mount_unionfs.c (4065) | mount_unionfs.c (15770) |
---|---|
1/* 2 * Copyright (c) 1992, 1993, 1994 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software donated to Berkeley by 6 * Jan-Simon Pendry. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 39 unchanged lines hidden (view full) --- 48#include <sys/mount.h> 49 50#include <miscfs/union/union.h> 51 52#include <err.h> 53#include <stdio.h> 54#include <stdlib.h> 55#include <string.h> | 1/* 2 * Copyright (c) 1992, 1993, 1994 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software donated to Berkeley by 6 * Jan-Simon Pendry. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 39 unchanged lines hidden (view full) --- 48#include <sys/mount.h> 49 50#include <miscfs/union/union.h> 51 52#include <err.h> 53#include <stdio.h> 54#include <stdlib.h> 55#include <string.h> |
56#include <sysexits.h> |
|
56#include <unistd.h> 57 58#include "mntopts.h" 59 | 57#include <unistd.h> 58 59#include "mntopts.h" 60 |
60struct mntopt mopts[] = { | 61static struct mntopt mopts[] = { |
61 MOPT_STDOPTS, 62 { NULL } 63}; 64 | 62 MOPT_STDOPTS, 63 { NULL } 64}; 65 |
65int subdir __P((const char *, const char *)); 66void usage __P((void)); | 66static int subdir __P((const char *, const char *)); 67static __dead void usage __P((void)) __dead2; |
67 68int 69main(argc, argv) 70 int argc; 71 char *argv[]; 72{ 73 struct union_args args; 74 int ch, mntflags; --- 22 unchanged lines hidden (view full) --- 97 } 98 argc -= optind; 99 argv += optind; 100 101 if (argc != 2) 102 usage(); 103 104 if (realpath(argv[0], target) == 0) | 68 69int 70main(argc, argv) 71 int argc; 72 char *argv[]; 73{ 74 struct union_args args; 75 int ch, mntflags; --- 22 unchanged lines hidden (view full) --- 98 } 99 argc -= optind; 100 argv += optind; 101 102 if (argc != 2) 103 usage(); 104 105 if (realpath(argv[0], target) == 0) |
105 err(1, "%s", target); | 106 err(EX_OSERR, "%s", target); |
106 107 if (subdir(target, argv[1]) || subdir(argv[1], target)) | 107 108 if (subdir(target, argv[1]) || subdir(argv[1], target)) |
108 errx(1, "%s (%s) and %s are not distinct paths", | 109 errx(EX_USAGE, "%s (%s) and %s are not distinct paths", |
109 argv[0], target, argv[1]); 110 111 args.target = target; 112 113 vfc = getvfsbyname("union"); 114 if(!vfc && vfsisloadable("union")) { 115 if(vfsload("union")) 116 err(1, "vfsload(union)"); 117 endvfsent(); /* flush cache */ 118 vfc = getvfsbyname("union"); 119 } | 110 argv[0], target, argv[1]); 111 112 args.target = target; 113 114 vfc = getvfsbyname("union"); 115 if(!vfc && vfsisloadable("union")) { 116 if(vfsload("union")) 117 err(1, "vfsload(union)"); 118 endvfsent(); /* flush cache */ 119 vfc = getvfsbyname("union"); 120 } |
121 if (!vfc) 122 errx(EX_OSERR, "union filesystem is not available"); |
|
120 | 123 |
121 if (mount(vfc ? vfc->vfc_index : MOUNT_UNION, argv[1], mntflags, &args)) 122 err(1, NULL); | 124 if (mount(vfc->vfc_index, argv[1], mntflags, &args)) 125 err(EX_OSERR, target); |
123 exit(0); 124} 125 126int 127subdir(p, dir) 128 const char *p; 129 const char *dir; 130{ --- 9 unchanged lines hidden (view full) --- 140 return (0); 141} 142 143void 144usage() 145{ 146 (void)fprintf(stderr, 147 "usage: mount_union [-br] [-o options] target_fs mount_point\n"); | 126 exit(0); 127} 128 129int 130subdir(p, dir) 131 const char *p; 132 const char *dir; 133{ --- 9 unchanged lines hidden (view full) --- 143 return (0); 144} 145 146void 147usage() 148{ 149 (void)fprintf(stderr, 150 "usage: mount_union [-br] [-o options] target_fs mount_point\n"); |
148 exit(1); | 151 exit(EX_USAGE); |
149} | 152} |