Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F137955439
D23722.id68434.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
4 KB
Referenced Files
None
Subscribers
None
D23722.id68434.diff
View Options
Index: cddl/contrib/opensolaris/cmd/zfs/zfs_main.c
===================================================================
--- cddl/contrib/opensolaris/cmd/zfs/zfs_main.c
+++ cddl/contrib/opensolaris/cmd/zfs/zfs_main.c
@@ -59,6 +59,9 @@
#include <sys/mount.h>
#include <sys/stat.h>
#include <sys/fs/zfs.h>
+#ifdef __FreeBSD__
+#include <sys/sysctl.h>
+#endif
#include <sys/types.h>
#include <time.h>
#include <err.h>
@@ -6968,6 +6971,23 @@
/* check for legacy mountpoint and complain appropriately */
ret = 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) {
+ strlcpy(mntopts, default_mount_opts,
+ sizeof(mntopts));
+ if (tmp[0] != '\0') {
+ strlcat(mntopts, ",", sizeof(mntopts));
+ strlcat(mntopts, tmp, sizeof(mntopts));
+ }
+ }
+ free(default_mount_opts);
+ free(tmp);
+ }
+#endif /* __FreeBSD__ */
if (zmount(dataset, path, flags, MNTTYPE_ZFS,
NULL, 0, mntopts, sizeof (mntopts)) != 0) {
(void) fprintf(stderr, gettext("mount failed: %s\n"),
Index: cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h
===================================================================
--- cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h
+++ cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h
@@ -772,6 +772,9 @@
extern int zfs_mount_at(zfs_handle_t *, const char *, int, const char *);
extern int zfs_unmount(zfs_handle_t *, const char *, int);
extern int zfs_unmountall(zfs_handle_t *, int);
+#ifdef __FreeBSD__
+extern char *freebsd_default_mount_options(zfs_handle_t *);
+#endif
/*
* Share support functions.
Index: cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c
===================================================================
--- cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c
+++ cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c
@@ -80,6 +80,9 @@
#include <sys/mount.h>
#include <sys/stat.h>
#include <sys/statvfs.h>
+#ifdef __FreeBSD__
+#include <sys/sysctl.h>
+#endif
#include <libzfs.h>
@@ -359,6 +362,38 @@
return (zfs_mount_at(zhp, options, flags, mountpoint));
}
+#ifdef __FreeBSD__
+/*
+ * A helper function to look for FreeBSD-specific
+ * mount options, pre-mount. Right now, this looks
+ * at sysctl vfs.zfs.mount_options. The results from
+ * this need to be freed by the caller, and should be
+ * prepended to any user-requested mount options (since
+ * a user-requested option may undo one of the system
+ * default options).
+ */
+char *
+freebsd_default_mount_options(zfs_handle_t *zhp)
+{
+ char *retval = NULL;
+ size_t len = 0;
+ int rv;
+
+ rv = sysctlbyname("vfs.zfs.mount_options", NULL, &len, NULL, 0);
+ if (rv == -1)
+ return (NULL);
+
+ retval = malloc(len+1);
+ rv = sysctlbyname("vfs.zfs.mount_options", retval, &len, NULL, 0);
+ if (rv == 0) {
+ retval[len] = 0; /* Ensure NUL end */
+ return (retval);
+ }
+ free(retval);
+ return (NULL);
+}
+#endif /* __FreeBSD__ */
+
int
zfs_mount_at(zfs_handle_t *zhp, const char *options, int flags,
const char *mountpoint)
@@ -366,6 +401,9 @@
struct stat buf;
char mntopts[MNT_LINE_MAX];
libzfs_handle_t *hdl = zhp->zfs_hdl;
+#ifdef __FreeBSD__
+ char *default_mount_opts;
+#endif
if (options == NULL)
mntopts[0] = '\0';
@@ -409,6 +447,20 @@
}
#endif
+#ifdef __FreeBSD__
+ default_mount_opts = freebsd_default_mount_options(zhp);
+ if (default_mount_opts != NULL) {
+ const char *tmp = strdup(mntopts);
+
+ if (mntopts[0] != '\0')
+ (void)snprintf(mntopts, sizeof(mntopts), "%s,%s",
+ default_mount_opts, tmp);
+ else
+ strlcpy(mntopts, default_mount_opts, sizeof(mntopts));
+ free(tmp);
+ free(default_mount_opts);
+ }
+#endif /* __FreeBSD__ */
/* perform the mount */
if (zmount(zfs_get_name(zhp), mountpoint, flags,
MNTTYPE_ZFS, NULL, 0, mntopts, sizeof (mntopts)) != 0) {
Index: sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c
===================================================================
--- sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c
+++ sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c
@@ -91,6 +91,9 @@
static int zfs_version_zpl = ZPL_VERSION;
SYSCTL_INT(_vfs_zfs_version, OID_AUTO, zpl, CTLFLAG_RD, &zfs_version_zpl, 0,
"ZPL_VERSION");
+static char zfs_mount_options[1024];
+SYSCTL_STRING(_vfs_zfs, OID_AUTO, mount_options, CTLFLAG_RW,
+ zfs_mount_options, sizeof(zfs_mount_options), "System ZFS mount options");
static int zfs_quotactl(vfs_t *vfsp, int cmds, uid_t id, void *arg);
static int zfs_mount(vfs_t *vfsp);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Nov 28, 4:14 PM (6 h, 10 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
26283671
Default Alt Text
D23722.id68434.diff (4 KB)
Attached To
Mode
D23722: Allow default mount options for ZFS
Attached
Detach File
Event Timeline
Log In to Comment