1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35 #ifndef _SYS_MOUNT_H_
36 #define _SYS_MOUNT_H_
37
38 #include <sys/cdefs.h>
39 #ifndef _KERNEL
40 #include <sys/ucred.h>
41 #endif
42 #include <sys/queue.h>
43 #include <sys/rwlock.h>
44
45 typedef struct { int32_t val[2]; } fsid_t;
46
47
48
49
50
51 #define MAXFIDSZ 16
52
53 struct fid {
54 u_short fid_len;
55 u_short fid_reserved;
56 char fid_data[MAXFIDSZ];
57 };
58
59
60
61
62 struct export_args {
63 int ex_flags;
64 uid_t ex_root;
65 struct ucred ex_anon;
66 struct sockaddr *ex_addr;
67 int ex_addrlen;
68 struct sockaddr *ex_mask;
69 int ex_masklen;
70 };
71
72
73
74
75 struct ufs_args {
76 char *fspec;
77 struct export_args export_info;
78 };
79
80
81
82
83 struct mfs_args {
84 char *fspec;
85 struct export_args export_info;
86 caddr_t base;
87 u_long size;
88 };
89
90
91
92
93 struct iso_args {
94 char *fspec;
95 struct export_args export_info;
96 int flags;
97 int sess;
98 };
99
100 #define ISOFSMNT_NORRIP 0x00000001
101 #define ISOFSMNT_GENS 0x00000002
102 #define ISOFSMNT_EXTATT 0x00000004
103 #define ISOFSMNT_NOJOLIET 0x00000008
104 #define ISOFSMNT_SESS 0x00000010
105
106
107
108
109 #define NFS_ARGSVERSION 4
110 struct nfs_args {
111 int version;
112 struct sockaddr *addr;
113 int addrlen;
114 int sotype;
115 int proto;
116 u_char *fh;
117 int fhsize;
118 int flags;
119 int wsize;
120 int rsize;
121 int readdirsize;
122 int timeo;
123 int retrans;
124 int maxgrouplist;
125 int readahead;
126 int leaseterm;
127 int deadthresh;
128 char *hostname;
129 int acregmin;
130 int acregmax;
131 int acdirmin;
132 int acdirmax;
133 };
134
135 struct nfs_args3 {
136 int version;
137 struct sockaddr *addr;
138 int addrlen;
139 int sotype;
140 int proto;
141 u_char *fh;
142 int fhsize;
143 int flags;
144 int wsize;
145 int rsize;
146 int readdirsize;
147 int timeo;
148 int retrans;
149 int maxgrouplist;
150 int readahead;
151 int leaseterm;
152 int deadthresh;
153 char *hostname;
154 };
155
156
157
158
159 #ifndef _KERNEL
160 #define NFSMNT_RESVPORT 0x00000000
161 #endif
162 #define NFSMNT_SOFT 0x00000001
163 #define NFSMNT_WSIZE 0x00000002
164 #define NFSMNT_RSIZE 0x00000004
165 #define NFSMNT_TIMEO 0x00000008
166 #define NFSMNT_RETRANS 0x00000010
167 #define NFSMNT_MAXGRPS 0x00000020
168 #define NFSMNT_INT 0x00000040
169 #define NFSMNT_NOCONN 0x00000080
170 #define NFSMNT_NQNFS 0x00000100
171 #define NFSMNT_NFSV3 0x00000200
172 #define NFSMNT_KERB 0x00000400
173 #define NFSMNT_DUMBTIMR 0x00000800
174 #define NFSMNT_LEASETERM 0x00001000
175 #define NFSMNT_READAHEAD 0x00002000
176 #define NFSMNT_DEADTHRESH 0x00004000
177 #ifdef _KERNEL
178 #define NFSMNT_NOAC 0x00008000
179 #endif
180 #define NFSMNT_RDIRPLUS 0x00010000
181 #define NFSMNT_READDIRSIZE 0x00020000
182
183
184 #define NFSMNT_ACREGMIN 0x00040000
185 #define NFSMNT_ACREGMAX 0x00080000
186 #define NFSMNT_ACDIRMIN 0x00100000
187 #define NFSMNT_ACDIRMAX 0x00200000
188
189
190 #define NFSMNT_INTERNAL 0xfffc0000
191 #define NFSMNT_HASWRITEVERF 0x00040000
192 #define NFSMNT_GOTPATHCONF 0x00080000
193 #define NFSMNT_GOTFSINFO 0x00100000
194 #define NFSMNT_MNTD 0x00200000
195 #define NFSMNT_DISMINPROG 0x00400000
196 #define NFSMNT_DISMNT 0x00800000
197 #define NFSMNT_SNDLOCK 0x01000000
198 #define NFSMNT_WANTSND 0x02000000
199 #define NFSMNT_RCVLOCK 0x04000000
200 #define NFSMNT_WANTRCV 0x08000000
201 #define NFSMNT_WAITAUTH 0x10000000
202 #define NFSMNT_HASAUTH 0x20000000
203 #define NFSMNT_WANTAUTH 0x40000000
204 #define NFSMNT_AUTHERR 0x80000000
205
206
207
208
209 struct msdosfs_args {
210 char *fspec;
211 struct export_args export_info;
212
213 uid_t uid;
214 gid_t gid;
215 mode_t mask;
216 int flags;
217 };
218
219
220
221
222 #define MSDOSFSMNT_SHORTNAME 0x01
223 #define MSDOSFSMNT_LONGNAME 0x02
224 #define MSDOSFSMNT_NOWIN95 0x04
225 #define MSDOSFSMNT_ALLOWDIRX 0x10
226
227
228
229
230 struct ntfs_args {
231 char *fspec;
232 struct export_args export_info;
233 uid_t uid;
234 gid_t gid;
235 mode_t mode;
236 u_long flag;
237 };
238
239
240
241
242 #define NTFS_MFLAG_CASEINS 0x00000001
243 #define NTFS_MFLAG_ALLNAMES 0x00000002
244
245
246 struct udf_args {
247 char *fspec;
248 u_int32_t lastblock;
249 };
250
251
252
253
254 struct procfs_args {
255 int version;
256 int flags;
257 };
258
259
260
261
262 #define PROCFS_ARGSVERSION 1
263 #define PROCFSMNT_LINUXCOMPAT 0x01
264
265
266
267
268
269
270 #define MFSNAMELEN 16
271 #define MNAMELEN 90
272
273
274 union mount_info {
275 struct ufs_args ufs_args;
276 struct mfs_args mfs_args;
277 struct nfs_args nfs_args;
278 struct iso_args iso_args;
279 struct procfs_args procfs_args;
280 struct msdosfs_args msdosfs_args;
281 struct ntfs_args ntfs_args;
282 char __align[160];
283 };
284
285
286 struct statfs {
287 u_int32_t f_flags;
288 int32_t f_bsize;
289 u_int32_t f_iosize;
290 u_int32_t f_blocks;
291 u_int32_t f_bfree;
292 int32_t f_bavail;
293 u_int32_t f_files;
294 u_int32_t f_ffree;
295 fsid_t f_fsid;
296 uid_t f_owner;
297 u_int32_t f_syncwrites;
298 u_int32_t f_asyncwrites;
299 u_int32_t f_ctime;
300 u_int32_t f_spare[3];
301 char f_fstypename[MFSNAMELEN];
302 char f_mntonname[MNAMELEN];
303 char f_mntfromname[MNAMELEN];
304 union mount_info mount_info;
305 };
306
307
308 struct ostatfs {
309 short f_type;
310 short f_flags;
311 long f_bsize;
312 long f_iosize;
313 long f_blocks;
314 long f_bfree;
315 long f_bavail;
316 long f_files;
317 long f_ffree;
318 fsid_t f_fsid;
319 uid_t f_owner;
320 long f_syncwrites;
321 long f_asyncwrites;
322 long f_spare[2];
323 char f_fstypename[MFSNAMELEN];
324 char f_mntonname[MNAMELEN];
325 char f_mntfromname[MNAMELEN];
326 };
327
328
329
330
331 #define MOUNT_FFS "ffs"
332 #define MOUNT_UFS MOUNT_FFS
333 #define MOUNT_NFS "nfs"
334 #define MOUNT_MFS "mfs"
335 #define MOUNT_MSDOS "msdos"
336 #define MOUNT_PORTAL "portal"
337 #define MOUNT_PROCFS "procfs"
338 #define MOUNT_AFS "afs"
339 #define MOUNT_CD9660 "cd9660"
340 #define MOUNT_EXT2FS "ext2fs"
341 #define MOUNT_NCPFS "ncpfs"
342 #define MOUNT_XFS "xfs"
343 #define MOUNT_NTFS "ntfs"
344 #define MOUNT_UDF "udf"
345
346
347
348
349
350
351 LIST_HEAD(vnodelst, vnode);
352
353 struct mount {
354 CIRCLEQ_ENTRY(mount) mnt_list;
355 const struct vfsops *mnt_op;
356 struct vfsconf *mnt_vfc;
357 struct vnode *mnt_vnodecovered;
358 struct vnode *mnt_syncer;
359 struct vnodelst mnt_vnodelist;
360 struct rwlock mnt_lock;
361 int mnt_flag;
362 int mnt_maxsymlinklen;
363 struct statfs mnt_stat;
364 void *mnt_data;
365 };
366
367
368
369
370
371
372 #define MNT_RDONLY 0x00000001
373 #define MNT_SYNCHRONOUS 0x00000002
374 #define MNT_NOEXEC 0x00000004
375 #define MNT_NOSUID 0x00000008
376 #define MNT_NODEV 0x00000010
377 #define MNT_ASYNC 0x00000040
378
379
380
381
382 #define MNT_EXRDONLY 0x00000080
383 #define MNT_EXPORTED 0x00000100
384 #define MNT_DEFEXPORTED 0x00000200
385 #define MNT_EXPORTANON 0x00000400
386 #define MNT_EXKERB 0x00000800
387
388
389
390
391 #define MNT_LOCAL 0x00001000
392 #define MNT_QUOTA 0x00002000
393 #define MNT_ROOTFS 0x00004000
394
395
396
397
398 #define MNT_NOATIME 0x00008000
399
400
401
402
403 #define MNT_VISFLAGMASK 0x0400ffff
404
405 #define MNT_BITS \
406 "\010\001RDONLY\002SYNCHRONOUS\003NOEXEC\004NOSUID\005NODEV" \
407 "\007ASYNC\010EXRDONLY\011EXPORTED\012DEFEXPORTED\013EXPORTANON" \
408 "\014EXKERB\015LOCAL\016QUOTA\017ROOTFS"
409
410
411
412
413 #define MNT_UPDATE 0x00010000
414 #define MNT_DELEXPORT 0x00020000
415 #define MNT_RELOAD 0x00040000
416 #define MNT_FORCE 0x00080000
417 #define MNT_WANTRDWR 0x02000000
418 #define MNT_SOFTDEP 0x04000000
419 #define MNT_DOOMED 0x08000000
420
421
422
423
424
425
426
427 #define VFS_GENERIC 0
428
429
430
431
432
433 #define VFS_MAXTYPENUM 1
434 #define VFS_CONF 2
435
436 #define CTL_VFSGENCTL_NAMES { \
437 { 0, 0 }, \
438 { "maxtypenum", CTLTYPE_INT }, \
439 { "conf", CTLTYPE_NODE } \
440 }
441
442
443
444
445
446
447 struct vfsconf {
448 const struct vfsops *vfc_vfsops;
449 char vfc_name[MFSNAMELEN];
450 int vfc_typenum;
451 int vfc_refcount;
452 int vfc_flags;
453 int (*vfc_mountroot)(void);
454 struct vfsconf *vfc_next;
455 };
456
457
458
459
460 #ifdef _KERNEL
461 #ifdef __STDC__
462 struct nameidata;
463 struct mbuf;
464 #endif
465
466 extern int maxvfsconf;
467 extern struct vfsconf *vfsconf;
468
469 struct vfsops {
470 int (*vfs_mount)(struct mount *mp, const char *path,
471 void *data,
472 struct nameidata *ndp, struct proc *p);
473 int (*vfs_start)(struct mount *mp, int flags,
474 struct proc *p);
475 int (*vfs_unmount)(struct mount *mp, int mntflags,
476 struct proc *p);
477 int (*vfs_root)(struct mount *mp, struct vnode **vpp);
478 int (*vfs_quotactl)(struct mount *mp, int cmds, uid_t uid,
479 caddr_t arg, struct proc *p);
480 int (*vfs_statfs)(struct mount *mp, struct statfs *sbp,
481 struct proc *p);
482 int (*vfs_sync)(struct mount *mp, int waitfor,
483 struct ucred *cred, struct proc *p);
484 int (*vfs_vget)(struct mount *mp, ino_t ino,
485 struct vnode **vpp);
486 int (*vfs_fhtovp)(struct mount *mp, struct fid *fhp,
487 struct vnode **vpp);
488 int (*vfs_vptofh)(struct vnode *vp, struct fid *fhp);
489 int (*vfs_init)(struct vfsconf *);
490 int (*vfs_sysctl)(int *, u_int, void *, size_t *, void *,
491 size_t, struct proc *);
492 int (*vfs_checkexp)(struct mount *mp, struct mbuf *nam,
493 int *extflagsp, struct ucred **credanonp);
494 };
495
496 #define VFS_MOUNT(MP, PATH, DATA, NDP, P) \
497 (*(MP)->mnt_op->vfs_mount)(MP, PATH, DATA, NDP, P)
498 #define VFS_START(MP, FLAGS, P) (*(MP)->mnt_op->vfs_start)(MP, FLAGS, P)
499 #define VFS_UNMOUNT(MP, FORCE, P) (*(MP)->mnt_op->vfs_unmount)(MP, FORCE, P)
500 #define VFS_ROOT(MP, VPP) (*(MP)->mnt_op->vfs_root)(MP, VPP)
501 #define VFS_QUOTACTL(MP,C,U,A,P) (*(MP)->mnt_op->vfs_quotactl)(MP, C, U, A, P)
502 #define VFS_STATFS(MP, SBP, P) (*(MP)->mnt_op->vfs_statfs)(MP, SBP, P)
503 #define VFS_SYNC(MP, WAIT, C, P) (*(MP)->mnt_op->vfs_sync)(MP, WAIT, C, P)
504 #define VFS_VGET(MP, INO, VPP) (*(MP)->mnt_op->vfs_vget)(MP, INO, VPP)
505 #define VFS_FHTOVP(MP, FIDP, VPP) \
506 (*(MP)->mnt_op->vfs_fhtovp)(MP, FIDP, VPP)
507 #define VFS_VPTOFH(VP, FIDP) (*(VP)->v_mount->mnt_op->vfs_vptofh)(VP, FIDP)
508 #define VFS_CHECKEXP(MP, NAM, EXFLG, CRED) \
509 (*(MP)->mnt_op->vfs_checkexp)(MP, NAM, EXFLG, CRED)
510 #endif
511
512
513
514
515
516
517 #define MNT_WAIT 1
518 #define MNT_NOWAIT 2
519 #define MNT_LAZY 3
520
521
522
523
524 struct fhandle {
525 fsid_t fh_fsid;
526 struct fid fh_fid;
527 };
528 typedef struct fhandle fhandle_t;
529
530 #ifdef _KERNEL
531 #include <net/radix.h>
532 #include <sys/socket.h>
533
534
535
536
537 struct netcred {
538 struct radix_node netc_rnodes[2];
539 int netc_exflags;
540 struct ucred netc_anon;
541 };
542
543
544
545
546 struct netexport {
547 struct netcred ne_defexported;
548 struct radix_node_head *ne_rtable[AF_MAX+1];
549 };
550 #endif
551
552 #ifdef _KERNEL
553
554
555
556 int vfs_busy(struct mount *, int);
557 #define VB_READ 0x01
558 #define VB_WRITE 0x02
559 #define VB_NOWAIT 0x04
560 #define VB_WAIT 0x08
561
562 int vfs_isbusy(struct mount *);
563 int vfs_mount_foreach_vnode(struct mount *, int (*func)(struct vnode *,
564 void *), void *);
565 void vfs_getnewfsid(struct mount *);
566 struct mount *vfs_getvfs(fsid_t *);
567 int vfs_mountedon(struct vnode *);
568 int vfs_mountroot(void);
569 int vfs_rootmountalloc(char *, char *, struct mount **);
570 void vfs_unbusy(struct mount *);
571 void vfs_unmountall(void);
572 extern CIRCLEQ_HEAD(mntlist, mount) mountlist;
573
574 struct mount *getvfs(fsid_t *);
575
576 int vfs_export(struct mount *, struct netexport *, struct export_args *);
577
578 struct netcred *vfs_export_lookup(struct mount *, struct netexport *,
579 struct mbuf *);
580 int vfs_allocate_syncvnode(struct mount *);
581 int speedup_syncer(void);
582
583 int vfs_syncwait(int);
584 void vfs_shutdown(void);
585 long makefstype(char *);
586 int dounmount(struct mount *, int, struct proc *, struct vnode *);
587 void vfsinit(void);
588 void vfs_bufstats(void);
589 int vfs_register(struct vfsconf *);
590 int vfs_unregister(struct vfsconf *);
591 #else
592
593 #ifndef _SYS_STAT_H_
594 struct stat;
595 #endif
596
597 __BEGIN_DECLS
598 int fstatfs(int, struct statfs *);
599 int getfh(const char *, fhandle_t *);
600 int getfsstat(struct statfs *, size_t, int);
601 int getmntinfo(struct statfs **, int);
602 int mount(const char *, const char *, int, void *);
603 int statfs(const char *, struct statfs *);
604 int unmount(const char *, int);
605 #if __BSD_VISIBLE
606 int fhopen(const fhandle_t *, int);
607 int fhstat(const fhandle_t *, struct stat *);
608 int fhstatfs(const fhandle_t *, struct statfs *);
609 #endif
610
611 __END_DECLS
612
613 #endif
614 #endif