X-Git-Url: https://git.camperquake.de/gitweb.cgi?a=blobdiff_plain;f=cmd%2Fmount_zfs%2Fmount_zfs.c;h=45c291e04ce000ab3d56d84d6da58d4c8d7b1a28;hb=739a1a82e0f366923e8d9bc8f9ad4b1c680a780b;hp=204f9fa14679a7818586b4139c1ad482fd30e517;hpb=3aff775555a40fe3e5193f1309ba6e80312be5ff;p=zfs.git diff --git a/cmd/mount_zfs/mount_zfs.c b/cmd/mount_zfs/mount_zfs.c index 204f9fa..45c291e 100644 --- a/cmd/mount_zfs/mount_zfs.c +++ b/cmd/mount_zfs/mount_zfs.c @@ -30,6 +30,7 @@ #include #include #include +#include #ifdef HAVE_LIBSELINUX #include #endif /* HAVE_LIBSELINUX */ @@ -96,6 +97,7 @@ static const option_map_t option_map[] = { { MNTOPT_QUIET, MS_SILENT, ZS_COMMENT }, #endif /* Custom zfs options */ + { MNTOPT_XATTR, MS_COMMENT, ZS_COMMENT }, { MNTOPT_NOXATTR, MS_COMMENT, ZS_COMMENT }, { MNTOPT_ZFSUTIL, MS_COMMENT, ZS_ZFSUTIL }, { NULL, 0, 0 } }; @@ -120,6 +122,7 @@ parse_option(char *mntopt, unsigned long *mntflags, if (*ptr == '=') { *ptr = '\0'; value = ptr+1; + VERIFY3P(value, !=, NULL); break; } } @@ -228,7 +231,9 @@ parse_dataset(char *dataset) char cwd[PATH_MAX]; int len; - (void) getcwd(cwd, PATH_MAX); + if (getcwd(cwd, PATH_MAX) == NULL) + return (dataset); + len = strlen(cwd); /* Do not add one when cwd already ends in a trailing '/' */ @@ -249,7 +254,7 @@ mtab_is_writeable(void) struct stat st; int error, fd; - error = stat(MNTTAB, &st); + error = lstat(MNTTAB, &st); if (error || S_ISLNK(st.st_mode)) return (0); @@ -425,15 +430,20 @@ main(int argc, char **argv) return (MOUNT_SYSERR); /* try to open the dataset to access the mount point */ - if ((zhp = zfs_open(g_zfs, dataset, ZFS_TYPE_FILESYSTEM)) == NULL) { + if ((zhp = zfs_open(g_zfs, dataset, + ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT)) == NULL) { (void) fprintf(stderr, gettext("filesystem '%s' cannot be " "mounted, unable to open the dataset\n"), dataset); libzfs_fini(g_zfs); return (MOUNT_USAGE); } - (void) zfs_prop_get(zhp, ZFS_PROP_MOUNTPOINT, legacy, - sizeof (legacy), NULL, NULL, 0, B_FALSE); + /* treat all snapshots as legacy mount points */ + if (zfs_get_type(zhp) == ZFS_TYPE_SNAPSHOT) + (void) strlcpy(legacy, ZFS_MOUNTPOINT_LEGACY, ZFS_MAXPROPLEN); + else + (void) zfs_prop_get(zhp, ZFS_PROP_MOUNTPOINT, legacy, + sizeof (legacy), NULL, NULL, 0, B_FALSE); zfs_close(zhp); libzfs_fini(g_zfs); @@ -471,6 +481,10 @@ main(int argc, char **argv) mntflags, mntopts); if (error) { switch (errno) { + case ENOENT: + (void) fprintf(stderr, gettext("mount point " + "'%s' does not exist\n"), mntpoint); + return (MOUNT_SYSERR); case EBUSY: (void) fprintf(stderr, gettext("filesystem " "'%s' is already mounted\n"), dataset);