blob: f8f39937e301be584f3258881f5740457234cb31 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 *
3 * Definitions for mount interface. This describes the in the kernel build
4 * linkedlist with mounted filesystems.
5 *
6 * Author: Marco van Wieringen <mvw@planets.elm.net>
7 *
8 * Version: $Id: mount.h,v 2.0 1996/11/17 16:48:14 mvw Exp mvw $
9 *
10 */
11#ifndef _LINUX_MOUNT_H
12#define _LINUX_MOUNT_H
13#ifdef __KERNEL__
14
Andrew Mortond53d9f12005-07-12 13:58:07 -070015#include <linux/types.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070016#include <linux/list.h>
17#include <linux/spinlock.h>
18#include <asm/atomic.h>
19
20#define MNT_NOSUID 1
21#define MNT_NODEV 2
22#define MNT_NOEXEC 4
23
24struct vfsmount
25{
26 struct list_head mnt_hash;
27 struct vfsmount *mnt_parent; /* fs we are mounted on */
28 struct dentry *mnt_mountpoint; /* dentry of mountpoint */
29 struct dentry *mnt_root; /* root of the mounted tree */
30 struct super_block *mnt_sb; /* pointer to superblock */
31 struct list_head mnt_mounts; /* list of children, anchored here */
32 struct list_head mnt_child; /* and going through their mnt_child */
33 atomic_t mnt_count;
34 int mnt_flags;
35 int mnt_expiry_mark; /* true if marked for expiry */
36 char *mnt_devname; /* Name of device e.g. /dev/dsk/hda1 */
37 struct list_head mnt_list;
Miklos Szeredi55e700b2005-07-07 17:57:30 -070038 struct list_head mnt_expire; /* link in fs-specific expiry list */
Linus Torvalds1da177e2005-04-16 15:20:36 -070039 struct namespace *mnt_namespace; /* containing namespace */
40};
41
42static inline struct vfsmount *mntget(struct vfsmount *mnt)
43{
44 if (mnt)
45 atomic_inc(&mnt->mnt_count);
46 return mnt;
47}
48
49extern void __mntput(struct vfsmount *mnt);
50
Miklos Szeredi751c4042005-07-07 17:57:30 -070051static inline void mntput_no_expire(struct vfsmount *mnt)
Linus Torvalds1da177e2005-04-16 15:20:36 -070052{
53 if (mnt) {
54 if (atomic_dec_and_test(&mnt->mnt_count))
55 __mntput(mnt);
56 }
57}
58
59static inline void mntput(struct vfsmount *mnt)
60{
61 if (mnt) {
62 mnt->mnt_expiry_mark = 0;
Miklos Szeredi751c4042005-07-07 17:57:30 -070063 mntput_no_expire(mnt);
Linus Torvalds1da177e2005-04-16 15:20:36 -070064 }
65}
66
67extern void free_vfsmnt(struct vfsmount *mnt);
68extern struct vfsmount *alloc_vfsmnt(const char *name);
69extern struct vfsmount *do_kern_mount(const char *fstype, int flags,
70 const char *name, void *data);
71
72struct nameidata;
73
74extern int do_add_mount(struct vfsmount *newmnt, struct nameidata *nd,
75 int mnt_flags, struct list_head *fslist);
76
77extern void mark_mounts_for_expiry(struct list_head *mounts);
78
79extern spinlock_t vfsmount_lock;
Andrew Mortond53d9f12005-07-12 13:58:07 -070080extern dev_t name_to_dev_t(char *name);
Linus Torvalds1da177e2005-04-16 15:20:36 -070081
82#endif
83#endif /* _LINUX_MOUNT_H */