#ifndef _SYS_MOUNT_H_
#define _SYS_MOUNT_H_
#include <sys/cdefs.h>
#ifndef _KERNEL
#include <sys/ucred.h>
#endif
#include <sys/queue.h>
#include <sys/rwlock.h>
typedef struct { int32_t val[2]; } fsid_t;
#define MAXFIDSZ 16
struct fid {
u_short fid_len;
u_short fid_reserved;
char fid_data[MAXFIDSZ];
};
struct export_args {
int ex_flags;
uid_t ex_root;
struct xucred ex_anon;
struct sockaddr *ex_addr;
int ex_addrlen;
struct sockaddr *ex_mask;
int ex_masklen;
};
struct ufs_args {
char *fspec;
struct export_args export_info;
};
struct mfs_args {
char *fspec;
struct export_args export_info;
caddr_t base;
u_long size;
};
struct iso_args {
char *fspec;
struct export_args export_info;
int flags;
int sess;
};
#define ISOFSMNT_NORRIP 0x00000001
#define ISOFSMNT_GENS 0x00000002
#define ISOFSMNT_EXTATT 0x00000004
#define ISOFSMNT_NOJOLIET 0x00000008
#define ISOFSMNT_SESS 0x00000010
#define NFS_ARGSVERSION 4
struct nfs_args {
int version;
struct sockaddr *addr;
int addrlen;
int sotype;
int proto;
u_char *fh;
int fhsize;
int flags;
int wsize;
int rsize;
int readdirsize;
int timeo;
int retrans;
int maxgrouplist;
int readahead;
int leaseterm;
int deadthresh;
char *hostname;
int acregmin;
int acregmax;
int acdirmin;
int acdirmax;
};
#define NFSMNT_RESVPORT 0x00000000
#define NFSMNT_SOFT 0x00000001
#define NFSMNT_WSIZE 0x00000002
#define NFSMNT_RSIZE 0x00000004
#define NFSMNT_TIMEO 0x00000008
#define NFSMNT_RETRANS 0x00000010
#define NFSMNT_MAXGRPS 0x00000020
#define NFSMNT_INT 0x00000040
#define NFSMNT_NOCONN 0x00000080
#define NFSMNT_NQNFS 0x00000100
#define NFSMNT_NFSV3 0x00000200
#define NFSMNT_KERB 0x00000400
#define NFSMNT_DUMBTIMR 0x00000800
#define NFSMNT_LEASETERM 0x00001000
#define NFSMNT_READAHEAD 0x00002000
#define NFSMNT_DEADTHRESH 0x00004000
#define NFSMNT_NOAC 0x00008000
#define NFSMNT_RDIRPLUS 0x00010000
#define NFSMNT_READDIRSIZE 0x00020000
#define NFSMNT_ACREGMIN 0x00040000
#define NFSMNT_ACREGMAX 0x00080000
#define NFSMNT_ACDIRMIN 0x00100000
#define NFSMNT_ACDIRMAX 0x00200000
#define NFSMNT_INTERNAL 0xfffc0000
#define NFSMNT_HASWRITEVERF 0x00040000
#define NFSMNT_GOTPATHCONF 0x00080000
#define NFSMNT_GOTFSINFO 0x00100000
#define NFSMNT_MNTD 0x00200000
#define NFSMNT_DISMINPROG 0x00400000
#define NFSMNT_DISMNT 0x00800000
#define NFSMNT_SNDLOCK 0x01000000
#define NFSMNT_WANTSND 0x02000000
#define NFSMNT_RCVLOCK 0x04000000
#define NFSMNT_WANTRCV 0x08000000
#define NFSMNT_WAITAUTH 0x10000000
#define NFSMNT_HASAUTH 0x20000000
#define NFSMNT_WANTAUTH 0x40000000
#define NFSMNT_AUTHERR 0x80000000
struct msdosfs_args {
char *fspec;
struct export_args export_info;
uid_t uid;
gid_t gid;
mode_t mask;
int flags;
};
#define MSDOSFSMNT_SHORTNAME 0x01
#define MSDOSFSMNT_LONGNAME 0x02
#define MSDOSFSMNT_NOWIN95 0x04
struct ntfs_args {
char *fspec;
struct export_args export_info;
uid_t uid;
gid_t gid;
mode_t mode;
u_long flag;
};
#define NTFS_MFLAG_CASEINS 0x00000001
#define NTFS_MFLAG_ALLNAMES 0x00000002
struct udf_args {
char *fspec;
u_int32_t lastblock;
};
#define TMPFS_ARGS_VERSION 1
struct tmpfs_args {
int ta_version;
ino_t ta_nodes_max;
off_t ta_size_max;
uid_t ta_root_uid;
gid_t ta_root_gid;
mode_t ta_root_mode;
};
struct fusefs_args {
char *name;
int fd;
int max_read;
int allow_other;
};
#define MFSNAMELEN 16
#define MNAMELEN 90
union mount_info {
struct ufs_args ufs_args;
struct mfs_args mfs_args;
struct nfs_args nfs_args;
struct iso_args iso_args;
struct msdosfs_args msdosfs_args;
struct ntfs_args ntfs_args;
struct tmpfs_args tmpfs_args;
char __align[160];
};
struct statfs {
u_int32_t f_flags;
u_int32_t f_bsize;
u_int32_t f_iosize;
u_int64_t f_blocks;
u_int64_t f_bfree;
int64_t f_bavail;
u_int64_t f_files;
u_int64_t f_ffree;
int64_t f_favail;
u_int64_t f_syncwrites;
u_int64_t f_syncreads;
u_int64_t f_asyncwrites;
u_int64_t f_asyncreads;
fsid_t f_fsid;
u_int32_t f_namemax;
uid_t f_owner;
u_int64_t f_ctime;
char f_fstypename[MFSNAMELEN];
char f_mntonname[MNAMELEN];
char f_mntfromname[MNAMELEN];
char f_mntfromspec[MNAMELEN];
union mount_info mount_info;
};
#define MOUNT_FFS "ffs"
#define MOUNT_UFS MOUNT_FFS
#define MOUNT_NFS "nfs"
#define MOUNT_MFS "mfs"
#define MOUNT_MSDOS "msdos"
#define MOUNT_AFS "afs"
#define MOUNT_CD9660 "cd9660"
#define MOUNT_EXT2FS "ext2fs"
#define MOUNT_NCPFS "ncpfs"
#define MOUNT_NTFS "ntfs"
#define MOUNT_UDF "udf"
#define MOUNT_TMPFS "tmpfs"
#define MOUNT_FUSEFS "fuse"
struct mount {
TAILQ_ENTRY(mount) mnt_list;
SLIST_ENTRY(mount) mnt_dounmount;
const struct vfsops *mnt_op;
struct vfsconf *mnt_vfc;
struct vnode *mnt_vnodecovered;
struct vnode *mnt_syncer;
TAILQ_HEAD(, vnode) mnt_vnodelist;
struct rwlock mnt_lock;
struct refcnt mnt_refs;
int mnt_flag;
struct statfs mnt_stat;
void *mnt_data;
};
#define MNT_RDONLY 0x00000001
#define MNT_SYNCHRONOUS 0x00000002
#define MNT_NOEXEC 0x00000004
#define MNT_NOSUID 0x00000008
#define MNT_NODEV 0x00000010
#define MNT_NOPERM 0x00000020
#define MNT_ASYNC 0x00000040
#define MNT_WXALLOWED 0x00000800
#define MNT_EXRDONLY 0x00000080
#define MNT_EXPORTED 0x00000100
#define MNT_DEFEXPORTED 0x00000200
#define MNT_EXPORTANON 0x00000400
#define MNT_LOCAL 0x00001000
#define MNT_QUOTA 0x00002000
#define MNT_ROOTFS 0x00004000
#define MNT_NOATIME 0x00008000
#define MNT_VISFLAGMASK 0x0400ffff
#define MNT_BITS \
"\20\001RDONLY\002SYNCHRONOUS\003NOEXEC\004NOSUID\005NODEV\006NOPERM" \
"\007ASYNC\010EXRDONLY\011EXPORTED\012DEFEXPORTED\013EXPORTANON" \
"\014WXALLOWED\015LOCAL\016QUOTA\017ROOTFS\020NOATIME\021UPDATE" \
"\022DELEXPORT\023RELOAD\024FORCE\025STALLED\026SWAPPABLE\031UNMOUNT" \
"\032WANTRDWR\033SOFTDEP\034DOOMED"
#define MNT_UPDATE 0x00010000
#define MNT_DELEXPORT 0x00020000
#define MNT_RELOAD 0x00040000
#define MNT_FORCE 0x00080000
#define MNT_STALLED 0x00100000
#define MNT_SWAPPABLE 0x00200000
#define MNT_UNMOUNT 0x01000000
#define MNT_WANTRDWR 0x02000000
#define MNT_SOFTDEP 0x04000000
#define MNT_DOOMED 0x08000000
#ifdef _KERNEL
#define MNT_OP_FLAGS (MNT_UPDATE | MNT_RELOAD | MNT_FORCE | MNT_WANTRDWR)
#endif
#define MNT_WAIT 1
#define MNT_NOWAIT 2
#define MNT_LAZY 3
struct fhandle {
fsid_t fh_fsid;
struct fid fh_fid;
};
typedef struct fhandle fhandle_t;
#define VFS_GENERIC 0
#define VFS_MAXTYPENUM 1
#define VFS_CONF 2
#define VFS_BCACHESTAT 3
#define CTL_VFSGENCTL_NAMES { \
{ 0, 0 }, \
{ "maxtypenum", CTLTYPE_INT }, \
{ "conf", CTLTYPE_NODE }, \
{ "bcachestat", CTLTYPE_STRUCT } \
}
struct vfsconf {
const struct vfsops *vfc_vfsops;
char vfc_name[MFSNAMELEN];
int vfc_typenum;
u_int vfc_refcount;
int vfc_flags;
size_t vfc_datasize;
};
struct bcachestats {
int64_t numbufs;
int64_t numbufpages;
int64_t numdirtypages;
int64_t numcleanpages;
int64_t pendingwrites;
int64_t pendingreads;
int64_t numwrites;
int64_t numreads;
int64_t cachehits;
int64_t busymapped;
int64_t dmapages;
int64_t highpages;
int64_t delwribufs;
int64_t kvaslots;
int64_t kvaslots_avail;
int64_t highflips;
int64_t highflops;
int64_t dmaflips;
};
#ifdef _KERNEL
extern struct bcachestats bcstats;
extern long buflowpages, bufhighpages, bufbackpages;
#define BUFPAGES_DEFICIT (((buflowpages - bcstats.numbufpages) < 0) ? 0 \
: buflowpages - bcstats.numbufpages)
#define BUFPAGES_INACT (((bcstats.numcleanpages - buflowpages) < 0) ? 0 \
: bcstats.numcleanpages - buflowpages)
extern int bufcachepercent;
extern void bufadjust(int);
struct uvm_constraint_range;
extern unsigned long bufbackoff(struct uvm_constraint_range*, long);
struct nameidata;
struct mbuf;
extern int maxvfsconf;
struct vfsops {
int (*vfs_mount)(struct mount *mp, const char *path,
void *data,
struct nameidata *ndp, struct proc *p);
int (*vfs_start)(struct mount *mp, int flags,
struct proc *p);
int (*vfs_unmount)(struct mount *mp, int mntflags,
struct proc *p);
int (*vfs_root)(struct mount *mp, struct vnode **vpp);
int (*vfs_quotactl)(struct mount *mp, int cmds, uid_t uid,
caddr_t arg, struct proc *p);
int (*vfs_statfs)(struct mount *mp, struct statfs *sbp,
struct proc *p);
int (*vfs_sync)(struct mount *mp, int waitfor, int stall,
struct ucred *cred, struct proc *p);
int (*vfs_vget)(struct mount *mp, ino_t ino,
struct vnode **vpp);
int (*vfs_fhtovp)(struct mount *mp, struct fid *fhp,
struct vnode **vpp);
int (*vfs_vptofh)(struct vnode *vp, struct fid *fhp);
int (*vfs_init)(struct vfsconf *);
int (*vfs_sysctl)(int *, u_int, void *, size_t *, void *,
size_t, struct proc *);
int (*vfs_checkexp)(struct mount *mp, struct mbuf *nam,
int *extflagsp, struct ucred **credanonp);
};
#define VFS_MOUNT(MP, PATH, DATA, NDP, P) \
(*(MP)->mnt_op->vfs_mount)(MP, PATH, DATA, NDP, P)
#define VFS_START(MP, FLAGS, P) (*(MP)->mnt_op->vfs_start)(MP, FLAGS, P)
#define VFS_UNMOUNT(MP, FORCE, P) (*(MP)->mnt_op->vfs_unmount)(MP, FORCE, P)
#define VFS_ROOT(MP, VPP) (*(MP)->mnt_op->vfs_root)(MP, VPP)
#define VFS_QUOTACTL(MP,C,U,A,P) (*(MP)->mnt_op->vfs_quotactl)(MP, C, U, A, P)
#define VFS_STATFS(MP, SBP, P) (*(MP)->mnt_op->vfs_statfs)(MP, SBP, P)
#define VFS_SYNC(MP, W, S, C, P) (*(MP)->mnt_op->vfs_sync)(MP, W, S, C, P)
#define VFS_VGET(MP, INO, VPP) (*(MP)->mnt_op->vfs_vget)(MP, INO, VPP)
#define VFS_FHTOVP(MP, FIDP, VPP) \
(*(MP)->mnt_op->vfs_fhtovp)(MP, FIDP, VPP)
#define VFS_VPTOFH(VP, FIDP) (*(VP)->v_mount->mnt_op->vfs_vptofh)(VP, FIDP)
#define VFS_CHECKEXP(MP, NAM, EXFLG, CRED) \
(*(MP)->mnt_op->vfs_checkexp)(MP, NAM, EXFLG, CRED)
extern const struct vfsops ffs_vfsops;
extern const struct vfsops mfs_vfsops;
extern const struct vfsops msdosfs_vfsops;
extern const struct vfsops nfs_vfsops;
extern const struct vfsops cd9660_vfsops;
extern const struct vfsops ext2fs_vfsops;
extern const struct vfsops ntfs_vfsops;
extern const struct vfsops udf_vfsops;
extern const struct vfsops fusefs_vfsops;
extern const struct vfsops tmpfs_vfsops;
#include <net/radix.h>
#include <sys/socket.h>
struct netcred {
struct radix_node netc_rnodes[2];
int netc_exflags;
int netc_len;
struct ucred netc_anon;
};
struct netexport {
struct netcred ne_defexported;
struct radix_node_head *ne_rtable_inet;
};
int vfs_busy(struct mount *, int);
#define VB_READ 0x01
#define VB_WRITE 0x02
#define VB_NOWAIT 0x04
#define VB_WAIT 0x08
#define VB_DUPOK 0x10
int vfs_isbusy(struct mount *);
struct mount *vfs_mount_alloc(struct vnode *, struct vfsconf *);
void vfs_mount_free(struct mount *);
int vfs_mount_foreach_vnode(struct mount *, int (*func)(struct vnode *,
void *), void *);
void vfs_getnewfsid(struct mount *);
struct mount *vfs_getvfs(fsid_t *);
int vfs_mountedon(struct vnode *);
int vfs_rootmountalloc(char *, char *, struct mount **);
void vfs_unbusy(struct mount *);
extern TAILQ_HEAD(mntlist, mount) mountlist;
int vfs_stall(struct proc *, int);
void vfs_stall_barrier(void);
int vfs_export(struct mount *, struct netexport *, struct export_args *);
struct netcred *vfs_export_lookup(struct mount *, struct netexport *,
struct mbuf *);
int vfs_allocate_syncvnode(struct mount *);
int vfs_syncwait(struct proc *, int);
void vfs_shutdown(struct proc *);
int dounmount(struct mount *, int, struct proc *);
void vfsinit(void);
struct vfsconf *vfs_byname(const char *);
struct vfsconf *vfs_bytypenum(int);
#else
__BEGIN_DECLS
int fstatfs(int, struct statfs *);
int getfh(const char *, fhandle_t *);
int getfsstat(struct statfs *, size_t, int);
int getmntinfo(struct statfs **, int);
int mount(const char *, const char *, int, void *);
int statfs(const char *, struct statfs *);
int unmount(const char *, int);
#if __BSD_VISIBLE
struct stat;
int fhopen(const fhandle_t *, int);
int fhstat(const fhandle_t *, struct stat *);
int fhstatfs(const fhandle_t *, struct statfs *);
#endif
__END_DECLS
#endif
#endif