Changeset View
Changeset View
Standalone View
Standalone View
sbin/mount/mount.c
Show First 20 Lines • Show All 83 Lines • ▼ Show 20 Lines | struct cpa { | ||||
int c; | int c; | ||||
}; | }; | ||||
char *catopt(char *, const char *); | char *catopt(char *, const char *); | ||||
struct statfs *getmntpt(const char *); | struct statfs *getmntpt(const char *); | ||||
int hasopt(const char *, const char *); | int hasopt(const char *, const char *); | ||||
int ismounted(struct fstab *, struct statfs *, int); | int ismounted(struct fstab *, struct statfs *, int); | ||||
int isremountable(const char *); | int isremountable(const char *); | ||||
int allow_file_mount(const char *); | |||||
void mangle(char *, struct cpa *); | void mangle(char *, struct cpa *); | ||||
char *update_options(char *, char *, int); | char *update_options(char *, char *, int); | ||||
int mountfs(const char *, const char *, const char *, | int mountfs(const char *, const char *, const char *, | ||||
int, const char *, const char *); | int, const char *, const char *); | ||||
void remopt(char *, const char *); | void remopt(char *, const char *); | ||||
void prmount(struct statfs *); | void prmount(struct statfs *); | ||||
void putfsent(struct statfs *); | void putfsent(struct statfs *); | ||||
void usage(void); | void usage(void); | ||||
▲ Show 20 Lines • Show All 398 Lines • ▼ Show 20 Lines | isremountable(const char *vfsname) | ||||
for (cp = remountable_fs_names; *cp; cp++) | for (cp = remountable_fs_names; *cp; cp++) | ||||
if (strcmp(*cp, vfsname) == 0) | if (strcmp(*cp, vfsname) == 0) | ||||
return (1); | return (1); | ||||
return (0); | return (0); | ||||
} | } | ||||
int | int | ||||
allow_file_mount(const char *vfsname) | |||||
{ | |||||
if (strcmp(vfsname, "nullfs") == 0) | |||||
return (1); | |||||
return (0); | |||||
} | |||||
int | |||||
hasopt(const char *mntopts, const char *option) | hasopt(const char *mntopts, const char *option) | ||||
{ | { | ||||
int negative, found; | int negative, found; | ||||
char *opt, *optbuf; | char *opt, *optbuf; | ||||
if (option[0] == 'n' && option[1] == 'o') { | if (option[0] == 'n' && option[1] == 'o') { | ||||
negative = 1; | negative = 1; | ||||
option += 2; | option += 2; | ||||
Show All 29 Lines | mountfs(const char *vfstype, const char *spec, const char *name, int flags, | ||||
const char *options, const char *mntopts) | const char *options, const char *mntopts) | ||||
{ | { | ||||
struct statfs sf; | struct statfs sf; | ||||
int i, ret; | int i, ret; | ||||
char *optbuf, execname[PATH_MAX], mntpath[PATH_MAX]; | char *optbuf, execname[PATH_MAX], mntpath[PATH_MAX]; | ||||
static struct cpa mnt_argv; | static struct cpa mnt_argv; | ||||
/* resolve the mountpoint with realpath(3) */ | /* resolve the mountpoint with realpath(3) */ | ||||
if (allow_file_mount(vfstype)) { | |||||
if (checkpath_allow_file(name, mntpath) != 0) { | |||||
xo_warn("%s", mntpath); | |||||
return (1); | |||||
} | |||||
} else { | |||||
if (checkpath(name, mntpath) != 0) { | if (checkpath(name, mntpath) != 0) { | ||||
xo_warn("%s", mntpath); | xo_warn("%s", mntpath); | ||||
return (1); | return (1); | ||||
} | |||||
} | } | ||||
name = mntpath; | name = mntpath; | ||||
if (mntopts == NULL) | if (mntopts == NULL) | ||||
mntopts = ""; | mntopts = ""; | ||||
optbuf = catopt(strdup(mntopts), options); | optbuf = catopt(strdup(mntopts), options); | ||||
if (strcmp(name, "/") == 0) | if (strcmp(name, "/") == 0) | ||||
▲ Show 20 Lines • Show All 424 Lines • Show Last 20 Lines |