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> |
57#include <unistd.h> 58 59#include "mntopts.h" 60 |
61static struct mntopt mopts[] = { |
62 MOPT_STDOPTS, 63 { NULL } 64}; 65 |
66static int subdir __P((const char *, const char *)); 67static __dead void usage __P((void)) __dead2; |
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) |
106 err(EX_OSERR, "%s", target); |
107 108 if (subdir(target, argv[1]) || subdir(argv[1], target)) |
109 errx(EX_USAGE, "%s (%s) and %s are not distinct paths", |
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"); |
123 |
124 if (mount(vfc->vfc_index, argv[1], mntflags, &args)) 125 err(EX_OSERR, target); |
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"); |
151 exit(EX_USAGE); |
152} |