4 * Copyright (C) 1991, 1992 Linus Torvalds
6 * super.c contains code to handle: - mount structures
8 * - filesystem drivers list
10 * - umount system call
13 * GK 2/5/95 - Changed to support mounting the root fs via NFS
15 * Added kerneld support: Jacques Gelinas and Bjorn Ekwall
16 * Added change_root: Werner Almesberger & Hans Lermen, Feb '96
17 * Added options to /proc/mounts:
18 * Torbjörn Lindh (torbjorn.lindh@gopta.se), April 14, 1996.
19 * Added devfs support: Richard Gooch <rgooch@atnf.csiro.au>, 13-JAN-1998
20 * Heavily rewritten for 'one fs - one tree' dcache architecture. AV, Mar 2000
23 #include <linux/module.h>
24 #include <linux/slab.h>
25 #include <linux/acct.h>
26 #include <linux/blkdev.h>
27 #include <linux/quotaops.h>
28 #include <linux/mount.h>
29 #include <linux/security.h>
30 #include <linux/writeback.h> /* for the emergency remount stuff */
31 #include <linux/idr.h>
32 #include <linux/mutex.h>
33 #include <linux/backing-dev.h>
37 LIST_HEAD(super_blocks);
38 DEFINE_SPINLOCK(sb_lock);
41 * alloc_super - create new superblock
42 * @type: filesystem type superblock should belong to
44 * Allocates and initializes a new &struct super_block. alloc_super()
45 * returns a pointer new superblock or %NULL if allocation had failed.
47 static struct super_block *alloc_super(struct file_system_type *type)
49 struct super_block *s = kzalloc(sizeof(struct super_block), GFP_USER);
50 static const struct super_operations default_op;
53 if (security_sb_alloc(s)) {
58 INIT_LIST_HEAD(&s->s_files);
59 INIT_LIST_HEAD(&s->s_instances);
60 INIT_HLIST_HEAD(&s->s_anon);
61 INIT_LIST_HEAD(&s->s_inodes);
62 INIT_LIST_HEAD(&s->s_dentry_lru);
63 init_rwsem(&s->s_umount);
64 mutex_init(&s->s_lock);
65 lockdep_set_class(&s->s_umount, &type->s_umount_key);
67 * The locking rules for s_lock are up to the
68 * filesystem. For example ext3fs has different
69 * lock ordering than usbfs:
71 lockdep_set_class(&s->s_lock, &type->s_lock_key);
73 * sget() can have s_umount recursion.
75 * When it cannot find a suitable sb, it allocates a new
76 * one (this one), and tries again to find a suitable old
79 * In case that succeeds, it will acquire the s_umount
80 * lock of the old one. Since these are clearly distrinct
81 * locks, and this object isn't exposed yet, there's no
84 * Annotate this by putting this lock in a different
87 down_write_nested(&s->s_umount, SINGLE_DEPTH_NESTING);
89 atomic_set(&s->s_active, 1);
90 mutex_init(&s->s_vfs_rename_mutex);
91 mutex_init(&s->s_dquot.dqio_mutex);
92 mutex_init(&s->s_dquot.dqonoff_mutex);
93 init_rwsem(&s->s_dquot.dqptr_sem);
94 init_waitqueue_head(&s->s_wait_unfrozen);
95 s->s_maxbytes = MAX_NON_LFS;
96 s->dq_op = sb_dquot_ops;
97 s->s_qcop = sb_quotactl_ops;
98 s->s_op = &default_op;
99 s->s_time_gran = 1000000000;
106 * destroy_super - frees a superblock
107 * @s: superblock to free
109 * Frees a superblock.
111 static inline void destroy_super(struct super_block *s)
119 /* Superblock refcounting */
122 * Drop a superblock's refcount. The caller must hold sb_lock.
124 void __put_super(struct super_block *sb)
126 if (!--sb->s_count) {
127 list_del_init(&sb->s_list);
133 * put_super - drop a temporary reference to superblock
134 * @sb: superblock in question
136 * Drops a temporary reference, frees superblock if there's no
139 void put_super(struct super_block *sb)
143 spin_unlock(&sb_lock);
148 * deactivate_locked_super - drop an active reference to superblock
149 * @s: superblock to deactivate
151 * Drops an active reference to superblock, converting it into a temprory
152 * one if there is no other active references left. In that case we
153 * tell fs driver to shut it down and drop the temporary reference we
156 * Caller holds exclusive lock on superblock; that lock is released.
158 void deactivate_locked_super(struct super_block *s)
160 struct file_system_type *fs = s->s_type;
161 if (atomic_dec_and_test(&s->s_active)) {
167 up_write(&s->s_umount);
171 EXPORT_SYMBOL(deactivate_locked_super);
174 * deactivate_super - drop an active reference to superblock
175 * @s: superblock to deactivate
177 * Variant of deactivate_locked_super(), except that superblock is *not*
178 * locked by caller. If we are going to drop the final active reference,
179 * lock will be acquired prior to that.
181 void deactivate_super(struct super_block *s)
183 if (!atomic_add_unless(&s->s_active, -1, 1)) {
184 down_write(&s->s_umount);
185 deactivate_locked_super(s);
189 EXPORT_SYMBOL(deactivate_super);
192 * grab_super - acquire an active reference
193 * @s: reference we are trying to make active
195 * Tries to acquire an active reference. grab_super() is used when we
196 * had just found a superblock in super_blocks or fs_type->fs_supers
197 * and want to turn it into a full-blown active reference. grab_super()
198 * is called with sb_lock held and drops it. Returns 1 in case of
199 * success, 0 if we had failed (superblock contents was already dead or
200 * dying when grab_super() had been called).
202 static int grab_super(struct super_block *s) __releases(sb_lock)
204 if (atomic_inc_not_zero(&s->s_active)) {
205 spin_unlock(&sb_lock);
208 /* it's going away */
210 spin_unlock(&sb_lock);
211 /* wait for it to die */
212 down_write(&s->s_umount);
213 up_write(&s->s_umount);
219 * Superblock locking. We really ought to get rid of these two.
221 void lock_super(struct super_block * sb)
224 mutex_lock(&sb->s_lock);
227 void unlock_super(struct super_block * sb)
230 mutex_unlock(&sb->s_lock);
233 EXPORT_SYMBOL(lock_super);
234 EXPORT_SYMBOL(unlock_super);
237 * generic_shutdown_super - common helper for ->kill_sb()
238 * @sb: superblock to kill
240 * generic_shutdown_super() does all fs-independent work on superblock
241 * shutdown. Typical ->kill_sb() should pick all fs-specific objects
242 * that need destruction out of superblock, call generic_shutdown_super()
243 * and release aforementioned objects. Note: dentries and inodes _are_
244 * taken care of and do not need specific handling.
246 * Upon calling this function, the filesystem may no longer alter or
247 * rearrange the set of dentries belonging to this super_block, nor may it
248 * change the attachments of dentries to inodes.
250 void generic_shutdown_super(struct super_block *sb)
252 const struct super_operations *sop = sb->s_op;
256 shrink_dcache_for_umount(sb);
259 sb->s_flags &= ~MS_ACTIVE;
261 /* bad name - it should be evict_inodes() */
262 invalidate_inodes(sb);
267 /* Forget any remaining inodes */
268 if (invalidate_inodes(sb)) {
269 printk("VFS: Busy inodes after unmount of %s. "
270 "Self-destruct in 5 seconds. Have a nice day...\n",
276 /* should be initialized for __put_super_and_need_restart() */
277 list_del_init(&sb->s_instances);
278 spin_unlock(&sb_lock);
279 up_write(&sb->s_umount);
282 EXPORT_SYMBOL(generic_shutdown_super);
285 * sget - find or create a superblock
286 * @type: filesystem type superblock should belong to
287 * @test: comparison callback
288 * @set: setup callback
289 * @data: argument to each of them
291 struct super_block *sget(struct file_system_type *type,
292 int (*test)(struct super_block *,void *),
293 int (*set)(struct super_block *,void *),
296 struct super_block *s = NULL;
297 struct super_block *old;
303 list_for_each_entry(old, &type->fs_supers, s_instances) {
304 if (!test(old, data))
306 if (!grab_super(old))
309 up_write(&s->s_umount);
312 down_write(&old->s_umount);
317 spin_unlock(&sb_lock);
318 s = alloc_super(type);
320 return ERR_PTR(-ENOMEM);
326 spin_unlock(&sb_lock);
327 up_write(&s->s_umount);
332 strlcpy(s->s_id, type->name, sizeof(s->s_id));
333 list_add_tail(&s->s_list, &super_blocks);
334 list_add(&s->s_instances, &type->fs_supers);
335 spin_unlock(&sb_lock);
336 get_filesystem(type);
342 void drop_super(struct super_block *sb)
344 up_read(&sb->s_umount);
348 EXPORT_SYMBOL(drop_super);
351 * sync_supers - helper for periodic superblock writeback
353 * Call the write_super method if present on all dirty superblocks in
354 * the system. This is for the periodic writeback used by most older
355 * filesystems. For data integrity superblock writeback use
356 * sync_filesystems() instead.
358 * Note: check the dirty flag before waiting, so we don't
359 * hold up the sync while mounting a device. (The newly
360 * mounted device won't need syncing.)
362 void sync_supers(void)
364 struct super_block *sb, *n;
367 list_for_each_entry_safe(sb, n, &super_blocks, s_list) {
368 if (list_empty(&sb->s_instances))
370 if (sb->s_op->write_super && sb->s_dirt) {
372 spin_unlock(&sb_lock);
374 down_read(&sb->s_umount);
375 if (sb->s_root && sb->s_dirt)
376 sb->s_op->write_super(sb);
377 up_read(&sb->s_umount);
383 spin_unlock(&sb_lock);
387 * iterate_supers - call function for all active superblocks
388 * @f: function to call
389 * @arg: argument to pass to it
391 * Scans the superblock list and calls given function, passing it
392 * locked superblock and given argument.
394 void iterate_supers(void (*f)(struct super_block *, void *), void *arg)
396 struct super_block *sb, *n;
399 list_for_each_entry_safe(sb, n, &super_blocks, s_list) {
400 if (list_empty(&sb->s_instances))
403 spin_unlock(&sb_lock);
405 down_read(&sb->s_umount);
408 up_read(&sb->s_umount);
413 spin_unlock(&sb_lock);
417 * get_super - get the superblock of a device
418 * @bdev: device to get the superblock for
420 * Scans the superblock list and finds the superblock of the file system
421 * mounted on the device given. %NULL is returned if no match is found.
424 struct super_block *get_super(struct block_device *bdev)
426 struct super_block *sb;
433 list_for_each_entry(sb, &super_blocks, s_list) {
434 if (list_empty(&sb->s_instances))
436 if (sb->s_bdev == bdev) {
438 spin_unlock(&sb_lock);
439 down_read(&sb->s_umount);
443 up_read(&sb->s_umount);
444 /* nope, got unmounted */
450 spin_unlock(&sb_lock);
454 EXPORT_SYMBOL(get_super);
457 * get_active_super - get an active reference to the superblock of a device
458 * @bdev: device to get the superblock for
460 * Scans the superblock list and finds the superblock of the file system
461 * mounted on the device given. Returns the superblock with an active
462 * reference or %NULL if none was found.
464 struct super_block *get_active_super(struct block_device *bdev)
466 struct super_block *sb;
473 list_for_each_entry(sb, &super_blocks, s_list) {
474 if (list_empty(&sb->s_instances))
476 if (sb->s_bdev == bdev) {
477 if (grab_super(sb)) /* drops sb_lock */
483 spin_unlock(&sb_lock);
487 struct super_block *user_get_super(dev_t dev)
489 struct super_block *sb;
493 list_for_each_entry(sb, &super_blocks, s_list) {
494 if (list_empty(&sb->s_instances))
496 if (sb->s_dev == dev) {
498 spin_unlock(&sb_lock);
499 down_read(&sb->s_umount);
503 up_read(&sb->s_umount);
504 /* nope, got unmounted */
510 spin_unlock(&sb_lock);
515 * do_remount_sb - asks filesystem to change mount options.
516 * @sb: superblock in question
517 * @flags: numeric part of options
518 * @data: the rest of options
519 * @force: whether or not to force the change
521 * Alters the mount options of a mounted file system.
523 int do_remount_sb(struct super_block *sb, int flags, void *data, int force)
526 int remount_rw, remount_ro;
528 if (sb->s_frozen != SB_UNFROZEN)
532 if (!(flags & MS_RDONLY) && bdev_read_only(sb->s_bdev))
536 if (flags & MS_RDONLY)
538 shrink_dcache_sb(sb);
541 remount_ro = (flags & MS_RDONLY) && !(sb->s_flags & MS_RDONLY);
542 remount_rw = !(flags & MS_RDONLY) && (sb->s_flags & MS_RDONLY);
544 /* If we are remounting RDONLY and current sb is read/write,
545 make sure there are no rw files opened */
549 else if (!fs_may_remount_ro(sb))
551 retval = vfs_dq_off(sb, 1);
552 if (retval < 0 && retval != -ENOSYS)
556 if (sb->s_op->remount_fs) {
557 retval = sb->s_op->remount_fs(sb, &flags, data);
561 sb->s_flags = (sb->s_flags & ~MS_RMT_MASK) | (flags & MS_RMT_MASK);
563 vfs_dq_quota_on_remount(sb);
565 * Some filesystems modify their metadata via some other path than the
566 * bdev buffer cache (eg. use a private mapping, or directories in
567 * pagecache, etc). Also file data modifications go via their own
568 * mappings. So If we try to mount readonly then copy the filesystem
569 * from bdev, we could get stale data, so invalidate it to give a best
570 * effort at coherency.
572 if (remount_ro && sb->s_bdev)
573 invalidate_bdev(sb->s_bdev);
577 static void do_emergency_remount(struct work_struct *work)
579 struct super_block *sb, *n;
582 list_for_each_entry_safe(sb, n, &super_blocks, s_list) {
583 if (list_empty(&sb->s_instances))
586 spin_unlock(&sb_lock);
587 down_write(&sb->s_umount);
588 if (sb->s_root && sb->s_bdev && !(sb->s_flags & MS_RDONLY)) {
590 * What lock protects sb->s_flags??
592 do_remount_sb(sb, MS_RDONLY, NULL, 1);
594 up_write(&sb->s_umount);
598 spin_unlock(&sb_lock);
600 printk("Emergency Remount complete\n");
603 void emergency_remount(void)
605 struct work_struct *work;
607 work = kmalloc(sizeof(*work), GFP_ATOMIC);
609 INIT_WORK(work, do_emergency_remount);
615 * Unnamed block devices are dummy devices used by virtual
616 * filesystems which don't use real block-devices. -- jrs
619 static DEFINE_IDA(unnamed_dev_ida);
620 static DEFINE_SPINLOCK(unnamed_dev_lock);/* protects the above */
621 static int unnamed_dev_start = 0; /* don't bother trying below it */
623 int set_anon_super(struct super_block *s, void *data)
629 if (ida_pre_get(&unnamed_dev_ida, GFP_ATOMIC) == 0)
631 spin_lock(&unnamed_dev_lock);
632 error = ida_get_new_above(&unnamed_dev_ida, unnamed_dev_start, &dev);
634 unnamed_dev_start = dev + 1;
635 spin_unlock(&unnamed_dev_lock);
636 if (error == -EAGAIN)
637 /* We raced and lost with another CPU. */
642 if ((dev & MAX_ID_MASK) == (1 << MINORBITS)) {
643 spin_lock(&unnamed_dev_lock);
644 ida_remove(&unnamed_dev_ida, dev);
645 if (unnamed_dev_start > dev)
646 unnamed_dev_start = dev;
647 spin_unlock(&unnamed_dev_lock);
650 s->s_dev = MKDEV(0, dev & MINORMASK);
651 s->s_bdi = &noop_backing_dev_info;
655 EXPORT_SYMBOL(set_anon_super);
657 void kill_anon_super(struct super_block *sb)
659 int slot = MINOR(sb->s_dev);
661 generic_shutdown_super(sb);
662 spin_lock(&unnamed_dev_lock);
663 ida_remove(&unnamed_dev_ida, slot);
664 if (slot < unnamed_dev_start)
665 unnamed_dev_start = slot;
666 spin_unlock(&unnamed_dev_lock);
669 EXPORT_SYMBOL(kill_anon_super);
671 void kill_litter_super(struct super_block *sb)
674 d_genocide(sb->s_root);
678 EXPORT_SYMBOL(kill_litter_super);
680 static int ns_test_super(struct super_block *sb, void *data)
682 return sb->s_fs_info == data;
685 static int ns_set_super(struct super_block *sb, void *data)
687 sb->s_fs_info = data;
688 return set_anon_super(sb, NULL);
691 int get_sb_ns(struct file_system_type *fs_type, int flags, void *data,
692 int (*fill_super)(struct super_block *, void *, int),
693 struct vfsmount *mnt)
695 struct super_block *sb;
697 sb = sget(fs_type, ns_test_super, ns_set_super, data);
704 err = fill_super(sb, data, flags & MS_SILENT ? 1 : 0);
706 deactivate_locked_super(sb);
710 sb->s_flags |= MS_ACTIVE;
713 simple_set_mnt(mnt, sb);
717 EXPORT_SYMBOL(get_sb_ns);
720 static int set_bdev_super(struct super_block *s, void *data)
723 s->s_dev = s->s_bdev->bd_dev;
726 * We set the bdi here to the queue backing, file systems can
727 * overwrite this in ->fill_super()
729 s->s_bdi = &bdev_get_queue(s->s_bdev)->backing_dev_info;
733 static int test_bdev_super(struct super_block *s, void *data)
735 return (void *)s->s_bdev == data;
738 int get_sb_bdev(struct file_system_type *fs_type,
739 int flags, const char *dev_name, void *data,
740 int (*fill_super)(struct super_block *, void *, int),
741 struct vfsmount *mnt)
743 struct block_device *bdev;
744 struct super_block *s;
745 fmode_t mode = FMODE_READ;
748 if (!(flags & MS_RDONLY))
751 bdev = open_bdev_exclusive(dev_name, mode, fs_type);
753 return PTR_ERR(bdev);
756 * once the super is inserted into the list by sget, s_umount
757 * will protect the lockfs code from trying to start a snapshot
758 * while we are mounting
760 mutex_lock(&bdev->bd_fsfreeze_mutex);
761 if (bdev->bd_fsfreeze_count > 0) {
762 mutex_unlock(&bdev->bd_fsfreeze_mutex);
766 s = sget(fs_type, test_bdev_super, set_bdev_super, bdev);
767 mutex_unlock(&bdev->bd_fsfreeze_mutex);
772 if ((flags ^ s->s_flags) & MS_RDONLY) {
773 deactivate_locked_super(s);
778 close_bdev_exclusive(bdev, mode);
780 char b[BDEVNAME_SIZE];
784 strlcpy(s->s_id, bdevname(bdev, b), sizeof(s->s_id));
785 sb_set_blocksize(s, block_size(bdev));
786 error = fill_super(s, data, flags & MS_SILENT ? 1 : 0);
788 deactivate_locked_super(s);
792 s->s_flags |= MS_ACTIVE;
796 simple_set_mnt(mnt, s);
802 close_bdev_exclusive(bdev, mode);
807 EXPORT_SYMBOL(get_sb_bdev);
809 void kill_block_super(struct super_block *sb)
811 struct block_device *bdev = sb->s_bdev;
812 fmode_t mode = sb->s_mode;
814 bdev->bd_super = NULL;
815 generic_shutdown_super(sb);
817 close_bdev_exclusive(bdev, mode);
820 EXPORT_SYMBOL(kill_block_super);
823 int get_sb_nodev(struct file_system_type *fs_type,
824 int flags, void *data,
825 int (*fill_super)(struct super_block *, void *, int),
826 struct vfsmount *mnt)
829 struct super_block *s = sget(fs_type, NULL, set_anon_super, NULL);
836 error = fill_super(s, data, flags & MS_SILENT ? 1 : 0);
838 deactivate_locked_super(s);
841 s->s_flags |= MS_ACTIVE;
842 simple_set_mnt(mnt, s);
846 EXPORT_SYMBOL(get_sb_nodev);
848 static int compare_single(struct super_block *s, void *p)
853 int get_sb_single(struct file_system_type *fs_type,
854 int flags, void *data,
855 int (*fill_super)(struct super_block *, void *, int),
856 struct vfsmount *mnt)
858 struct super_block *s;
861 s = sget(fs_type, compare_single, set_anon_super, NULL);
866 error = fill_super(s, data, flags & MS_SILENT ? 1 : 0);
868 deactivate_locked_super(s);
871 s->s_flags |= MS_ACTIVE;
873 do_remount_sb(s, flags, data, 0);
875 simple_set_mnt(mnt, s);
879 EXPORT_SYMBOL(get_sb_single);
882 vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void *data)
884 struct vfsmount *mnt;
885 char *secdata = NULL;
889 return ERR_PTR(-ENODEV);
892 mnt = alloc_vfsmnt(name);
896 if (flags & MS_KERNMOUNT)
897 mnt->mnt_flags = MNT_INTERNAL;
899 if (data && !(type->fs_flags & FS_BINARY_MOUNTDATA)) {
900 secdata = alloc_secdata();
904 error = security_sb_copy_data(data, secdata);
906 goto out_free_secdata;
909 error = type->get_sb(type, flags, name, data, mnt);
911 goto out_free_secdata;
912 BUG_ON(!mnt->mnt_sb);
913 WARN_ON(!mnt->mnt_sb->s_bdi);
915 error = security_sb_kern_mount(mnt->mnt_sb, flags, secdata);
920 * filesystems should never set s_maxbytes larger than MAX_LFS_FILESIZE
921 * but s_maxbytes was an unsigned long long for many releases. Throw
922 * this warning for a little while to try and catch filesystems that
923 * violate this rule. This warning should be either removed or
924 * converted to a BUG() in 2.6.34.
926 WARN((mnt->mnt_sb->s_maxbytes < 0), "%s set sb->s_maxbytes to "
927 "negative value (%lld)\n", type->name, mnt->mnt_sb->s_maxbytes);
929 mnt->mnt_mountpoint = mnt->mnt_root;
930 mnt->mnt_parent = mnt;
931 up_write(&mnt->mnt_sb->s_umount);
932 free_secdata(secdata);
936 deactivate_locked_super(mnt->mnt_sb);
938 free_secdata(secdata);
942 return ERR_PTR(error);
945 EXPORT_SYMBOL_GPL(vfs_kern_mount);
948 * freeze_super -- lock the filesystem and force it into a consistent state
949 * @super: the super to lock
951 * Syncs the super to make sure the filesystem is consistent and calls the fs's
952 * freeze_fs. Subsequent calls to this without first thawing the fs will return
955 int freeze_super(struct super_block *sb)
959 atomic_inc(&sb->s_active);
960 down_write(&sb->s_umount);
962 deactivate_locked_super(sb);
966 if (sb->s_flags & MS_RDONLY) {
967 sb->s_frozen = SB_FREEZE_TRANS;
969 up_write(&sb->s_umount);
973 sb->s_frozen = SB_FREEZE_WRITE;
978 sb->s_frozen = SB_FREEZE_TRANS;
981 sync_blockdev(sb->s_bdev);
982 if (sb->s_op->freeze_fs) {
983 ret = sb->s_op->freeze_fs(sb);
986 "VFS:Filesystem freeze failed\n");
987 sb->s_frozen = SB_UNFROZEN;
988 deactivate_locked_super(sb);
992 up_write(&sb->s_umount);
995 EXPORT_SYMBOL(freeze_super);
998 * thaw_super -- unlock filesystem
999 * @sb: the super to thaw
1001 * Unlocks the filesystem and marks it writeable again after freeze_super().
1003 int thaw_super(struct super_block *sb)
1007 down_write(&sb->s_umount);
1008 if (sb->s_frozen == SB_UNFROZEN) {
1009 up_write(&sb->s_umount);
1013 if (sb->s_flags & MS_RDONLY)
1016 if (sb->s_op->unfreeze_fs) {
1017 error = sb->s_op->unfreeze_fs(sb);
1020 "VFS:Filesystem thaw failed\n");
1021 sb->s_frozen = SB_FREEZE_TRANS;
1022 up_write(&sb->s_umount);
1028 sb->s_frozen = SB_UNFROZEN;
1030 wake_up(&sb->s_wait_unfrozen);
1031 deactivate_locked_super(sb);
1035 EXPORT_SYMBOL(thaw_super);
1037 static struct vfsmount *fs_set_subtype(struct vfsmount *mnt, const char *fstype)
1040 const char *subtype = strchr(fstype, '.');
1049 mnt->mnt_sb->s_subtype = kstrdup(subtype, GFP_KERNEL);
1051 if (!mnt->mnt_sb->s_subtype)
1057 return ERR_PTR(err);
1061 do_kern_mount(const char *fstype, int flags, const char *name, void *data)
1063 struct file_system_type *type = get_fs_type(fstype);
1064 struct vfsmount *mnt;
1066 return ERR_PTR(-ENODEV);
1067 mnt = vfs_kern_mount(type, flags, name, data);
1068 if (!IS_ERR(mnt) && (type->fs_flags & FS_HAS_SUBTYPE) &&
1069 !mnt->mnt_sb->s_subtype)
1070 mnt = fs_set_subtype(mnt, fstype);
1071 put_filesystem(type);
1074 EXPORT_SYMBOL_GPL(do_kern_mount);
1076 struct vfsmount *kern_mount_data(struct file_system_type *type, void *data)
1078 return vfs_kern_mount(type, MS_KERNMOUNT, type->name, data);
1081 EXPORT_SYMBOL_GPL(kern_mount_data);