1 /* $OpenBSD: mount.h,v 1.62 2005/07/03 20:14:00 drahn Exp $ */ 2 /* $NetBSD: mount.h,v 1.48 1996/02/18 11:55:47 fvdl Exp $ */ 3 4 /* 5 * Copyright (c) 1989, 1991, 1993 6 * The Regents of the University of California. All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 3. Neither the name of the University nor the names of its contributors 17 * may be used to endorse or promote products derived from this software 18 * without specific prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 * 32 * @(#)mount.h 8.15 (Berkeley) 7/14/94 33 */ 34 35 #ifndef _SYS_MOUNT_H_ 36 #define _SYS_MOUNT_H_ 37 38 #ifndef _KERNEL 39 #include <sys/ucred.h> 40 #endif 41 #include <sys/queue.h> 42 #include <sys/lock.h> 43 44 typedef struct { int32_t val[2]; } fsid_t; /* file system id type */ 45 46 /* 47 * File identifier. 48 * These are unique per filesystem on a single machine. 49 */ 50 #define MAXFIDSZ 16 51 52 struct fid { 53 u_short fid_len; /* length of data in bytes */ 54 u_short fid_reserved; /* force longword alignment */ 55 char fid_data[MAXFIDSZ]; /* data (variable length) */ 56 }; 57 58 /* 59 * Export arguments for local filesystem mount calls. 60 */ 61 struct export_args { 62 int ex_flags; /* export related flags */ 63 uid_t ex_root; /* mapping for root uid */ 64 struct ucred ex_anon; /* mapping for anonymous user */ 65 struct sockaddr *ex_addr; /* net address to which exported */ 66 int ex_addrlen; /* and the net address length */ 67 struct sockaddr *ex_mask; /* mask of valid bits in saddr */ 68 int ex_masklen; /* and the smask length */ 69 }; 70 71 /* 72 * Arguments to mount UFS-based filesystems 73 */ 74 struct ufs_args { 75 char *fspec; /* block special device to mount */ 76 struct export_args export_info;/* network export information */ 77 }; 78 79 /* 80 * Arguments to mount MFS 81 */ 82 struct mfs_args { 83 char *fspec; /* name to export for statfs */ 84 struct export_args export_info;/* if exported MFSes are supported */ 85 caddr_t base; /* base of file system in memory */ 86 u_long size; /* size of file system */ 87 }; 88 89 /* 90 * Arguments to mount ISO 9660 filesystems. 91 */ 92 struct iso_args { 93 char *fspec; /* block special device to mount */ 94 struct export_args export_info;/* network export info */ 95 int flags; /* mounting flags, see below */ 96 }; 97 #define ISOFSMNT_NORRIP 0x00000001 /* disable Rock Ridge Ext.*/ 98 #define ISOFSMNT_GENS 0x00000002 /* enable generation numbers */ 99 #define ISOFSMNT_EXTATT 0x00000004 /* enable extended attributes */ 100 #define ISOFSMNT_NOJOLIET 0x00000008 /* disable Joliet Ext.*/ 101 102 /* 103 * Arguments to mount NFS 104 */ 105 #define NFS_ARGSVERSION 4 /* change when nfs_args changes */ 106 struct nfs_args { 107 int version; /* args structure version number */ 108 struct sockaddr *addr; /* file server address */ 109 int addrlen; /* length of address */ 110 int sotype; /* Socket type */ 111 int proto; /* and Protocol */ 112 u_char *fh; /* File handle to be mounted */ 113 int fhsize; /* Size, in bytes, of fh */ 114 int flags; /* flags */ 115 int wsize; /* write size in bytes */ 116 int rsize; /* read size in bytes */ 117 int readdirsize; /* readdir size in bytes */ 118 int timeo; /* initial timeout in .1 secs */ 119 int retrans; /* times to retry send */ 120 int maxgrouplist; /* Max. size of group list */ 121 int readahead; /* # of blocks to readahead */ 122 int leaseterm; /* Term (sec) of lease */ 123 int deadthresh; /* Retrans threshold */ 124 char *hostname; /* server's name */ 125 int acregmin; /* Attr cache file recently modified */ 126 int acregmax; /* ac file not recently modified */ 127 int acdirmin; /* ac for dir recently modified */ 128 int acdirmax; /* ac for dir not recently modified */ 129 }; 130 /* NFS args version 3 (for backwards compatibility) */ 131 struct nfs_args3 { 132 int version; /* args structure version number */ 133 struct sockaddr *addr; /* file server address */ 134 int addrlen; /* length of address */ 135 int sotype; /* Socket type */ 136 int proto; /* and Protocol */ 137 u_char *fh; /* File handle to be mounted */ 138 int fhsize; /* Size, in bytes, of fh */ 139 int flags; /* flags */ 140 int wsize; /* write size in bytes */ 141 int rsize; /* read size in bytes */ 142 int readdirsize; /* readdir size in bytes */ 143 int timeo; /* initial timeout in .1 secs */ 144 int retrans; /* times to retry send */ 145 int maxgrouplist; /* Max. size of group list */ 146 int readahead; /* # of blocks to readahead */ 147 int leaseterm; /* Term (sec) of lease */ 148 int deadthresh; /* Retrans threshold */ 149 char *hostname; /* server's name */ 150 }; 151 152 /* 153 * NFS mount option flags 154 */ 155 #ifndef _KERNEL 156 #define NFSMNT_RESVPORT 0x00000000 /* always use reserved ports */ 157 #endif /* ! _KERNEL */ 158 #define NFSMNT_SOFT 0x00000001 /* soft mount (hard is default) */ 159 #define NFSMNT_WSIZE 0x00000002 /* set write size */ 160 #define NFSMNT_RSIZE 0x00000004 /* set read size */ 161 #define NFSMNT_TIMEO 0x00000008 /* set initial timeout */ 162 #define NFSMNT_RETRANS 0x00000010 /* set number of request retries */ 163 #define NFSMNT_MAXGRPS 0x00000020 /* set maximum grouplist size */ 164 #define NFSMNT_INT 0x00000040 /* allow interrupts on hard mount */ 165 #define NFSMNT_NOCONN 0x00000080 /* Don't Connect the socket */ 166 #define NFSMNT_NQNFS 0x00000100 /* Use Nqnfs protocol */ 167 #define NFSMNT_NFSV3 0x00000200 /* Use NFS Version 3 protocol */ 168 #define NFSMNT_KERB 0x00000400 /* Use Kerberos authentication */ 169 #define NFSMNT_DUMBTIMR 0x00000800 /* Don't estimate rtt dynamically */ 170 #define NFSMNT_LEASETERM 0x00001000 /* set lease term (nqnfs) */ 171 #define NFSMNT_READAHEAD 0x00002000 /* set read ahead */ 172 #define NFSMNT_DEADTHRESH 0x00004000 /* set dead server retry thresh */ 173 #ifdef _KERNEL /* Coming soon to a system call near you! */ 174 #define NFSMNT_NOAC 0x00008000 /* disable attribute cache */ 175 #endif /* _KERNEL */ 176 #define NFSMNT_RDIRPLUS 0x00010000 /* Use Readdirplus for V3 */ 177 #define NFSMNT_READDIRSIZE 0x00020000 /* Set readdir size */ 178 179 /* Flags valid only in mount syscall arguments */ 180 #define NFSMNT_ACREGMIN 0x00040000 /* acregmin field valid */ 181 #define NFSMNT_ACREGMAX 0x00080000 /* acregmax field valid */ 182 #define NFSMNT_ACDIRMIN 0x00100000 /* acdirmin field valid */ 183 #define NFSMNT_ACDIRMAX 0x00200000 /* acdirmax field valid */ 184 185 /* Flags valid only in kernel */ 186 #define NFSMNT_INTERNAL 0xfffc0000 /* Bits set internally */ 187 #define NFSMNT_HASWRITEVERF 0x00040000 /* Has write verifier for V3 */ 188 #define NFSMNT_GOTPATHCONF 0x00080000 /* Got the V3 pathconf info */ 189 #define NFSMNT_GOTFSINFO 0x00100000 /* Got the V3 fsinfo */ 190 #define NFSMNT_MNTD 0x00200000 /* Mnt server for mnt point */ 191 #define NFSMNT_DISMINPROG 0x00400000 /* Dismount in progress */ 192 #define NFSMNT_DISMNT 0x00800000 /* Dismounted */ 193 #define NFSMNT_SNDLOCK 0x01000000 /* Send socket lock */ 194 #define NFSMNT_WANTSND 0x02000000 /* Want above */ 195 #define NFSMNT_RCVLOCK 0x04000000 /* Rcv socket lock */ 196 #define NFSMNT_WANTRCV 0x08000000 /* Want above */ 197 #define NFSMNT_WAITAUTH 0x10000000 /* Wait for authentication */ 198 #define NFSMNT_HASAUTH 0x20000000 /* Has authenticator */ 199 #define NFSMNT_WANTAUTH 0x40000000 /* Wants an authenticator */ 200 #define NFSMNT_AUTHERR 0x80000000 /* Authentication error */ 201 202 /* 203 * Arguments to mount MSDOS filesystems. 204 */ 205 struct msdosfs_args { 206 char *fspec; /* blocks special holding the fs to mount */ 207 struct export_args export_info; 208 /* network export information */ 209 uid_t uid; /* uid that owns msdosfs files */ 210 gid_t gid; /* gid that owns msdosfs files */ 211 mode_t mask; /* mask to be applied for msdosfs perms */ 212 int flags; /* see below */ 213 }; 214 215 /* 216 * Msdosfs mount options: 217 */ 218 #define MSDOSFSMNT_SHORTNAME 0x01 /* Force old DOS short names only */ 219 #define MSDOSFSMNT_LONGNAME 0x02 /* Force Win'95 long names */ 220 #define MSDOSFSMNT_NOWIN95 0x04 /* Completely ignore Win95 entries */ 221 #define MSDOSFSMNT_GEMDOSFS 0x08 /* This is a gemdos-flavour */ 222 #define MSDOSFSMNT_ALLOWDIRX 0x10 /* dir is mode +x if r */ 223 224 /* 225 * Arguments to mount amigados filesystems. 226 */ 227 struct adosfs_args { 228 char *fspec; /* blocks special holding the fs to mount */ 229 struct export_args export_info; 230 /* network export information */ 231 uid_t uid; /* uid that owns adosfs files */ 232 gid_t gid; /* gid that owns adosfs files */ 233 mode_t mask; /* mask to be applied for adosfs perms */ 234 }; 235 236 /* 237 * Arguments to mount ntfs filesystems 238 */ 239 struct ntfs_args { 240 char *fspec; /* block special device to mount */ 241 struct export_args export_info;/* network export information */ 242 uid_t uid; /* uid that owns ntfs files */ 243 gid_t gid; /* gid that owns ntfs files */ 244 mode_t mode; /* mask to be applied for ntfs perms */ 245 u_long flag; /* additional flags */ 246 }; 247 248 /* 249 * ntfs mount options: 250 */ 251 #define NTFS_MFLAG_CASEINS 0x00000001 252 #define NTFS_MFLAG_ALLNAMES 0x00000002 253 254 /* 255 * Arguments to mount UDF filesystems. 256 */ 257 struct udf_args { 258 char *fspec; /* block special device to mount */ 259 }; 260 261 /* 262 * Arguments to mount procfs filesystems 263 */ 264 struct procfs_args { 265 int version; 266 int flags; 267 }; 268 269 /* 270 * procfs mount options: 271 */ 272 #define PROCFS_ARGSVERSION 1 273 #define PROCFSMNT_LINUXCOMPAT 0x01 274 275 276 /* 277 * file system statistics 278 */ 279 280 #define MFSNAMELEN 16 /* length of fs type name, including nul */ 281 #define MNAMELEN 90 /* length of buffer for returned name */ 282 283 /* per-filesystem mount options */ 284 union mount_info { 285 struct ufs_args ufs_args; 286 struct mfs_args mfs_args; 287 struct nfs_args nfs_args; 288 struct iso_args iso_args; 289 struct procfs_args procfs_args; 290 struct msdosfs_args msdosfs_args; 291 struct adosfs_args adosfs_args; 292 struct ntfs_args ntfs_args; 293 char __align[160]; /* 64-bit alignment and room to grow */ 294 }; 295 296 /* new statfs structure with mount options */ 297 struct statfs { 298 u_int32_t f_flags; /* copy of mount flags */ 299 int32_t f_bsize; /* fundamental file system block size */ 300 u_int32_t f_iosize; /* optimal transfer block size */ 301 u_int32_t f_blocks; /* total data blocks in file system */ 302 u_int32_t f_bfree; /* free blocks in fs */ 303 int32_t f_bavail; /* free blocks avail to non-superuser */ 304 u_int32_t f_files; /* total file nodes in file system */ 305 u_int32_t f_ffree; /* free file nodes in fs */ 306 fsid_t f_fsid; /* file system id */ 307 uid_t f_owner; /* user that mounted the file system */ 308 u_int32_t f_syncwrites; /* count of sync writes since mount */ 309 u_int32_t f_asyncwrites; /* count of async writes since mount */ 310 u_int32_t f_ctime; /* last mount [-u] time */ 311 u_int32_t f_spare[3]; /* spare for later */ 312 char f_fstypename[MFSNAMELEN]; /* fs type name */ 313 char f_mntonname[MNAMELEN]; /* directory on which mounted */ 314 char f_mntfromname[MNAMELEN]; /* mounted file system */ 315 union mount_info mount_info; /* per-filesystem mount options */ 316 }; 317 318 /* old (pre-2.6) statfs structure */ 319 struct ostatfs { 320 short f_type; /* type of file system (unused; zero) */ 321 short f_flags; /* copy of mount flags */ 322 long f_bsize; /* fundamental file system block size */ 323 long f_iosize; /* optimal transfer block size */ 324 long f_blocks; /* total data blocks in file system */ 325 long f_bfree; /* free blocks in fs */ 326 long f_bavail; /* free blocks avail to non-superuser */ 327 long f_files; /* total file nodes in file system */ 328 long f_ffree; /* free file nodes in fs */ 329 fsid_t f_fsid; /* file system id */ 330 uid_t f_owner; /* user that mounted the file system */ 331 long f_syncwrites; /* count of sync writes since mount */ 332 long f_asyncwrites; /* count of async writes since mount */ 333 long f_spare[2]; /* spare for later */ 334 char f_fstypename[MFSNAMELEN]; /* fs type name */ 335 char f_mntonname[MNAMELEN]; /* directory on which mounted */ 336 char f_mntfromname[MNAMELEN]; /* mounted file system */ 337 }; 338 339 /* 340 * File system types. 341 */ 342 #define MOUNT_FFS "ffs" /* UNIX "Fast" Filesystem */ 343 #define MOUNT_UFS MOUNT_FFS /* for compatibility */ 344 #define MOUNT_NFS "nfs" /* Network Filesystem */ 345 #define MOUNT_MFS "mfs" /* Memory Filesystem */ 346 #define MOUNT_MSDOS "msdos" /* MSDOS Filesystem */ 347 #define MOUNT_LFS "lfs" /* Log-based Filesystem */ 348 #define MOUNT_LOFS "lofs" /* Loopback filesystem */ 349 #define MOUNT_FDESC "fdesc" /* File Descriptor Filesystem */ 350 #define MOUNT_PORTAL "portal" /* Portal Filesystem */ 351 #define MOUNT_KERNFS "kernfs" /* Kernel Information Filesystem */ 352 #define MOUNT_PROCFS "procfs" /* /proc Filesystem */ 353 #define MOUNT_AFS "afs" /* Andrew Filesystem */ 354 #define MOUNT_CD9660 "cd9660" /* ISO9660 (aka CDROM) Filesystem */ 355 #define MOUNT_ADOSFS "adosfs" /* AmigaDOS Filesystem */ 356 #define MOUNT_EXT2FS "ext2fs" /* Second Extended Filesystem */ 357 #define MOUNT_NCPFS "ncpfs" /* NetWare Network File System */ 358 #define MOUNT_XFS "xfs" /* xfs */ 359 #define MOUNT_NTFS "ntfs" /* NTFS */ 360 #define MOUNT_UDF "udf" /* UDF */ 361 362 /* 363 * Structure per mounted file system. Each mounted file system has an 364 * array of operations and an instance record. The file systems are 365 * put on a doubly linked list. 366 */ 367 LIST_HEAD(vnodelst, vnode); 368 369 struct mount { 370 CIRCLEQ_ENTRY(mount) mnt_list; /* mount list */ 371 const struct vfsops *mnt_op; /* operations on fs */ 372 struct vfsconf *mnt_vfc; /* configuration info */ 373 struct vnode *mnt_vnodecovered; /* vnode we mounted on */ 374 struct vnode *mnt_syncer; /* syncer vnode */ 375 struct vnodelst mnt_vnodelist; /* list of vnodes this mount */ 376 struct lock mnt_lock; /* mount structure lock */ 377 int mnt_flag; /* flags */ 378 int mnt_maxsymlinklen; /* max size of short symlink */ 379 struct statfs mnt_stat; /* cache of filesystem stats */ 380 void *mnt_data; /* private data */ 381 }; 382 383 /* 384 * Mount flags. 385 * 386 * Unmount uses MNT_FORCE flag. 387 */ 388 #define MNT_RDONLY 0x00000001 /* read only filesystem */ 389 #define MNT_SYNCHRONOUS 0x00000002 /* file system written synchronously */ 390 #define MNT_NOEXEC 0x00000004 /* can't exec from filesystem */ 391 #define MNT_NOSUID 0x00000008 /* don't honor setuid bits on fs */ 392 #define MNT_NODEV 0x00000010 /* don't interpret special files */ 393 #define MNT_ASYNC 0x00000040 /* file system written asynchronously */ 394 395 /* 396 * exported mount flags. 397 */ 398 #define MNT_EXRDONLY 0x00000080 /* exported read only */ 399 #define MNT_EXPORTED 0x00000100 /* file system is exported */ 400 #define MNT_DEFEXPORTED 0x00000200 /* exported to the world */ 401 #define MNT_EXPORTANON 0x00000400 /* use anon uid mapping for everyone */ 402 #define MNT_EXKERB 0x00000800 /* exported with Kerberos uid mapping */ 403 404 /* 405 * Flags set by internal operations. 406 */ 407 #define MNT_LOCAL 0x00001000 /* filesystem is stored locally */ 408 #define MNT_QUOTA 0x00002000 /* quotas are enabled on filesystem */ 409 #define MNT_ROOTFS 0x00004000 /* identifies the root filesystem */ 410 411 /* 412 * Extra post 4.4BSD-lite2 mount flags. 413 */ 414 #define MNT_NOATIME 0x00008000 /* don't update access times on fs */ 415 416 /* 417 * Mask of flags that are visible to statfs() 418 */ 419 #define MNT_VISFLAGMASK 0x0400ffff 420 421 /* 422 * filesystem control flags. 423 */ 424 #define MNT_UPDATE 0x00010000 /* not a real mount, just an update */ 425 #define MNT_DELEXPORT 0x00020000 /* delete export host lists */ 426 #define MNT_RELOAD 0x00040000 /* reload filesystem data */ 427 #define MNT_FORCE 0x00080000 /* force unmount or readonly change */ 428 #define MNT_WANTRDWR 0x02000000 /* want upgrade to read/write */ 429 #define MNT_SOFTDEP 0x04000000 /* soft dependencies being done */ 430 #define MNT_DOOMED 0x08000000 /* device behind filesystem is gone */ 431 432 /* 433 * Sysctl CTL_VFS definitions. 434 * 435 * Second level identifier specifies which filesystem. Second level 436 * identifier VFS_GENERIC returns information about all filesystems. 437 */ 438 #define VFS_GENERIC 0 /* generic filesystem information */ 439 /* 440 * Third level identifiers for VFS_GENERIC are given below; third 441 * level identifiers for specific filesystems are given in their 442 * mount specific header files. 443 */ 444 #define VFS_MAXTYPENUM 1 /* int: highest defined filesystem type */ 445 #define VFS_CONF 2 /* struct: vfsconf for filesystem given 446 as next argument */ 447 #define VFSGEN_MAXID 3 /* max number of vfs.generic ids */ 448 449 #define CTL_VFSGENCTL_NAMES { \ 450 { 0, 0 }, \ 451 { "maxtypenum", CTLTYPE_INT }, \ 452 { "conf", CTLTYPE_NODE } \ 453 } 454 455 /* 456 * Filesystem configuration information. One of these exists for each 457 * type of filesystem supported by the kernel. These are searched at 458 * mount time to identify the requested filesystem. 459 */ 460 struct vfsconf { 461 const struct vfsops *vfc_vfsops; /* filesystem operations vector */ 462 char vfc_name[MFSNAMELEN]; /* filesystem type name */ 463 int vfc_typenum; /* historic filesystem type number */ 464 int vfc_refcount; /* number mounted of this type */ 465 int vfc_flags; /* permanent flags */ 466 int (*vfc_mountroot)(void); /* if != NULL, routine to mount root */ 467 struct vfsconf *vfc_next; /* next in list */ 468 }; 469 470 /* 471 * Operations supported on mounted file system. 472 */ 473 #ifdef _KERNEL 474 #ifdef __STDC__ 475 struct nameidata; 476 struct mbuf; 477 #endif 478 479 extern int maxvfsconf; /* highest defined filesystem type */ 480 extern struct vfsconf *vfsconf; /* head of list of filesystem types */ 481 482 struct vfsops { 483 int (*vfs_mount)(struct mount *mp, const char *path, 484 void *data, 485 struct nameidata *ndp, struct proc *p); 486 int (*vfs_start)(struct mount *mp, int flags, 487 struct proc *p); 488 int (*vfs_unmount)(struct mount *mp, int mntflags, 489 struct proc *p); 490 int (*vfs_root)(struct mount *mp, struct vnode **vpp); 491 int (*vfs_quotactl)(struct mount *mp, int cmds, uid_t uid, 492 caddr_t arg, struct proc *p); 493 int (*vfs_statfs)(struct mount *mp, struct statfs *sbp, 494 struct proc *p); 495 int (*vfs_sync)(struct mount *mp, int waitfor, 496 struct ucred *cred, struct proc *p); 497 int (*vfs_vget)(struct mount *mp, ino_t ino, 498 struct vnode **vpp); 499 int (*vfs_fhtovp)(struct mount *mp, struct fid *fhp, 500 struct vnode **vpp); 501 int (*vfs_vptofh)(struct vnode *vp, struct fid *fhp); 502 int (*vfs_init)(struct vfsconf *); 503 int (*vfs_sysctl)(int *, u_int, void *, size_t *, void *, 504 size_t, struct proc *); 505 int (*vfs_checkexp)(struct mount *mp, struct mbuf *nam, 506 int *extflagsp, struct ucred **credanonp); 507 }; 508 509 #define VFS_MOUNT(MP, PATH, DATA, NDP, P) \ 510 (*(MP)->mnt_op->vfs_mount)(MP, PATH, DATA, NDP, P) 511 #define VFS_START(MP, FLAGS, P) (*(MP)->mnt_op->vfs_start)(MP, FLAGS, P) 512 #define VFS_UNMOUNT(MP, FORCE, P) (*(MP)->mnt_op->vfs_unmount)(MP, FORCE, P) 513 #define VFS_ROOT(MP, VPP) (*(MP)->mnt_op->vfs_root)(MP, VPP) 514 #define VFS_QUOTACTL(MP,C,U,A,P) (*(MP)->mnt_op->vfs_quotactl)(MP, C, U, A, P) 515 #define VFS_STATFS(MP, SBP, P) (*(MP)->mnt_op->vfs_statfs)(MP, SBP, P) 516 #define VFS_SYNC(MP, WAIT, C, P) (*(MP)->mnt_op->vfs_sync)(MP, WAIT, C, P) 517 #define VFS_VGET(MP, INO, VPP) (*(MP)->mnt_op->vfs_vget)(MP, INO, VPP) 518 #define VFS_FHTOVP(MP, FIDP, VPP) \ 519 (*(MP)->mnt_op->vfs_fhtovp)(MP, FIDP, VPP) 520 #define VFS_VPTOFH(VP, FIDP) (*(VP)->v_mount->mnt_op->vfs_vptofh)(VP, FIDP) 521 #define VFS_CHECKEXP(MP, NAM, EXFLG, CRED) \ 522 (*(MP)->mnt_op->vfs_checkexp)(MP, NAM, EXFLG, CRED) 523 #endif /* _KERNEL */ 524 525 /* 526 * Flags for various system call interfaces. 527 * 528 * waitfor flags to vfs_sync() and getfsstat() 529 */ 530 #define MNT_WAIT 1 /* synchronously wait for I/O to complete */ 531 #define MNT_NOWAIT 2 /* start all I/O, but do not wait for it */ 532 #define MNT_LAZY 3 /* push data not written by filesystem syncer */ 533 534 /* 535 * Generic file handle 536 */ 537 struct fhandle { 538 fsid_t fh_fsid; /* File system id of mount point */ 539 struct fid fh_fid; /* File sys specific id */ 540 }; 541 typedef struct fhandle fhandle_t; 542 543 #ifdef _KERNEL 544 #include <net/radix.h> 545 #include <sys/socket.h> /* XXX for AF_MAX */ 546 547 /* 548 * Network address lookup element 549 */ 550 struct netcred { 551 struct radix_node netc_rnodes[2]; 552 int netc_exflags; 553 struct ucred netc_anon; 554 }; 555 556 /* 557 * Network export information 558 */ 559 struct netexport { 560 struct netcred ne_defexported; /* Default export */ 561 struct radix_node_head *ne_rtable[AF_MAX+1]; /* Individual exports */ 562 }; 563 #endif /* _KERNEL */ 564 565 #ifdef _KERNEL 566 /* 567 * exported vnode operations 568 */ 569 int vfs_busy(struct mount *, int, struct simplelock *, struct proc *); 570 int vfs_isbusy(struct mount *); 571 int vfs_mount_foreach_vnode(struct mount *, int (*func)(struct vnode *, 572 void *), void *); 573 void vfs_getnewfsid(struct mount *); 574 struct mount *vfs_getvfs(fsid_t *); 575 int vfs_mountedon(struct vnode *); 576 int vfs_mountroot(void); 577 int vfs_rootmountalloc(char *, char *, struct mount **); 578 void vfs_unbusy(struct mount *, struct proc *); 579 void vfs_unmountall(void); 580 extern CIRCLEQ_HEAD(mntlist, mount) mountlist; 581 extern struct simplelock mountlist_slock; 582 583 struct mount *getvfs(fsid_t *); /* return vfs given fsid */ 584 /* process mount export info */ 585 int vfs_export(struct mount *, struct netexport *, struct export_args *); 586 /* lookup host in fs export list */ 587 struct netcred *vfs_export_lookup(struct mount *, struct netexport *, 588 struct mbuf *); 589 int vfs_allocate_syncvnode(struct mount *); 590 int speedup_syncer(void); 591 592 int vfs_syncwait(int); /* sync and wait for complete */ 593 void vfs_shutdown(void); /* unmount and sync file systems */ 594 long makefstype(char *); 595 int dounmount(struct mount *, int, struct proc *, struct vnode *); 596 void vfsinit(void); 597 #ifdef DEBUG 598 void vfs_bufstats(void); 599 #endif 600 int vfs_register(struct vfsconf *); 601 int vfs_unregister(struct vfsconf *); 602 #else /* _KERNEL */ 603 604 #include <sys/cdefs.h> 605 606 #ifndef _SYS_STAT_H_ 607 struct stat; 608 #endif 609 610 __BEGIN_DECLS 611 int fstatfs(int, struct statfs *); 612 int getfh(const char *, fhandle_t *); 613 int getfsstat(struct statfs *, size_t, int); 614 int getmntinfo(struct statfs **, int); 615 int mount(const char *, const char *, int, void *); 616 int statfs(const char *, struct statfs *); 617 int unmount(const char *, int); 618 #if !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE) 619 int fhopen(const fhandle_t *, int); 620 int fhstat(const fhandle_t *, struct stat *); 621 int fhstatfs(const fhandle_t *, struct statfs *); 622 #endif /* !_POSIX_C_SOURCE */ 623 624 __END_DECLS 625 626 #endif /* _KERNEL */ 627 #endif /* !_SYS_MOUNT_H_ */ 628