@@ -2207,6 +2207,9 @@ static int loop_add(struct loop_device **l, int i, struct inode *inode)
disk->private_data = lo;
disk->queue = lo->lo_queue;
sprintf(disk->disk_name, "loop%d", i);
+#ifdef CONFIG_BLK_DEV_LOOPFS
+ loopfs_init(disk, inode);
+#endif
add_disk(disk);
@@ -74,6 +74,12 @@ bool loopfs_wants_remove(const struct loop_device *lo)
(lo->lo_info->lo_flags & LOOPFS_FLAGS_INACTIVE);
}
+void loopfs_init(struct gendisk *disk, struct inode *inode)
+{
+ if (loopfs_i_sb(inode))
+ disk->user_ns = loopfs_i_sb(inode)->s_user_ns;
+}
+
/**
* loopfs_add - allocate inode from super block of a loopfs mount
* @lo: loop device for which we are creating a new device entry
@@ -31,6 +31,7 @@ extern void loopfs_remove(struct loop_device *lo);
extern bool loopfs_wants_remove(const struct loop_device *lo);
extern void loopfs_evict_locked(struct loop_device *lo);
extern int loopfs_rundown_locked(struct loop_device *lo);
+extern void loopfs_init(struct gendisk *disk, struct inode *inode);
#endif