Changeset View
Changeset View
Standalone View
Standalone View
cddl/contrib/opensolaris/cmd/zfs/zfs_main.c
Show First 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | |||||
#include <signal.h> | #include <signal.h> | ||||
#include <sys/debug.h> | #include <sys/debug.h> | ||||
#include <sys/list.h> | #include <sys/list.h> | ||||
#include <sys/mntent.h> | #include <sys/mntent.h> | ||||
#include <sys/mnttab.h> | #include <sys/mnttab.h> | ||||
#include <sys/mount.h> | #include <sys/mount.h> | ||||
#include <sys/stat.h> | #include <sys/stat.h> | ||||
#include <sys/fs/zfs.h> | #include <sys/fs/zfs.h> | ||||
#ifdef __FreeBSD__ | |||||
#include <sys/sysctl.h> | |||||
#endif | |||||
#include <sys/types.h> | #include <sys/types.h> | ||||
#include <time.h> | #include <time.h> | ||||
#include <err.h> | #include <err.h> | ||||
#include <jail.h> | #include <jail.h> | ||||
#include <libzfs.h> | #include <libzfs.h> | ||||
#include <libzfs_core.h> | #include <libzfs_core.h> | ||||
#include <zfs_prop.h> | #include <zfs_prop.h> | ||||
▲ Show 20 Lines • Show All 6,893 Lines • ▼ Show 20 Lines | if ((zhp = zfs_open(g_zfs, dataset, ZFS_TYPE_FILESYSTEM)) == NULL) | ||||
return (1); | return (1); | ||||
(void) zfs_prop_get(zhp, ZFS_PROP_MOUNTPOINT, mountpoint, | (void) zfs_prop_get(zhp, ZFS_PROP_MOUNTPOINT, mountpoint, | ||||
sizeof (mountpoint), NULL, NULL, 0, B_FALSE); | sizeof (mountpoint), NULL, NULL, 0, B_FALSE); | ||||
/* check for legacy mountpoint and complain appropriately */ | /* check for legacy mountpoint and complain appropriately */ | ||||
ret = 0; | ret = 0; | ||||
if (strcmp(mountpoint, ZFS_MOUNTPOINT_LEGACY) == 0) { | if (strcmp(mountpoint, ZFS_MOUNTPOINT_LEGACY) == 0) { | ||||
#ifdef __FreeBSD__ | |||||
char *default_mount_opts = freebsd_default_mount_options(zhp); | |||||
if (default_mount_opts != NULL) { | |||||
const char *tmp = strdup(mntopts); | |||||
if (tmp != NULL) { | |||||
delphij: this if..else block should be enclosed in a if (tmp != NULL) condition because tmp can be NULL. | |||||
strlcpy(mntopts, default_mount_opts, | |||||
sizeof(mntopts)); | |||||
if (tmp[0] != '\0') { | |||||
strlcat(mntopts, ",", sizeof(mntopts)); | |||||
strlcat(mntopts, tmp, sizeof(mntopts)); | |||||
} | |||||
delphijUnsubmitted Not Done Inline ActionsTook a closer look at the code. It looks like mntopts is only used when the file system is not mount=legacy (this codepath). It seems that you can move this whole code block above (line 6917), keeping only: char *default_mount_opts = freebsd_default_mount_options(zhp); if (default_mount_opts != NULL) { strlcpy(mntopts, default_mount_opts, sizeof(mntopts)); } free(default_mount_opts); and in line 6922, change the code to: if (mntopts[0] != '\0') { strlcat(mntopts, ",", sizeof(mntopts)); } strlcat(mntopts, optarg, sizeof(mntopts)); ? (Note that this changes -o semantics slightly, previously specifying it multiple times, the last one wins, now every time it appends new options; the alternative would be to save the optarg pointer and perform the appending after getopt() loop.) delphij: Took a closer look at the code. It looks like mntopts is only used when the file system is not… | |||||
sefAuthorUnsubmitted Done Inline ActionsOr just keep the code as I have it; this means that the new code isn't invoked except in the legacy case, and doesn't change the semantics of the -o option... sef: Or just keep the code as I have it; this means that the new code isn't invoked except in the… | |||||
} | |||||
free(default_mount_opts); | |||||
free(tmp); | |||||
} | |||||
#endif /* __FreeBSD__ */ | |||||
if (zmount(dataset, path, flags, MNTTYPE_ZFS, | if (zmount(dataset, path, flags, MNTTYPE_ZFS, | ||||
NULL, 0, mntopts, sizeof (mntopts)) != 0) { | NULL, 0, mntopts, sizeof (mntopts)) != 0) { | ||||
(void) fprintf(stderr, gettext("mount failed: %s\n"), | (void) fprintf(stderr, gettext("mount failed: %s\n"), | ||||
strerror(errno)); | strerror(errno)); | ||||
ret = 1; | ret = 1; | ||||
} | } | ||||
} else { | } else { | ||||
(void) fprintf(stderr, gettext("filesystem '%s' cannot be " | (void) fprintf(stderr, gettext("filesystem '%s' cannot be " | ||||
▲ Show 20 Lines • Show All 601 Lines • Show Last 20 Lines |
this if..else block should be enclosed in a if (tmp != NULL) condition because tmp can be NULL.