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 * Added options to /proc/mounts
14 * Torbjörn Lindh (torbjorn.lindh@gopta.se), April 14, 1996.
16 * GK 2/5/95 - Changed to support mounting the root fs via NFS
18 * Added kerneld support: Jacques Gelinas and Bjorn Ekwall
19 * Added change_root: Werner Almesberger & Hans Lermen, Feb '96
20 * Added devfs support: Richard Gooch <rgooch@atnf.csiro.au>, 13-JAN-1998
21 * Heavily rewritten for 'one fs - one tree' dcache architecture. AV, Mar 2000
24 #include <linux/config.h>
25 #include <linux/string.h>
26 #include <linux/malloc.h>
27 #include <linux/locks.h>
28 #include <linux/smp_lock.h>
29 #include <linux/devfs_fs_kernel.h>
31 #include <linux/init.h>
32 #include <linux/quotaops.h>
33 #include <linux/acct.h>
35 #include <asm/uaccess.h>
37 #include <linux/nfs_fs.h>
38 #include <linux/nfs_fs_sb.h>
39 #include <linux/nfs_mount.h>
41 #include <linux/kmod.h>
42 #define __NO_VERSION__
43 #include <linux/module.h>
46 * We use a semaphore to synchronize all mount/umount
47 * activity - imagine the mess if we have a race between
48 * unmounting a filesystem and re-mounting it (or something
51 static DECLARE_MUTEX(mount_sem
);
53 extern void wait_for_keypress(void);
55 extern int root_mountflags
;
57 static int do_remount_sb(struct super_block
*sb
, int flags
, char * data
);
59 /* this is initialized in init/main.c */
63 int max_super_blocks
= NR_SUPER
;
64 LIST_HEAD(super_blocks
);
67 * Handling of filesystem drivers list.
69 * Inclusion to/removals from/scanning of list are protected by spinlock.
70 * During the unload module must call unregister_filesystem().
71 * We can access the fields of list element if:
72 * 1) spinlock is held or
73 * 2) we hold the reference to the module.
74 * The latter can be guaranteed by call of try_inc_mod_count(); if it
75 * returned 0 we must skip the element, otherwise we got the reference.
76 * Once the reference is obtained we can drop the spinlock.
79 static struct file_system_type
*file_systems
;
80 static rwlock_t file_systems_lock
= RW_LOCK_UNLOCKED
;
82 /* WARNING: This can be used only if we _already_ own a reference */
83 static void get_filesystem(struct file_system_type
*fs
)
86 __MOD_INC_USE_COUNT(fs
->owner
);
89 static void put_filesystem(struct file_system_type
*fs
)
92 __MOD_DEC_USE_COUNT(fs
->owner
);
95 static struct file_system_type
**find_filesystem(const char *name
)
97 struct file_system_type
**p
;
98 for (p
=&file_systems
; *p
; p
=&(*p
)->next
)
99 if (strcmp((*p
)->name
,name
) == 0)
105 * register_filesystem - register a new filesystem
106 * @fs: the file system structure
108 * Adds the file system passed to the list of file systems the kernel
109 * is aware of for mount and other syscalls. Returns 0 on success,
110 * or a negative errno code on an error.
112 * The &struct file_system_type that is passed is linked into the kernel
113 * structures and must not be freed until the file system has been
117 int register_filesystem(struct file_system_type
* fs
)
120 struct file_system_type
** p
;
126 write_lock(&file_systems_lock
);
127 p
= find_filesystem(fs
->name
);
132 write_unlock(&file_systems_lock
);
137 * unregister_filesystem - unregister a file system
138 * @fs: filesystem to unregister
140 * Remove a file system that was previously successfully registered
141 * with the kernel. An error is returned if the file system is not found.
142 * Zero is returned on a success.
144 * Once this function has returned the &struct file_system_type structure
145 * may be freed or reused.
148 int unregister_filesystem(struct file_system_type
* fs
)
150 struct file_system_type
** tmp
;
152 write_lock(&file_systems_lock
);
158 write_unlock(&file_systems_lock
);
163 write_unlock(&file_systems_lock
);
167 static int fs_index(const char * __name
)
169 struct file_system_type
* tmp
;
173 name
= getname(__name
);
179 read_lock(&file_systems_lock
);
180 for (tmp
=file_systems
, index
=0 ; tmp
; tmp
=tmp
->next
, index
++) {
181 if (strcmp(tmp
->name
,name
) == 0) {
186 read_unlock(&file_systems_lock
);
191 static int fs_name(unsigned int index
, char * buf
)
193 struct file_system_type
* tmp
;
196 read_lock(&file_systems_lock
);
197 for (tmp
= file_systems
; tmp
; tmp
= tmp
->next
, index
--)
198 if (index
<= 0 && try_inc_mod_count(tmp
->owner
))
200 read_unlock(&file_systems_lock
);
204 /* OK, we got the reference, so we can safely block */
205 len
= strlen(tmp
->name
) + 1;
206 res
= copy_to_user(buf
, tmp
->name
, len
) ? -EFAULT
: 0;
211 static int fs_maxindex(void)
213 struct file_system_type
* tmp
;
216 read_lock(&file_systems_lock
);
217 for (tmp
= file_systems
, index
= 0 ; tmp
; tmp
= tmp
->next
, index
++)
219 read_unlock(&file_systems_lock
);
224 * Whee.. Weird sysv syscall.
226 asmlinkage
long sys_sysfs(int option
, unsigned long arg1
, unsigned long arg2
)
228 int retval
= -EINVAL
;
232 retval
= fs_index((const char *) arg1
);
236 retval
= fs_name(arg1
, (char *) arg2
);
240 retval
= fs_maxindex();
246 int get_filesystem_list(char * buf
)
249 struct file_system_type
* tmp
;
251 read_lock(&file_systems_lock
);
253 while (tmp
&& len
< PAGE_SIZE
- 80) {
254 len
+= sprintf(buf
+len
, "%s\t%s\n",
255 (tmp
->fs_flags
& FS_REQUIRES_DEV
) ? "" : "nodev",
259 read_unlock(&file_systems_lock
);
263 struct file_system_type
*get_fs_type(const char *name
)
265 struct file_system_type
*fs
;
267 read_lock(&file_systems_lock
);
268 fs
= *(find_filesystem(name
));
269 if (fs
&& !try_inc_mod_count(fs
->owner
))
271 read_unlock(&file_systems_lock
);
272 if (!fs
&& (request_module(name
) == 0)) {
273 read_lock(&file_systems_lock
);
274 fs
= *(find_filesystem(name
));
275 if (fs
&& !try_inc_mod_count(fs
->owner
))
277 read_unlock(&file_systems_lock
);
282 static LIST_HEAD(vfsmntlist
);
285 * add_vfsmnt - add a new mount node
286 * @nd: location of mountpoint or %NULL if we want a root node
287 * @root: root of (sub)tree to be mounted
288 * @dev_name: device name to show in /proc/mounts or %NULL (for "none").
290 * This is VFS idea of mount. New node is allocated, bound to a tree
291 * we are mounting and optionally (OK, usually) registered as mounted
292 * on a given mountpoint. Returns a pointer to new node or %NULL in
295 * Potential reason for failure (aside of trivial lack of memory) is a
296 * deleted mountpoint. Caller must hold ->i_zombie on mountpoint
299 * Node is marked as MNT_VISIBLE (visible in /proc/mounts) unless both
300 * @nd and @devname are %NULL. It works since we pass non-%NULL @devname
301 * when we are mounting root and kern_mount() filesystems are deviceless.
302 * If we will get a kern_mount() filesystem with nontrivial @devname we
303 * will have to pass the visibility flag explicitly, so if we will add
304 * support for such beasts we'll have to change prototype.
307 static struct vfsmount
*add_vfsmnt(struct nameidata
*nd
,
309 const char *dev_name
)
311 struct vfsmount
*mnt
;
312 struct super_block
*sb
= root
->d_inode
->i_sb
;
315 mnt
= kmalloc(sizeof(struct vfsmount
), GFP_KERNEL
);
318 memset(mnt
, 0, sizeof(struct vfsmount
));
321 mnt
->mnt_flags
= MNT_VISIBLE
;
323 /* It may be NULL, but who cares? */
325 name
= kmalloc(strlen(dev_name
)+1, GFP_KERNEL
);
327 strcpy(name
, dev_name
);
328 mnt
->mnt_devname
= name
;
331 mnt
->mnt_owner
= current
->uid
;
332 atomic_set(&mnt
->mnt_count
,1);
335 spin_lock(&dcache_lock
);
336 if (nd
&& !IS_ROOT(nd
->dentry
) && d_unhashed(nd
->dentry
))
338 mnt
->mnt_root
= dget(root
);
339 mnt
->mnt_mountpoint
= nd
? dget(nd
->dentry
) : dget(root
);
340 mnt
->mnt_parent
= nd
? mntget(nd
->mnt
) : mnt
;
343 list_add(&mnt
->mnt_child
, &nd
->mnt
->mnt_mounts
);
344 list_add(&mnt
->mnt_clash
, &nd
->dentry
->d_vfsmnt
);
346 INIT_LIST_HEAD(&mnt
->mnt_child
);
347 INIT_LIST_HEAD(&mnt
->mnt_clash
);
349 INIT_LIST_HEAD(&mnt
->mnt_mounts
);
350 list_add(&mnt
->mnt_instances
, &sb
->s_mounts
);
351 list_add(&mnt
->mnt_list
, vfsmntlist
.prev
);
352 spin_unlock(&dcache_lock
);
356 spin_unlock(&dcache_lock
);
357 if (mnt
->mnt_devname
)
358 kfree(mnt
->mnt_devname
);
363 static void move_vfsmnt(struct vfsmount
*mnt
,
364 struct dentry
*mountpoint
,
365 struct vfsmount
*parent
,
366 const char *dev_name
)
368 struct dentry
*old_mountpoint
;
369 struct vfsmount
*old_parent
;
370 char *new_devname
= NULL
;
373 new_devname
= kmalloc(strlen(dev_name
)+1, GFP_KERNEL
);
375 strcpy(new_devname
, dev_name
);
378 spin_lock(&dcache_lock
);
379 old_mountpoint
= mnt
->mnt_mountpoint
;
380 old_parent
= mnt
->mnt_parent
;
384 if (mnt
->mnt_devname
)
385 kfree(mnt
->mnt_devname
);
386 mnt
->mnt_devname
= new_devname
;
389 /* flip the linkage */
390 mnt
->mnt_mountpoint
= dget(mountpoint
);
391 mnt
->mnt_parent
= parent
? mntget(parent
) : mnt
;
392 list_del(&mnt
->mnt_clash
);
393 list_del(&mnt
->mnt_child
);
395 list_add(&mnt
->mnt_child
, &parent
->mnt_mounts
);
396 list_add(&mnt
->mnt_clash
, &mountpoint
->d_vfsmnt
);
398 INIT_LIST_HEAD(&mnt
->mnt_child
);
399 INIT_LIST_HEAD(&mnt
->mnt_clash
);
401 spin_unlock(&dcache_lock
);
403 /* put the old stuff */
404 dput(old_mountpoint
);
405 if (old_parent
!= mnt
)
410 * Called with spinlock held, releases it.
412 static void remove_vfsmnt(struct vfsmount
*mnt
)
414 /* First of all, remove it from all lists */
415 list_del(&mnt
->mnt_instances
);
416 list_del(&mnt
->mnt_clash
);
417 list_del(&mnt
->mnt_list
);
418 list_del(&mnt
->mnt_child
);
419 spin_unlock(&dcache_lock
);
420 /* Now we can work safely */
421 if (mnt
->mnt_parent
!= mnt
)
422 mntput(mnt
->mnt_parent
);
424 dput(mnt
->mnt_mountpoint
);
426 if (mnt
->mnt_devname
)
427 kfree(mnt
->mnt_devname
);
431 static struct proc_fs_info
{
435 { MS_NOEXEC
, ",noexec" },
436 { MS_NOSUID
, ",nosuid" },
437 { MS_NODEV
, ",nodev" },
438 { MS_SYNCHRONOUS
, ",sync" },
439 { MS_MANDLOCK
, ",mand" },
440 { MS_NOATIME
, ",noatime" },
441 { MS_NODIRATIME
, ",nodiratime" },
442 #ifdef MS_NOSUB /* Can't find this except in mount.c */
443 { MS_NOSUB
, ",nosub" },
448 static struct proc_nfs_info
{
453 { NFS_MOUNT_SOFT
, ",soft", ",hard" },
454 { NFS_MOUNT_INTR
, ",intr", "" },
455 { NFS_MOUNT_POSIX
, ",posix", "" },
456 { NFS_MOUNT_TCP
, ",tcp", ",udp" },
457 { NFS_MOUNT_NOCTO
, ",nocto", "" },
458 { NFS_MOUNT_NOAC
, ",noac", "" },
459 { NFS_MOUNT_NONLM
, ",nolock", ",lock" },
463 int get_filesystem_info( char *buf
)
466 struct proc_fs_info
*fs_infop
;
467 struct proc_nfs_info
*nfs_infop
;
468 struct nfs_server
*nfss
;
470 char *path
,*buffer
= (char *) __get_free_page(GFP_KERNEL
);
472 if (!buffer
) return 0;
473 for (p
= vfsmntlist
.next
; p
!=&vfsmntlist
&& len
< PAGE_SIZE
- 160;
475 struct vfsmount
*tmp
= list_entry(p
, struct vfsmount
, mnt_list
);
476 if (!(tmp
->mnt_flags
& MNT_VISIBLE
))
478 path
= d_path(tmp
->mnt_root
, tmp
, buffer
, PAGE_SIZE
);
481 len
+= sprintf( buf
+ len
, "%s %s %s %s",
482 tmp
->mnt_devname
? tmp
->mnt_devname
: "none", path
,
483 tmp
->mnt_sb
->s_type
->name
,
484 tmp
->mnt_sb
->s_flags
& MS_RDONLY
? "ro" : "rw" );
485 for (fs_infop
= fs_info
; fs_infop
->flag
; fs_infop
++) {
486 if (tmp
->mnt_sb
->s_flags
& fs_infop
->flag
) {
487 strcpy(buf
+ len
, fs_infop
->str
);
488 len
+= strlen(fs_infop
->str
);
491 if (!strcmp("nfs", tmp
->mnt_sb
->s_type
->name
)) {
492 nfss
= &tmp
->mnt_sb
->u
.nfs_sb
.s_server
;
493 len
+= sprintf(buf
+len
, ",v%d", nfss
->rpc_ops
->version
);
495 len
+= sprintf(buf
+len
, ",rsize=%d", nfss
->rsize
);
497 len
+= sprintf(buf
+len
, ",wsize=%d", nfss
->wsize
);
499 if (nfss
->timeo
!= 7*HZ
/10) {
500 len
+= sprintf(buf
+len
, ",timeo=%d",
503 if (nfss
->retrans
!= 3) {
504 len
+= sprintf(buf
+len
, ",retrans=%d",
508 if (nfss
->acregmin
!= 3*HZ
) {
509 len
+= sprintf(buf
+len
, ",acregmin=%d",
512 if (nfss
->acregmax
!= 60*HZ
) {
513 len
+= sprintf(buf
+len
, ",acregmax=%d",
516 if (nfss
->acdirmin
!= 30*HZ
) {
517 len
+= sprintf(buf
+len
, ",acdirmin=%d",
520 if (nfss
->acdirmax
!= 60*HZ
) {
521 len
+= sprintf(buf
+len
, ",acdirmax=%d",
524 for (nfs_infop
= nfs_info
; nfs_infop
->flag
; nfs_infop
++) {
526 if (nfss
->flags
& nfs_infop
->flag
)
527 str
= nfs_infop
->str
;
529 str
= nfs_infop
->nostr
;
530 strcpy(buf
+ len
, str
);
533 len
+= sprintf(buf
+len
, ",addr=%s",
536 len
+= sprintf( buf
+ len
, " 0 0\n" );
539 free_page((unsigned long) buffer
);
544 * __wait_on_super - wait on a superblock
545 * @sb: superblock to wait on
547 * Waits for a superblock to become unlocked and then returns. It does
548 * not take the lock. This is an internal function. See wait_on_super().
551 void __wait_on_super(struct super_block
* sb
)
553 DECLARE_WAITQUEUE(wait
, current
);
555 add_wait_queue(&sb
->s_wait
, &wait
);
557 set_current_state(TASK_UNINTERRUPTIBLE
);
562 remove_wait_queue(&sb
->s_wait
, &wait
);
563 current
->state
= TASK_RUNNING
;
567 * Note: check the dirty flag before waiting, so we don't
568 * hold up the sync while mounting a device. (The newly
569 * mounted device won't need syncing.)
571 void sync_supers(kdev_t dev
)
573 struct super_block
* sb
;
575 for (sb
= sb_entry(super_blocks
.next
);
576 sb
!= sb_entry(&super_blocks
);
577 sb
= sb_entry(sb
->s_list
.next
)) {
580 if (dev
&& sb
->s_dev
!= dev
)
585 if (sb
->s_dev
&& sb
->s_dirt
&& (!dev
|| dev
== sb
->s_dev
))
586 if (sb
->s_op
&& sb
->s_op
->write_super
)
587 sb
->s_op
->write_super(sb
);
593 * get_super - get the superblock of a device
594 * @dev: device to get the superblock for
596 * Scans the superblock list and finds the superblock of the file system
597 * mounted on the device given. %NULL is returned if no match is found.
600 struct super_block
* get_super(kdev_t dev
)
602 struct super_block
* s
;
607 s
= sb_entry(super_blocks
.next
);
608 while (s
!= sb_entry(&super_blocks
))
609 if (s
->s_dev
== dev
) {
615 s
= sb_entry(s
->s_list
.next
);
619 asmlinkage
long sys_ustat(dev_t dev
, struct ustat
* ubuf
)
621 struct super_block
*s
;
627 s
= get_super(to_kdev_t(dev
));
631 err
= vfs_statfs(s
, &sbuf
);
635 memset(&tmp
,0,sizeof(struct ustat
));
636 tmp
.f_tfree
= sbuf
.f_bfree
;
637 tmp
.f_tinode
= sbuf
.f_ffree
;
639 err
= copy_to_user(ubuf
,&tmp
,sizeof(struct ustat
)) ? -EFAULT
: 0;
645 * get_empty_super - find empty superblocks
647 * Find a superblock with no device assigned. A free superblock is
648 * found and returned. If neccessary new superblocks are allocated.
649 * %NULL is returned if there are insufficient resources to complete
653 struct super_block
*get_empty_super(void)
655 struct super_block
*s
;
657 for (s
= sb_entry(super_blocks
.next
);
658 s
!= sb_entry(&super_blocks
);
659 s
= sb_entry(s
->s_list
.next
)) {
664 printk("VFS: empty superblock %p locked!\n", s
);
666 /* Need a new one... */
667 if (nr_super_blocks
>= max_super_blocks
)
669 s
= kmalloc(sizeof(struct super_block
), GFP_USER
);
672 memset(s
, 0, sizeof(struct super_block
));
673 INIT_LIST_HEAD(&s
->s_dirty
);
674 list_add (&s
->s_list
, super_blocks
.prev
);
675 init_waitqueue_head(&s
->s_wait
);
676 INIT_LIST_HEAD(&s
->s_files
);
677 INIT_LIST_HEAD(&s
->s_mounts
);
682 static struct super_block
* read_super(kdev_t dev
, struct block_device
*bdev
,
683 struct file_system_type
*type
, int flags
,
684 void *data
, int silent
)
686 struct super_block
* s
;
687 s
= get_empty_super();
694 sema_init(&s
->s_vfs_rename_sem
,1);
695 sema_init(&s
->s_nfsd_free_path_sem
,1);
697 sema_init(&s
->s_dquot
.dqio_sem
, 1);
698 sema_init(&s
->s_dquot
.dqoff_sem
, 1);
699 s
->s_dquot
.flags
= 0;
701 if (!type
->read_super(s
, data
, silent
))
704 /* tell bdcache that we are going to keep this one */
706 atomic_inc(&bdev
->bd_count
);
719 * Unnamed block devices are dummy devices used by virtual
720 * filesystems which don't use real block-devices. -- jrs
723 static unsigned int unnamed_dev_in_use
[256/(8*sizeof(unsigned int))];
725 kdev_t
get_unnamed_dev(void)
729 for (i
= 1; i
< 256; i
++) {
730 if (!test_and_set_bit(i
,unnamed_dev_in_use
))
731 return MKDEV(UNNAMED_MAJOR
, i
);
736 void put_unnamed_dev(kdev_t dev
)
738 if (!dev
|| MAJOR(dev
) != UNNAMED_MAJOR
)
740 if (test_and_clear_bit(MINOR(dev
), unnamed_dev_in_use
))
742 printk("VFS: put_unnamed_dev: freeing unused device %s\n",
746 static struct super_block
*get_sb_bdev(struct file_system_type
*fs_type
,
747 char *dev_name
, int flags
, void * data
)
750 struct block_device
*bdev
;
751 struct block_device_operations
*bdops
;
752 struct super_block
* sb
;
756 /* What device it is? */
757 if (!dev_name
|| !*dev_name
)
758 return ERR_PTR(-EINVAL
);
759 if (path_init(dev_name
, LOOKUP_FOLLOW
|LOOKUP_POSITIVE
, &nd
))
760 error
= path_walk(dev_name
, &nd
);
762 return ERR_PTR(error
);
763 inode
= nd
.dentry
->d_inode
;
765 if (!S_ISBLK(inode
->i_mode
))
770 bdev
= inode
->i_bdev
;
771 bdops
= devfs_get_ops ( devfs_get_handle_from_inode (inode
) );
772 if (bdops
) bdev
->bd_op
= bdops
;
773 /* Done with lookups, semaphore down */
775 dev
= to_kdev_t(bdev
->bd_dev
);
778 if (fs_type
== sb
->s_type
) {
783 mode_t mode
= FMODE_READ
; /* we always need it ;-) */
784 if (!(flags
& MS_RDONLY
))
786 error
= blkdev_get(bdev
, mode
, 0, BDEV_FS
);
789 check_disk_change(dev
);
791 if (!(flags
& MS_RDONLY
) && is_read_only(dev
))
794 sb
= read_super(dev
, bdev
, fs_type
, flags
, data
, 0);
796 get_filesystem(fs_type
);
801 blkdev_put(bdev
, BDEV_FS
);
806 return ERR_PTR(error
);
809 static struct super_block
*get_sb_nodev(struct file_system_type
*fs_type
,
810 int flags
, void * data
)
815 dev
= get_unnamed_dev();
817 struct super_block
* sb
;
819 sb
= read_super(dev
, NULL
, fs_type
, flags
, data
, 0);
821 get_filesystem(fs_type
);
824 put_unnamed_dev(dev
);
827 return ERR_PTR(error
);
830 static struct super_block
*get_sb_single(struct file_system_type
*fs_type
,
831 int flags
, void *data
)
833 struct super_block
* sb
;
835 * Get the superblock of kernel-wide instance, but
836 * keep the reference to fs_type.
839 sb
= fs_type
->kern_mnt
->mnt_sb
;
842 get_filesystem(fs_type
);
843 do_remount_sb(sb
, flags
, data
);
847 static struct block_device
*kill_super(struct super_block
*sb
, int umount_root
)
849 struct block_device
*bdev
;
851 struct dentry
*root
= sb
->s_root
;
853 /* Need to clean after the sucker */
854 if (sb
->s_type
->fs_flags
& FS_LITTER
)
856 if (sb
->s_type
->fs_flags
& (FS_SINGLE
|FS_LITTER
))
857 shrink_dcache_parent(root
);
861 if (sb
->s_op
->write_super
&& sb
->s_dirt
)
862 sb
->s_op
->write_super(sb
);
863 if (sb
->s_op
->put_super
)
864 sb
->s_op
->put_super(sb
);
867 /* Forget any remaining inodes */
868 if (invalidate_inodes(sb
)) {
869 printk("VFS: Busy inodes after unmount. "
870 "Self-destruct in 5 seconds. Have a nice day...\n");
874 sb
->s_dev
= 0; /* Free the superblock */
877 put_filesystem(sb
->s_type
);
881 /* special: the old device driver is going to be
882 a ramdisk and the point of this call is to free its
883 protected memory (even if dirty). */
884 destroy_buffers(dev
);
887 blkdev_put(bdev
, BDEV_FS
);
890 put_unnamed_dev(dev
);
895 * Alters the mount flags of a mounted file system. Only the mount point
896 * is used as a reference - file system type and the device are ignored.
899 static int do_remount_sb(struct super_block
*sb
, int flags
, char *data
)
903 if (!(flags
& MS_RDONLY
) && sb
->s_dev
&& is_read_only(sb
->s_dev
))
905 /*flags |= MS_RDONLY;*/
906 /* If we are remounting RDONLY, make sure there are no rw files open */
907 if ((flags
& MS_RDONLY
) && !(sb
->s_flags
& MS_RDONLY
))
908 if (!fs_may_remount_ro(sb
))
910 if (sb
->s_op
&& sb
->s_op
->remount_fs
) {
912 retval
= sb
->s_op
->remount_fs(sb
, &flags
, data
);
917 sb
->s_flags
= (sb
->s_flags
& ~MS_RMT_MASK
) | (flags
& MS_RMT_MASK
);
920 * We can't invalidate inodes as we can loose data when remounting
921 * (someone might manage to alter data while we are waiting in lock_super()
922 * or in foo_remount_fs()))
928 struct vfsmount
*kern_mount(struct file_system_type
*type
)
930 kdev_t dev
= get_unnamed_dev();
931 struct super_block
*sb
;
932 struct vfsmount
*mnt
;
934 return ERR_PTR(-EMFILE
);
935 sb
= read_super(dev
, NULL
, type
, 0, NULL
, 0);
937 put_unnamed_dev(dev
);
938 return ERR_PTR(-EINVAL
);
940 mnt
= add_vfsmnt(NULL
, sb
->s_root
, NULL
);
943 return ERR_PTR(-ENOMEM
);
945 type
->kern_mnt
= mnt
;
949 /* Call only after unregister_filesystem() - it's a final cleanup */
951 void kern_umount(struct vfsmount
*mnt
)
953 struct super_block
*sb
= mnt
->mnt_sb
;
954 spin_lock(&dcache_lock
);
960 * Doesn't take quota and stuff into account. IOW, in some cases it will
961 * give false negatives. The main reason why it's here is that we need
962 * a non-destructive way to look for easily umountable filesystems.
964 int may_umount(struct vfsmount
*mnt
)
966 if (atomic_read(&mnt
->mnt_count
) > 2)
971 static int do_umount(struct vfsmount
*mnt
, int umount_root
, int flags
)
973 struct super_block
* sb
= mnt
->mnt_sb
;
976 * No sense to grab the lock for this test, but test itself looks
977 * somewhat bogus. Suggestions for better replacement?
978 * Ho-hum... In principle, we might treat that as umount + switch
979 * to rootfs. GC would eventually take care of the old vfsmount.
980 * The problem being: we have to implement rootfs and GC for that ;-)
981 * Actually it makes sense, especially if rootfs would contain a
982 * /reboot - static binary that would close all descriptors and
983 * call reboot(9). Then init(8) could umount root and exec /reboot.
985 if (mnt
== current
->fs
->rootmnt
&& !umount_root
) {
988 * Special case for "unmounting" root ...
989 * we just try to remount it readonly.
992 if (!(sb
->s_flags
& MS_RDONLY
))
993 retval
= do_remount_sb(sb
, MS_RDONLY
, 0);
997 spin_lock(&dcache_lock
);
998 if (atomic_read(&mnt
->mnt_count
) > 2) {
999 spin_unlock(&dcache_lock
);
1004 if (mnt
->mnt_instances
.next
!= mnt
->mnt_instances
.prev
) {
1005 if (sb
->s_type
->fs_flags
& FS_SINGLE
)
1006 put_filesystem(sb
->s_type
);
1007 /* We hold two references, so mntput() is safe */
1012 spin_unlock(&dcache_lock
);
1015 * Before checking whether the filesystem is still busy,
1016 * make sure the kernel doesn't hold any quota files open
1017 * on the device. If the umount fails, too bad -- there
1018 * are no quotas running any more. Just turn them on again.
1021 acct_auto_close(sb
->s_dev
);
1024 * If we may have to abort operations to get out of this
1025 * mount, and they will themselves hold resources we must
1026 * allow the fs to do things. In the Unix tradition of
1027 * 'Gee thats tricky lets do it in userspace' the umount_begin
1028 * might fail to complete on the first run through as other tasks
1029 * must return, and the like. Thats for the mount program to worry
1030 * about for the moment.
1033 if( (flags
&MNT_FORCE
) && sb
->s_op
->umount_begin
)
1034 sb
->s_op
->umount_begin(sb
);
1037 * Shrink dcache, then fsync. This guarantees that if the
1038 * filesystem is quiescent at this point, then (a) only the
1039 * root entry should be in use and (b) that root entry is
1042 shrink_dcache_sb(sb
);
1043 fsync_dev(sb
->s_dev
);
1045 if (sb
->s_root
->d_inode
->i_state
) {
1050 /* Something might grab it again - redo checks */
1052 spin_lock(&dcache_lock
);
1053 if (atomic_read(&mnt
->mnt_count
) > 2) {
1054 spin_unlock(&dcache_lock
);
1059 /* OK, that's the point of no return */
1063 kill_super(sb
, umount_root
);
1068 * Now umount can handle mount points as well as block devices.
1069 * This is important for filesystems which use unnamed block devices.
1071 * We now support a flag for forced unmount like the other 'big iron'
1072 * unixes. Our API is identical to OSF/1 to avoid making a mess of AMD
1075 asmlinkage
long sys_umount(char * name
, int flags
)
1077 struct nameidata nd
;
1082 kname
= getname(name
);
1083 retval
= PTR_ERR(kname
);
1087 if (path_init(kname
, LOOKUP_POSITIVE
|LOOKUP_FOLLOW
, &nd
))
1088 retval
= path_walk(kname
, &nd
);
1093 if (nd
.dentry
!=nd
.mnt
->mnt_root
)
1097 if (!capable(CAP_SYS_ADMIN
) && current
->uid
!=nd
.mnt
->mnt_owner
)
1103 retval
= do_umount(nd
.mnt
, 0, flags
);
1114 * The 2.0 compatible umount. No flags.
1117 asmlinkage
long sys_oldumount(char * name
)
1119 return sys_umount(name
,0);
1122 static int mount_is_safe(struct nameidata
*nd
)
1124 if (capable(CAP_SYS_ADMIN
))
1128 if (S_ISLNK(nd
->dentry
->d_inode
->i_mode
))
1130 if (nd
->dentry
->d_inode
->i_mode
& S_ISVTX
) {
1131 if (current
->uid
!= nd
->dentry
->d_inode
->i_uid
)
1134 if (permission(nd
->dentry
->d_inode
, MAY_WRITE
))
1141 * do loopback mount.
1143 static int do_loopback(char *old_name
, char *new_name
)
1145 struct nameidata old_nd
, new_nd
;
1147 if (!old_name
|| !*old_name
)
1149 if (path_init(old_name
, LOOKUP_POSITIVE
, &old_nd
))
1150 err
= path_walk(old_name
, &old_nd
);
1153 if (path_init(new_name
, LOOKUP_POSITIVE
, &new_nd
))
1154 err
= path_walk(new_name
, &new_nd
);
1157 err
= mount_is_safe(&new_nd
);
1161 if (S_ISDIR(new_nd
.dentry
->d_inode
->i_mode
) !=
1162 S_ISDIR(old_nd
.dentry
->d_inode
->i_mode
))
1166 if (old_nd
.mnt
->mnt_sb
->s_type
->fs_flags
& FS_SINGLE
)
1167 get_filesystem(old_nd
.mnt
->mnt_sb
->s_type
);
1171 down(&new_nd
.dentry
->d_inode
->i_zombie
);
1172 if (IS_DEADDIR(new_nd
.dentry
->d_inode
))
1174 else if (add_vfsmnt(&new_nd
, old_nd
.dentry
, old_nd
.mnt
->mnt_devname
))
1176 up(&new_nd
.dentry
->d_inode
->i_zombie
);
1178 if (err
&& old_nd
.mnt
->mnt_sb
->s_type
->fs_flags
& FS_SINGLE
)
1179 put_filesystem(old_nd
.mnt
->mnt_sb
->s_type
);
1181 path_release(&new_nd
);
1183 path_release(&old_nd
);
1189 * change filesystem flags. dir should be a physical root of filesystem.
1190 * If you've mounted a non-root directory somewhere and want to do remount
1191 * on it - tough luck.
1194 static int do_remount(const char *dir
,int flags
,char *data
)
1196 struct nameidata nd
;
1199 if (!capable(CAP_SYS_ADMIN
))
1202 if (path_init(dir
, LOOKUP_FOLLOW
|LOOKUP_POSITIVE
, &nd
))
1203 retval
= path_walk(dir
, &nd
);
1205 struct super_block
* sb
= nd
.dentry
->d_inode
->i_sb
;
1209 if (nd
.dentry
== sb
->s_root
) {
1211 * Shrink the dcache and sync the device.
1213 shrink_dcache_sb(sb
);
1214 fsync_dev(sb
->s_dev
);
1215 if (flags
& MS_RDONLY
)
1216 acct_auto_close(sb
->s_dev
);
1217 retval
= do_remount_sb(sb
, flags
, data
);
1225 static int copy_mount_options (const void *data
, unsigned long *where
)
1235 if (!(page
= __get_free_page(GFP_KERNEL
)))
1238 /* We only care that *some* data at the address the user
1239 * gave us is valid. Just in case, we'll zero
1240 * the remainder of the page.
1242 /* copy_from_user cannot cross TASK_SIZE ! */
1243 size
= TASK_SIZE
- (unsigned long)data
;
1244 if (size
> PAGE_SIZE
)
1247 i
= size
- copy_from_user((void *)page
, data
, size
);
1253 memset((char *)page
+ i
, 0, PAGE_SIZE
- i
);
1259 * Flags is a 16-bit value that allows up to 16 non-fs dependent flags to
1260 * be given to the mount() call (ie: read-only, no-dev, no-suid etc).
1262 * data is a (void *) that can point to any structure up to
1263 * PAGE_SIZE-1 bytes, which can contain arbitrary fs-dependent
1264 * information (or be NULL).
1266 * NOTE! As old versions of mount() didn't use this setup, the flags
1267 * have to have a special 16-bit magic number in the high word:
1268 * 0xC0ED. If this magic word isn't present, the flags and data info
1269 * aren't used, as the syscall assumes we are talking to an older
1270 * version that didn't understand them.
1272 long do_mount(char * dev_name
, char * dir_name
, char *type_page
,
1273 unsigned long new_flags
, void *data_page
)
1275 struct file_system_type
* fstype
;
1276 struct nameidata nd
;
1277 struct vfsmount
*mnt
= NULL
;
1278 struct super_block
*sb
;
1280 unsigned long flags
= 0;
1282 /* Basic sanity checks */
1284 if (!dir_name
|| !*dir_name
|| !memchr(dir_name
, 0, PAGE_SIZE
))
1286 if (dev_name
&& !memchr(dev_name
, 0, PAGE_SIZE
))
1289 /* OK, looks good, now let's see what do they want */
1291 /* just change the flags? - capabilities are checked in do_remount() */
1292 if ((new_flags
& (MS_MGC_MSK
|MS_REMOUNT
)) == (MS_MGC_VAL
|MS_REMOUNT
))
1293 return do_remount(dir_name
, new_flags
&~(MS_MGC_MSK
|MS_REMOUNT
),
1294 (char *) data_page
);
1296 if ((new_flags
& MS_MGC_MSK
) == MS_MGC_VAL
)
1297 flags
= new_flags
& ~MS_MGC_MSK
;
1299 /* For the rest we need the type */
1301 if (!type_page
|| !memchr(type_page
, 0, PAGE_SIZE
))
1304 /* loopback mount? This is special - requires fewer capabilities */
1305 if (strcmp(type_page
, "bind")==0)
1306 return do_loopback(dev_name
, dir_name
);
1308 /* for the rest we _really_ need capabilities... */
1309 if (!capable(CAP_SYS_ADMIN
))
1312 /* ... filesystem driver... */
1313 fstype
= get_fs_type(type_page
);
1317 /* ... and mountpoint. Do the lookup first to force automounting. */
1318 if (path_init(dir_name
, LOOKUP_FOLLOW
|LOOKUP_POSITIVE
|LOOKUP_DIRECTORY
, &nd
))
1319 retval
= path_walk(dir_name
, &nd
);
1323 /* get superblock, locks mount_sem on success */
1324 if (fstype
->fs_flags
& FS_NOMOUNT
)
1325 sb
= ERR_PTR(-EINVAL
);
1326 else if (fstype
->fs_flags
& FS_REQUIRES_DEV
)
1327 sb
= get_sb_bdev(fstype
, dev_name
,flags
, data_page
);
1328 else if (fstype
->fs_flags
& FS_SINGLE
)
1329 sb
= get_sb_single(fstype
, flags
, data_page
);
1331 sb
= get_sb_nodev(fstype
, flags
, data_page
);
1333 retval
= PTR_ERR(sb
);
1337 /* Something was mounted here while we slept */
1338 while(d_mountpoint(nd
.dentry
) && follow_down(&nd
.mnt
, &nd
.dentry
))
1341 if (!nd
.dentry
->d_inode
)
1343 down(&nd
.dentry
->d_inode
->i_zombie
);
1344 if (!IS_DEADDIR(nd
.dentry
->d_inode
)) {
1346 mnt
= add_vfsmnt(&nd
, sb
->s_root
, dev_name
);
1348 up(&nd
.dentry
->d_inode
->i_zombie
);
1357 put_filesystem(fstype
);
1361 if (list_empty(&sb
->s_mounts
))
1366 asmlinkage
long sys_mount(char * dev_name
, char * dir_name
, char * type
,
1367 unsigned long new_flags
, void * data
)
1370 unsigned long data_page
;
1371 unsigned long type_page
;
1372 unsigned long dev_page
;
1375 retval
= copy_mount_options (type
, &type_page
);
1379 dir_page
= getname(dir_name
);
1380 retval
= PTR_ERR(dir_page
);
1381 if (IS_ERR(dir_page
))
1384 retval
= copy_mount_options (dev_name
, &dev_page
);
1387 retval
= copy_mount_options (data
, &data_page
);
1390 retval
= do_mount((char*)dev_page
,dir_page
,(char*)type_page
,
1391 new_flags
, (void*)data_page
);
1393 free_page(data_page
);
1395 free_page(dev_page
);
1399 free_page(type_page
);
1403 void __init
mount_root(void)
1405 struct file_system_type
* fs_type
;
1406 struct super_block
* sb
;
1407 struct vfsmount
*vfsmnt
;
1408 struct block_device
*bdev
= NULL
;
1413 int path_start
= -1;
1415 #ifdef CONFIG_ROOT_NFS
1417 if (MAJOR(ROOT_DEV
) != UNNAMED_MAJOR
)
1419 fs_type
= get_fs_type("nfs");
1422 ROOT_DEV
= get_unnamed_dev();
1425 * Your /linuxrc sucks worse than MSExchange - that's the
1426 * only way you could run out of anon devices at that point.
1429 data
= nfs_root_data();
1432 sb
= read_super(ROOT_DEV
, NULL
, fs_type
, root_mountflags
, data
, 1);
1435 * We _can_ fail there, but if that will happen we have no
1436 * chance anyway (no memory for vfsmnt and we _will_ need it,
1437 * no matter which fs we try to mount).
1441 put_unnamed_dev(ROOT_DEV
);
1443 put_filesystem(fs_type
);
1445 printk(KERN_ERR
"VFS: Unable to mount root fs via NFS, trying floppy.\n");
1446 ROOT_DEV
= MKDEV(FLOPPY_MAJOR
, 0);
1450 #ifdef CONFIG_BLK_DEV_FD
1451 if (MAJOR(ROOT_DEV
) == FLOPPY_MAJOR
) {
1452 #ifdef CONFIG_BLK_DEV_RAM
1453 extern int rd_doload
;
1454 extern void rd_load_secondary(void);
1457 #ifndef CONFIG_BLK_DEV_RAM
1458 printk(KERN_NOTICE
"(Warning, this kernel has no ramdisk support)\n");
1460 /* rd_doload is 2 for a dual initrd/ramload setup */
1462 rd_load_secondary();
1466 printk(KERN_NOTICE
"VFS: Insert root floppy and press ENTER\n");
1467 wait_for_keypress();
1472 devfs_make_root (root_device_name
);
1473 handle
= devfs_find_handle (NULL
, ROOT_DEVICE_NAME
,
1474 MAJOR (ROOT_DEV
), MINOR (ROOT_DEV
),
1475 DEVFS_SPECIAL_BLK
, 1);
1476 if (handle
) /* Sigh: bd*() functions only paper over the cracks */
1478 unsigned major
, minor
;
1480 devfs_get_maj_min (handle
, &major
, &minor
);
1481 ROOT_DEV
= MKDEV (major
, minor
);
1485 * Probably pure paranoia, but I'm less than happy about delving into
1486 * devfs crap and checking it right now. Later.
1489 panic("I have no root and I want to scream");
1491 bdev
= bdget(kdev_t_to_nr(ROOT_DEV
));
1493 panic(__FUNCTION__
": unable to allocate root device");
1494 bdev
->bd_op
= devfs_get_ops (handle
);
1495 path_start
= devfs_generate_path (handle
, path
+ 5, sizeof (path
) - 5);
1497 if (!(root_mountflags
& MS_RDONLY
))
1498 mode
|= FMODE_WRITE
;
1499 retval
= blkdev_get(bdev
, mode
, 0, BDEV_FS
);
1500 if (retval
== -EROFS
) {
1501 root_mountflags
|= MS_RDONLY
;
1502 retval
= blkdev_get(bdev
, FMODE_READ
, 0, BDEV_FS
);
1506 * Allow the user to distinguish between failed open
1507 * and bad superblock on root device.
1509 printk ("VFS: Cannot open root device \"%s\" or %s\n",
1510 root_device_name
, kdevname (ROOT_DEV
));
1511 printk ("Please append a correct \"root=\" boot option\n");
1512 panic("VFS: Unable to mount root fs on %s",
1513 kdevname(ROOT_DEV
));
1516 check_disk_change(ROOT_DEV
);
1517 sb
= get_super(ROOT_DEV
);
1519 fs_type
= sb
->s_type
;
1523 read_lock(&file_systems_lock
);
1524 for (fs_type
= file_systems
; fs_type
; fs_type
= fs_type
->next
) {
1525 if (!(fs_type
->fs_flags
& FS_REQUIRES_DEV
))
1527 if (!try_inc_mod_count(fs_type
->owner
))
1529 read_unlock(&file_systems_lock
);
1530 sb
= read_super(ROOT_DEV
,bdev
,fs_type
,root_mountflags
,NULL
,1);
1533 read_lock(&file_systems_lock
);
1534 put_filesystem(fs_type
);
1536 read_unlock(&file_systems_lock
);
1537 panic("VFS: Unable to mount root fs on %s", kdevname(ROOT_DEV
));
1540 printk ("VFS: Mounted root (%s filesystem)%s.\n",
1542 (sb
->s_flags
& MS_RDONLY
) ? " readonly" : "");
1543 if (path_start
>= 0) {
1544 devfs_mk_symlink (NULL
, "root", DEVFS_FL_DEFAULT
,
1545 path
+ 5 + path_start
, NULL
, NULL
);
1546 memcpy (path
+ path_start
, "/dev/", 5);
1547 vfsmnt
= add_vfsmnt(NULL
, sb
->s_root
, path
+ path_start
);
1550 vfsmnt
= add_vfsmnt(NULL
, sb
->s_root
, "/dev/root");
1551 /* FIXME: if something will try to umount us right now... */
1553 set_fs_root(current
->fs
, vfsmnt
, sb
->s_root
);
1554 set_fs_pwd(current
->fs
, vfsmnt
, sb
->s_root
);
1556 bdput(bdev
); /* sb holds a reference */
1559 panic("VFS: add_vfsmnt failed for root fs");
1563 static void chroot_fs_refs(struct dentry
*old_root
,
1564 struct vfsmount
*old_rootmnt
,
1565 struct dentry
*new_root
,
1566 struct vfsmount
*new_rootmnt
)
1568 struct task_struct
*p
;
1569 struct fs_struct
*fs
;
1571 read_lock(&tasklist_lock
);
1576 atomic_inc(&fs
->count
);
1578 if (fs
->root
==old_root
&& fs
->rootmnt
==old_rootmnt
)
1579 set_fs_root(fs
, new_rootmnt
, new_root
);
1580 if (fs
->pwd
==old_root
&& fs
->pwdmnt
==old_rootmnt
)
1581 set_fs_pwd(fs
, new_rootmnt
, new_root
);
1586 read_unlock(&tasklist_lock
);
1590 * Moves the current root to put_root, and sets root/cwd of all processes
1591 * which had them on the old root to new_root.
1594 * - we don't move root/cwd if they are not at the root (reason: if something
1595 * cared enough to change them, it's probably wrong to force them elsewhere)
1596 * - it's okay to pick a root that isn't the root of a file system, e.g.
1597 * /nfs/my_root where /nfs is the mount point. Better avoid creating
1598 * unreachable mount points this way, though.
1601 asmlinkage
long sys_pivot_root(const char *new_root
, const char *put_old
)
1603 struct dentry
*root
;
1604 struct vfsmount
*root_mnt
;
1605 struct vfsmount
*tmp
;
1606 struct nameidata new_nd
, old_nd
;
1610 if (!capable(CAP_SYS_ADMIN
))
1615 name
= getname(new_root
);
1616 error
= PTR_ERR(name
);
1620 if (path_init(name
, LOOKUP_POSITIVE
|LOOKUP_FOLLOW
|LOOKUP_DIRECTORY
, &new_nd
))
1621 error
= path_walk(name
, &new_nd
);
1626 name
= getname(put_old
);
1627 error
= PTR_ERR(name
);
1631 if (path_init(name
, LOOKUP_POSITIVE
|LOOKUP_FOLLOW
|LOOKUP_DIRECTORY
, &old_nd
))
1632 error
= path_walk(name
, &old_nd
);
1637 read_lock(¤t
->fs
->lock
);
1638 root_mnt
= mntget(current
->fs
->rootmnt
);
1639 root
= dget(current
->fs
->root
);
1640 read_unlock(¤t
->fs
->lock
);
1642 down(&old_nd
.dentry
->d_inode
->i_zombie
);
1644 if (IS_DEADDIR(new_nd
.dentry
->d_inode
))
1646 if (d_unhashed(new_nd
.dentry
) && !IS_ROOT(new_nd
.dentry
))
1648 if (d_unhashed(old_nd
.dentry
) && !IS_ROOT(old_nd
.dentry
))
1651 if (new_nd
.mnt
== root_mnt
|| old_nd
.mnt
== root_mnt
)
1652 goto out2
; /* loop */
1654 tmp
= old_nd
.mnt
; /* make sure we can reach put_old from new_root */
1655 spin_lock(&dcache_lock
);
1656 if (tmp
!= new_nd
.mnt
) {
1658 if (tmp
->mnt_parent
== tmp
)
1660 if (tmp
->mnt_parent
== new_nd
.mnt
)
1662 tmp
= tmp
->mnt_parent
;
1664 if (!is_subdir(tmp
->mnt_mountpoint
, new_nd
.dentry
))
1666 } else if (!is_subdir(old_nd
.dentry
, new_nd
.dentry
))
1668 spin_unlock(&dcache_lock
);
1670 move_vfsmnt(new_nd
.mnt
, new_nd
.dentry
, NULL
, NULL
);
1671 move_vfsmnt(root_mnt
, old_nd
.dentry
, old_nd
.mnt
, NULL
);
1672 chroot_fs_refs(root
,root_mnt
,new_nd
.dentry
,new_nd
.mnt
);
1675 up(&old_nd
.dentry
->d_inode
->i_zombie
);
1679 path_release(&old_nd
);
1681 path_release(&new_nd
);
1686 spin_unlock(&dcache_lock
);
1691 #ifdef CONFIG_BLK_DEV_INITRD
1693 int __init
change_root(kdev_t new_root_dev
,const char *put_old
)
1695 struct vfsmount
*old_rootmnt
;
1696 struct nameidata devfs_nd
, nd
;
1699 read_lock(¤t
->fs
->lock
);
1700 old_rootmnt
= mntget(current
->fs
->rootmnt
);
1701 read_unlock(¤t
->fs
->lock
);
1702 /* First unmount devfs if mounted */
1703 if (path_init("/dev", LOOKUP_FOLLOW
|LOOKUP_POSITIVE
, &devfs_nd
))
1704 error
= path_walk("/dev", &devfs_nd
);
1706 if (devfs_nd
.mnt
->mnt_sb
->s_magic
== DEVFS_SUPER_MAGIC
&&
1707 devfs_nd
.dentry
== devfs_nd
.mnt
->mnt_root
) {
1708 dput(devfs_nd
.dentry
);
1710 /* puts devfs_nd.mnt */
1711 do_umount(devfs_nd
.mnt
, 0, 0);
1714 path_release(&devfs_nd
);
1716 ROOT_DEV
= new_root_dev
;
1720 printk("change_root: old root has d_count=%d\n",
1721 atomic_read(&old_rootmnt
->mnt_root
->d_count
));
1725 * Get the new mount directory
1728 if (path_init(put_old
, LOOKUP_FOLLOW
|LOOKUP_POSITIVE
|LOOKUP_DIRECTORY
, &nd
))
1729 error
= path_walk(put_old
, &nd
);
1733 printk(KERN_NOTICE
"Trying to unmount old root ... ");
1734 blivet
= do_umount(old_rootmnt
, 1, 0);
1739 printk(KERN_ERR
"error %d\n",blivet
);
1742 /* FIXME: we should hold i_zombie on nd.dentry */
1743 move_vfsmnt(old_rootmnt
, nd
.dentry
, nd
.mnt
, "/dev/root.old");
1744 mntput(old_rootmnt
);