mount_unionfs.c (24359) | mount_unionfs.c (25275) |
---|---|
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 --- 59 unchanged lines hidden (view full) --- 68 69int 70main(argc, argv) 71 int argc; 72 char *argv[]; 73{ 74 struct union_args args; 75 int ch, mntflags; | 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 --- 59 unchanged lines hidden (view full) --- 68 69int 70main(argc, argv) 71 int argc; 72 char *argv[]; 73{ 74 struct union_args args; 75 int ch, mntflags; |
76 char source[MAXPATHLEN]; |
|
76 char target[MAXPATHLEN]; 77 struct vfsconf vfc; 78 int error; 79 80 mntflags = 0; 81 args.mntflags = UNMNT_ABOVE; 82 while ((ch = getopt(argc, argv, "bo:r")) != -1) 83 switch (ch) { --- 17 unchanged lines hidden (view full) --- 101 argv += optind; 102 103 if (argc != 2) 104 usage(); 105 106 if (realpath(argv[0], target) == 0) 107 err(EX_OSERR, "%s", target); 108 | 77 char target[MAXPATHLEN]; 78 struct vfsconf vfc; 79 int error; 80 81 mntflags = 0; 82 args.mntflags = UNMNT_ABOVE; 83 while ((ch = getopt(argc, argv, "bo:r")) != -1) 84 switch (ch) { --- 17 unchanged lines hidden (view full) --- 102 argv += optind; 103 104 if (argc != 2) 105 usage(); 106 107 if (realpath(argv[0], target) == 0) 108 err(EX_OSERR, "%s", target); 109 |
109 if (subdir(target, argv[1]) || subdir(argv[1], target)) 110 errx(EX_USAGE, "%s (%s) and %s are not distinct paths", 111 argv[0], target, argv[1]); | 110 if (realpath(argv[1], source) == 0) 111 err(EX_OSERR, "%s", target); |
112 | 112 |
113 if (subdir(target, source) || subdir(source, target)) 114 errx(EX_USAGE, "%s (%s) and %s (%s) are not distinct paths", 115 argv[0], target, argv[1], source); 116 |
|
113 args.target = target; 114 115 error = getvfsbyname("union", &vfc); 116 if (error && vfsisloadable("union")) { 117 if (vfsload("union")) 118 err(EX_OSERR, "vfsload(union)"); 119 endvfsent(); /* flush cache */ 120 error = getvfsbyname("union", &vfc); 121 } 122 if (error) 123 errx(EX_OSERR, "union filesystem is not available"); 124 | 117 args.target = target; 118 119 error = getvfsbyname("union", &vfc); 120 if (error && vfsisloadable("union")) { 121 if (vfsload("union")) 122 err(EX_OSERR, "vfsload(union)"); 123 endvfsent(); /* flush cache */ 124 error = getvfsbyname("union", &vfc); 125 } 126 if (error) 127 errx(EX_OSERR, "union filesystem is not available"); 128 |
125 if (mount(vfc.vfc_name, argv[1], mntflags, &args)) | 129 if (mount(vfc.vfc_name, source, mntflags, &args)) |
126 err(EX_OSERR, target); 127 exit(0); 128} 129 130int 131subdir(p, dir) 132 const char *p; 133 const char *dir; --- 20 unchanged lines hidden --- | 130 err(EX_OSERR, target); 131 exit(0); 132} 133 134int 135subdir(p, dir) 136 const char *p; 137 const char *dir; --- 20 unchanged lines hidden --- |