We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6ba51da commit 9a8e5cbCopy full SHA for 9a8e5cb
include/sys/dsl_dataset.h
@@ -268,6 +268,10 @@ typedef struct dsl_dataset {
268
269
/* Protected by ds_lock; keep at end of struct for better locality */
270
char ds_snapname[ZFS_MAX_DATASET_NAME_LEN];
271
+
272
+#ifdef __FreeBSD__
273
+ char *ds_jailname;
274
+#endif
275
} dsl_dataset_t;
276
277
static inline dsl_dataset_phys_t *
include/sys/fs/zfs.h
@@ -203,6 +203,7 @@ typedef enum {
203
ZFS_PROP_DEFAULTUSEROBJQUOTA,
204
ZFS_PROP_DEFAULTGROUPOBJQUOTA,
205
ZFS_PROP_DEFAULTPROJECTOBJQUOTA,
206
+ ZFS_PROP_ZONE,
207
ZFS_NUM_PROPS
208
} zfs_prop_t;
209
man/man7/zfsprops.7
@@ -2095,6 +2095,14 @@ for more information.
2095
Jails are a
2096
.Fx
2097
feature and this property is not available on other platforms.
2098
+.It Sy jail
2099
+This read-only property reports the name of the jail that mounted the jailed
2100
+dataset.
2101
+The "0" name is used for datasets that are not mounted or not jailed.
2102
+If a jail is renamed, the property will still report its old name from
2103
+the time the dataset was mounted.
2104
+The reported jail may no longer exist, while the dataset remains mounted.
2105
+The property is not revealed to jails, the "0" is reported instead.
2106
.It Sy zoned Ns = Ns Sy off Ns | Ns Sy on
2107
Controls whether the dataset is managed from a non-global zone or namespace.
2108
See
module/os/freebsd/zfs/zfs_vfsops.c
@@ -1310,6 +1310,20 @@ zfs_domount(vfs_t *vfsp, char *osname)
1310
1311
if (!zfsvfs->z_issnap)
1312
zfsctl_create(zfsvfs);
1313
1314
1315
+ if (error == 0) {
1316
+ /* zone dataset visiblity was checked before in zfs_mount() */
1317
+ struct prison *pr = curthread->td_ucred->cr_prison;
1318
+ if (pr != &prison0) {
1319
+ zfsvfs->z_os->os_dsl_dataset->ds_jailname =
1320
+ kmem_zalloc(strlen(pr->pr_name) + 1, KM_SLEEP);
1321
+ strcpy(zfsvfs->z_os->os_dsl_dataset->ds_jailname,
1322
+ pr->pr_name);
1323
+ }
1324
1325
1326
1327
out:
1328
if (error) {
1329
dmu_objset_disown(zfsvfs->z_os, B_TRUE, zfsvfs);
@@ -1783,6 +1797,12 @@ zfs_umount(vfs_t *vfsp, int fflag)
1783
1797
dmu_objset_set_user(os, NULL);
1784
1798
mutex_exit(&os->os_user_ptr_lock);
1785
1799
1800
1801
+ if (os->os_dsl_dataset->ds_jailname)
1802
+ kmem_strfree(os->os_dsl_dataset->ds_jailname);
1803
+ os->os_dsl_dataset->ds_jailname = NULL;
1804
1805
1786
1806
/*
1787
1807
* Finally release the objset
1788
1808
*/
module/zcommon/zfs_prop.c
@@ -516,9 +516,13 @@ zfs_prop_init(void)
516
zprop_register_index(ZFS_PROP_ZONED, "jailed", 0, PROP_INHERIT,
517
ZFS_TYPE_FILESYSTEM, "on | off", "JAILED", boolean_table,
518
sfeatures);
519
+ zprop_register_string(ZFS_PROP_ZONE, "jail", NULL, PROP_READONLY,
520
+ ZFS_TYPE_FILESYSTEM, "<jailname> | 0", "JAIL", sfeatures);
521
#else
522
zprop_register_index(ZFS_PROP_ZONED, "zoned", 0, PROP_INHERIT,
523
ZFS_TYPE_FILESYSTEM, "on | off", "ZONED", boolean_table, sfeatures);
524
+ zprop_register_string(ZFS_PROP_ZONE, "zone", NULL, PROP_READONLY,
525
+ ZFS_TYPE_FILESYSTEM, "<zonename>", "ZONE", sfeatures);
526
#endif
527
zprop_register_index(ZFS_PROP_VSCAN, "vscan", 0, PROP_INHERIT,
528
ZFS_TYPE_FILESYSTEM, "on | off", "VSCAN", boolean_table, sfeatures);
module/zfs/dsl_prop.c
@@ -1230,6 +1230,18 @@ dsl_prop_get_all_ds(dsl_dataset_t *ds, nvlist_t **nvp,
1230
goto out;
1231
}
1232
1233
1234
+ nvlist_t *propval;
1235
+ dsl_dataset_name(ds, setpoint);
1236
+ VERIFY0(nvlist_alloc(&propval, NV_UNIQUE_NAME, KM_SLEEP));
1237
+ VERIFY0(nvlist_add_string(propval, ZPROP_VALUE,
1238
+ (ds->ds_jailname && INGLOBALZONE(curproc)) ?
1239
+ ds->ds_jailname : "0"));
1240
+ VERIFY0(nvlist_add_string(propval, ZPROP_SOURCE, setpoint));
1241
+ VERIFY0(nvlist_add_nvlist(*nvp, "jail", propval));
1242
+ nvlist_free(propval);
1243
1244
1245
for (; dd != NULL; dd = dd->dd_parent) {
1246
if (dd != ds->ds_dir || (flags & DSL_PROP_GET_SNAPSHOT)) {
1247
if (flags & (DSL_PROP_GET_LOCAL |
0 commit comments