#ifndef _SYS_MOUNT_H_
#define _SYS_MOUNT_H_
#include <sys/appleapiopts.h>
#include <sys/cdefs.h>
#include <sys/attr.h>
#ifndef KERNEL
#include <stdint.h>
#include <sys/ucred.h>
#include <sys/queue.h>
#else
#include <sys/kernel_types.h>
#endif
typedef struct fsid { int32_t val[2]; } fsid_t;
#define MFSNAMELEN 15
#define MNAMELEN 90
struct statfs {
short f_otype;
short f_oflags;
long f_bsize;
long f_iosize;
long f_blocks;
long f_bfree;
long f_bavail;
long f_files;
long f_ffree;
fsid_t f_fsid;
uid_t f_owner;
short f_reserved1;
short f_type;
long f_flags;
long f_reserved2[2];
char f_fstypename[MFSNAMELEN];
char f_mntonname[MNAMELEN];
char f_mntfromname[MNAMELEN];
#if COMPAT_GETFSSTAT
char f_reserved3[0];
long f_reserved4[0];
#else
char f_reserved3;
long f_reserved4[4];
#endif
};
#define MFSTYPENAMELEN 16
#pragma pack(4)
struct vfsstatfs {
uint32_t f_bsize;
size_t f_iosize;
uint64_t f_blocks;
uint64_t f_bfree;
uint64_t f_bavail;
uint64_t f_bused;
uint64_t f_files;
uint64_t f_ffree;
fsid_t f_fsid;
uid_t f_owner;
uint64_t f_flags;
char f_fstypename[MFSTYPENAMELEN];
char f_mntonname[MAXPATHLEN];
char f_mntfromname[MAXPATHLEN];
uint32_t f_fssubtype;
void *f_reserved[2];
};
#pragma pack()
#define VFSATTR_INIT(s) ((s)->f_supported = (s)->f_active = 0LL)
#define VFSATTR_SET_SUPPORTED(s, a) ((s)->f_supported |= VFSATTR_ ## a)
#define VFSATTR_IS_SUPPORTED(s, a) ((s)->f_supported & VFSATTR_ ## a)
#define VFSATTR_CLEAR_ACTIVE(s, a) ((s)->f_active &= ~VFSATTR_ ## a)
#define VFSATTR_IS_ACTIVE(s, a) ((s)->f_active & VFSATTR_ ## a)
#define VFSATTR_ALL_SUPPORTED(s) (((s)->f_active & (s)->f_supported) == (s)->f_active)
#define VFSATTR_WANTED(s, a) ((s)->f_active |= VFSATTR_ ## a)
#define VFSATTR_RETURN(s, a, x) do { (s)-> a = (x); VFSATTR_SET_SUPPORTED(s, a);} while(0)
#define VFSATTR_f_objcount (1LL<< 0)
#define VFSATTR_f_filecount (1LL<< 1)
#define VFSATTR_f_dircount (1LL<< 2)
#define VFSATTR_f_maxobjcount (1LL<< 3)
#define VFSATTR_f_bsize (1LL<< 4)
#define VFSATTR_f_iosize (1LL<< 5)
#define VFSATTR_f_blocks (1LL<< 6)
#define VFSATTR_f_bfree (1LL<< 7)
#define VFSATTR_f_bavail (1LL<< 8)
#define VFSATTR_f_bused (1LL<< 9)
#define VFSATTR_f_files (1LL<< 10)
#define VFSATTR_f_ffree (1LL<< 11)
#define VFSATTR_f_fsid (1LL<< 12)
#define VFSATTR_f_owner (1LL<< 13)
#define VFSATTR_f_capabilities (1LL<< 14)
#define VFSATTR_f_attributes (1LL<< 15)
#define VFSATTR_f_create_time (1LL<< 16)
#define VFSATTR_f_modify_time (1LL<< 17)
#define VFSATTR_f_access_time (1LL<< 18)
#define VFSATTR_f_backup_time (1LL<< 19)
#define VFSATTR_f_fssubtype (1LL<< 20)
#define VFSATTR_f_vol_name (1LL<< 21)
#define VFSATTR_f_signature (1LL<< 22)
#define VFSATTR_f_carbon_fsid (1LL<< 23)
#pragma pack(4)
struct vfs_attr {
uint64_t f_supported;
uint64_t f_active;
uint64_t f_objcount;
uint64_t f_filecount;
uint64_t f_dircount;
uint64_t f_maxobjcount;
uint32_t f_bsize;
size_t f_iosize;
uint64_t f_blocks;
uint64_t f_bfree;
uint64_t f_bavail;
uint64_t f_bused;
uint64_t f_files;
uint64_t f_ffree;
fsid_t f_fsid;
uid_t f_owner;
vol_capabilities_attr_t f_capabilities;
vol_attributes_attr_t f_attributes;
struct timespec f_create_time;
struct timespec f_modify_time;
struct timespec f_access_time;
struct timespec f_backup_time;
uint32_t f_fssubtype;
char *f_vol_name;
uint16_t f_signature;
uint16_t f_carbon_fsid;
};
#pragma pack()
#define MNT_RDONLY 0x00000001
#define MNT_SYNCHRONOUS 0x00000002
#define MNT_NOEXEC 0x00000004
#define MNT_NOSUID 0x00000008
#define MNT_NODEV 0x00000010
#define MNT_UNION 0x00000020
#define MNT_ASYNC 0x00000040
#define MNT_DONTBROWSE 0x00100000
#define MNT_IGNORE_OWNERSHIP 0x00200000
#define MNT_AUTOMOUNTED 0x00400000
#define MNT_JOURNALED 0x00800000
#define MNT_NOUSERXATTR 0x01000000
#define MNT_DEFWRITE 0x02000000
#define MNT_UNKNOWNPERMISSIONS MNT_IGNORE_OWNERSHIP
#define MNT_EXPORTED 0x00000100
#define MNT_LOCAL 0x00001000
#define MNT_QUOTA 0x00002000
#define MNT_ROOTFS 0x00004000
#define MNT_DOVOLFS 0x00008000
#define MNT_VISFLAGMASK (MNT_RDONLY | MNT_SYNCHRONOUS | MNT_NOEXEC | \
MNT_NOSUID | MNT_NODEV | MNT_UNION | \
MNT_ASYNC | MNT_EXPORTED | \
MNT_LOCAL | MNT_QUOTA | \
MNT_ROOTFS | MNT_DOVOLFS | MNT_DONTBROWSE | \
MNT_UNKNOWNPERMISSIONS | MNT_AUTOMOUNTED | MNT_JOURNALED | \
MNT_DEFWRITE)
#define MNT_UPDATE 0x00010000
#define MNT_RELOAD 0x00040000
#define MNT_FORCE 0x00080000
#define MNT_CMDFLAGS (MNT_UPDATE|MNT_RELOAD|MNT_FORCE)
#define VFS_GENERIC 0
#define VFS_NUMMNTOPS 1
#define VFS_MAXTYPENUM 1
#define VFS_CONF 2
#define VFS_SET_PACKAGE_EXTS 3
#define MNT_WAIT 1
#define MNT_NOWAIT 2
#ifndef KERNEL
struct mount;
typedef struct mount * mount_t;
struct vnode;
typedef struct vnode * vnode_t;
#endif
struct vfsconf {
struct vfsops *vfc_vfsops;
char vfc_name[MFSNAMELEN];
int vfc_typenum;
int vfc_refcount;
int vfc_flags;
int (*vfc_mountroot)(mount_t, vnode_t);
struct vfsconf *vfc_next;
};
struct vfsidctl {
int vc_vers;
fsid_t vc_fsid;
void *vc_ptr;
size_t vc_len;
u_int32_t vc_spare[12];
};
#define VFS_CTL_VERS1 0x01
#ifdef KERNEL
struct user_vfsconf {
user_addr_t vfc_vfsops;
char vfc_name[MFSNAMELEN];
int vfc_typenum;
int vfc_refcount;
int vfc_flags;
user_addr_t vfc_mountroot __attribute((aligned(8)));
user_addr_t vfc_next;
};
struct user_vfsidctl {
int vc_vers;
fsid_t vc_fsid;
user_addr_t vc_ptr __attribute((aligned(8)));
user_size_t vc_len;
u_int32_t vc_spare[12];
};
#endif
#define VFS_CTL_STATFS 0x00010001
#define VFS_CTL_UMOUNT 0x00010002
#define VFS_CTL_QUERY 0x00010003
#define VFS_CTL_NEWADDR 0x00010004
#define VFS_CTL_TIMEO 0x00010005
#define VFS_CTL_NOLOCKS 0x00010006
struct vfsquery {
u_int32_t vq_flags;
u_int32_t vq_spare[31];
};
#define VQ_NOTRESP 0x0001
#define VQ_NEEDAUTH 0x0002
#define VQ_LOWDISK 0x0004
#define VQ_MOUNT 0x0008
#define VQ_UNMOUNT 0x0010
#define VQ_DEAD 0x0020
#define VQ_ASSIST 0x0040
#define VQ_NOTRESPLOCK 0x0080
#define VQ_UPDATE 0x0100
#define VQ_FLAG0200 0x0200
#define VQ_FLAG0400 0x0400
#define VQ_FLAG0800 0x0800
#define VQ_FLAG1000 0x1000
#define VQ_FLAG2000 0x2000
#define VQ_FLAG4000 0x4000
#define VQ_FLAG8000 0x8000
#ifdef KERNEL
struct vfsioattr {
u_int32_t io_maxreadcnt;
u_int32_t io_maxwritecnt;
u_int32_t io_segreadcnt;
u_int32_t io_segwritecnt;
u_int32_t io_maxsegreadsize;
u_int32_t io_maxsegwritesize;
u_int32_t io_devblocksize;
void * io_reserved[3];
};
#define VFS_TBLTHREADSAFE 0x01
#define VFS_TBLFSNODELOCK 0x02
#define VFS_TBLNOTYPENUM 0x08
#define VFS_TBLLOCALVOL 0x10
#define VFS_TBL64BITREADY 0x20
struct vfs_fsentry {
struct vfsops * vfe_vfsops;
int vfe_vopcnt;
struct vnodeopv_desc ** vfe_opvdescs;
int vfe_fstypenum;
char vfe_fsname[MFSNAMELEN];
uint32_t vfe_flags;
void * vfe_reserv[2];
};
struct vfsops {
int (*vfs_mount)(struct mount *mp, vnode_t devvp, user_addr_t data, vfs_context_t context);
int (*vfs_start)(struct mount *mp, int flags, vfs_context_t context);
int (*vfs_unmount)(struct mount *mp, int mntflags, vfs_context_t context);
int (*vfs_root)(struct mount *mp, struct vnode **vpp, vfs_context_t context);
int (*vfs_quotactl)(struct mount *mp, int cmds, uid_t uid, caddr_t arg, vfs_context_t context);
int (*vfs_getattr)(struct mount *mp, struct vfs_attr *, vfs_context_t context);
int (*vfs_sync)(struct mount *mp, int waitfor, vfs_context_t context);
int (*vfs_vget)(struct mount *mp, ino64_t ino, struct vnode **vpp, vfs_context_t context);
int (*vfs_fhtovp)(struct mount *mp, int fhlen, unsigned char *fhp, struct vnode **vpp,
vfs_context_t context);
int (*vfs_vptofh)(struct vnode *vp, int *fhlen, unsigned char *fhp, vfs_context_t context);
int (*vfs_init)(struct vfsconf *);
int (*vfs_sysctl)(int *, u_int, user_addr_t, size_t *, user_addr_t, size_t, vfs_context_t context);
int (*vfs_setattr)(struct mount *mp, struct vfs_attr *, vfs_context_t context);
void *vfs_reserved[7];
};
#define VFS_RETURNED 0
#define VFS_RETURNED_DONE 1
#define VFS_CLAIMED 2
#define VFS_CLAIMED_DONE 3
__BEGIN_DECLS
extern int VFS_MOUNT(mount_t, vnode_t, user_addr_t, vfs_context_t);
extern int VFS_START(mount_t, int, vfs_context_t);
extern int VFS_UNMOUNT(mount_t, int, vfs_context_t);
extern int VFS_ROOT(mount_t, vnode_t *, vfs_context_t);
extern int VFS_QUOTACTL(mount_t, int, uid_t, caddr_t, vfs_context_t);
extern int VFS_SYNC(mount_t, int, vfs_context_t);
extern int VFS_VGET(mount_t, ino64_t, vnode_t *, vfs_context_t);
extern int VFS_FHTOVP(mount_t, int, unsigned char *, vnode_t *, vfs_context_t);
extern int VFS_VPTOFH(vnode_t, int *, unsigned char *, vfs_context_t);
int vfs_fsadd(struct vfs_fsentry *, vfstable_t *);
int vfs_fsremove(vfstable_t);
int vfs_iterate(int, int (*)(struct mount *, void *), void *);
uint64_t vfs_flags(mount_t);
void vfs_setflags(mount_t, uint64_t);
void vfs_clearflags(mount_t, uint64_t);
int vfs_issynchronous(mount_t);
int vfs_iswriteupgrade(mount_t);
int vfs_isupdate(mount_t);
int vfs_isreload(mount_t);
int vfs_isforce(mount_t);
int vfs_isrdonly(mount_t);
int vfs_isrdwr(mount_t);
int vfs_authopaque(mount_t);
int vfs_authopaqueaccess(mount_t);
void vfs_setauthopaque(mount_t);
void vfs_setauthopaqueaccess(mount_t);
void vfs_clearauthopaque(mount_t);
void vfs_clearauthopaqueaccess(mount_t);
int vfs_extendedsecurity(mount_t);
void vfs_setextendedsecurity(mount_t);
void vfs_clearextendedsecurity(mount_t);
void vfs_setlocklocal(mount_t);
uint32_t vfs_maxsymlen(mount_t);
void vfs_setmaxsymlen(mount_t, uint32_t);
void * vfs_fsprivate(mount_t);
void vfs_setfsprivate(mount_t, void *mntdata);
struct vfsstatfs * vfs_statfs(mount_t);
int vfs_update_vfsstat(mount_t, vfs_context_t);
int vfs_getattr(mount_t mp, struct vfs_attr *vfa, vfs_context_t ctx);
int vfs_setattr(mount_t mp, struct vfs_attr *vfa, vfs_context_t ctx);
int vfs_typenum(mount_t);
void vfs_name(mount_t, char *);
int vfs_devblocksize(mount_t);
void vfs_ioattr(mount_t, struct vfsioattr *);
void vfs_setioattr(mount_t, struct vfsioattr *);
int vfs_64bitready(mount_t);
int vfs_busy(mount_t, int);
void vfs_unbusy(mount_t);
void vfs_getnewfsid(struct mount *);
mount_t vfs_getvfs(fsid_t *);
mount_t vfs_getvfs_by_mntonname(u_char *);
int vfs_mountedon(struct vnode *);
void vfs_event_signal(fsid_t *, u_int32_t, intptr_t);
void vfs_event_init(void);
__END_DECLS
#endif
#ifndef KERNEL
#define NFS_MAX_FH_SIZE 64
#define NFSV2_MAX_FH_SIZE 32
struct fhandle {
int fh_len;
unsigned char fh_data[NFS_MAX_FH_SIZE];
};
typedef struct fhandle fhandle_t;
__BEGIN_DECLS
int fhopen(const struct fhandle *, int);
int fstatfs(int, struct statfs *);
int getfh(const char *, fhandle_t *);
int getfsstat(struct statfs *, int, 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);
int getvfsbyname(const char *, struct vfsconf *);
__END_DECLS
#endif
#endif