/*
- * Copyright (c) 2000-2007 Apple Inc. All rights reserved.
+ * Copyright (c) 2000-2008 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
#ifndef _SYS_VNODE_INTERNAL_H_
#define _SYS_VNODE_INTERNAL_H_
-#define INTERIM_FSNODE_LOCK 1
-
#include <sys/appleapiopts.h>
#include <sys/cdefs.h>
#include <sys/queue.h>
LIST_HEAD(, namecache) v_nclinks; /* name cache entries that name this vnode */
LIST_HEAD(, namecache) v_ncchildren; /* name cache entries that regard us as there parent */
vnode_t v_defer_reclaimlist; /* in case we have to defer the reclaim to avoid recursion */
- u_long v_listflag; /* flags protected by the vnode_list_lock (see below) */
- u_long v_flag; /* vnode flags (see below) */
- u_short v_lflag; /* vnode local and named ref flags */
- u_char v_iterblkflags; /* buf iterator flags */
- u_char v_references; /* number of times io_count has been granted */
+ uint32_t v_listflag; /* flags protected by the vnode_list_lock (see below) */
+ uint32_t v_flag; /* vnode flags (see below) */
+ uint16_t v_lflag; /* vnode local and named ref flags */
+ uint8_t v_iterblkflags; /* buf iterator flags */
+ uint8_t v_references; /* number of times io_count has been granted */
int32_t v_kusecount; /* count of in-kernel refs */
int32_t v_usecount; /* reference count of users */
int32_t v_iocount; /* iocounters */
void * v_owner; /* act that owns the vnode */
- u_short v_type; /* vnode type */
- u_short v_tag; /* type of underlying data */
- int v_id; /* identity of vnode contents */
+ uint16_t v_type; /* vnode type */
+ uint16_t v_tag; /* type of underlying data */
+ uint32_t v_id; /* identity of vnode contents */
union {
struct mount *vu_mountedhere;/* ptr to mounted vfs (VDIR) */
struct socket *vu_socket; /* unix ipc (VSOCK) */
} v_un;
struct buflists v_cleanblkhd; /* clean blocklist head */
struct buflists v_dirtyblkhd; /* dirty blocklist head */
+ struct klist v_knotes; /* knotes attached to this vnode */
/*
* the following 4 fields are protected
* by the name_cache_lock held in
/*
* back to the vnode lock for protection
*/
- long v_numoutput; /* num of writes in progress */
- long v_writecount; /* reference count of writers */
+ int32_t v_numoutput; /* num of writes in progress */
+ int32_t v_writecount; /* reference count of writers */
const char *v_name; /* name component of the vnode */
vnode_t v_parent; /* pointer to parent vnode */
-#ifdef INTERIM_FSNODE_LOCK
struct lockf *v_lockf; /* advisory lock list head */
+#ifndef __LP64__
struct unsafe_fsnode *v_unsafefs; /* pointer to struct used to lock */
-#endif /* vnodes on unsafe filesystems */
+#else
+ int32_t v_reserved1;
+ int32_t v_reserved2;
+#endif /* __LP64__ */
int (**v_op)(void *); /* vnode operations vector */
mount_t v_mount; /* ptr to vfs we are in */
void * v_data; /* private data for fs */
*/
#define VL_SUSPENDED 0x0001 /* vnode is suspended */
#define VL_DRAIN 0x0002 /* vnode is being drained */
-#define VL_TERMINATE 0x0004 /* vnode is marked for termination */
-#define VL_TERMWANT 0x0008 /* vnode is marked for termination */
-#define VL_DEAD 0x0010 /* vnode is dead and completed recycle */
-#define VL_MARKTERM 0x0020 /* vnode is dead and completed recycle */
+#define VL_TERMINATE 0x0004 /* vnode is in the process of being recycled */
+#define VL_TERMWANT 0x0008 /* there's a waiter for recycle finish (vnode_getiocount)*/
+#define VL_DEAD 0x0010 /* vnode is dead, cleaned of filesystem-specific info */
+#define VL_MARKTERM 0x0020 /* vnode should be recycled when no longer referenced */
#define VL_MOUNTDEAD 0x0040 /* v_moutnedhere is dead */
#define VL_NEEDINACTIVE 0x0080 /* delay VNOP_INACTIVE until iocount goes to 0 */
#define VL_LABELWAIT 0x0200 /* vnode is marked for labeling */
#define VL_LABELED 0x0400 /* vnode is labeled */
#define VL_LWARNED 0x0800
+#define VL_HASSTREAMS 0x1000 /* vnode has had at least one associated named stream vnode (may not have one any longer) */
#define VNAMED_UBC 0x2000 /* ubc named reference */
#define VNAMED_MOUNT 0x4000 /* mount point named reference */
#define VDEVFLUSH 0x000040 /* device vnode after vflush */
#define VMOUNT 0x000080 /* mount operation in progress */
#define VBWAIT 0x000100 /* waiting for output to complete */
-#define VALIASED 0x000200 /* vnode has an alias */
+ /* Free slot here after removing VALIASED for radar #5971707 */
#define VNOCACHE_DATA 0x000400 /* don't keep data cached once it's been consumed */
#define VSTANDARD 0x000800 /* vnode obtained from common pool */
#define VAGE 0x001000 /* Insert vnode at head of free list */
#define VRAOFF 0x002000 /* read ahead disabled */
#define VNCACHEABLE 0x004000 /* vnode is allowed to be put back in name cache */
-#define VUINACTIVE 0x008000 /* UBC vnode is on inactive list */
+#if NAMEDSTREAMS
+#define VISSHADOW 0x008000 /* vnode is a shadow file */
+#endif
#define VSWAP 0x010000 /* vnode is being used as swapfile */
#define VTHROTTLED 0x020000 /* writes or pageouts have been throttled */
/* wakeup tasks waiting when count falls below threshold */
*/
extern struct vnode *rootvnode; /* root (i.e. "/") vnode */
+#ifdef CONFIG_IMGSRC_ACCESS
+extern struct vnode *imgsrc_rootvnode;
+#endif /* CONFIG_IMGSRC_ACCESS */
+
/*
* Mods for exensibility.
struct ostat;
#define BUILDPATH_NO_FS_ENTER 0x1 /* Use cache values, do not enter file system */
+#define BUILDPATH_CHECKACCESS 0x2 /* Check if parents have search rights */
int build_path(vnode_t first_vp, char *buff, int buflen, int *outlen, int flags, vfs_context_t ctx);
int bdevvp(dev_t dev, struct vnode **vpp);
__private_extern__ int is_package_name(const char *name, int len);
-__private_extern__ int set_package_extensions_table(void *data, int nentries, int maxwidth);
-int vn_rdwr(enum uio_rw rw, struct vnode *vp, caddr_t base,
- int len, off_t offset, enum uio_seg segflg, int ioflg,
- kauth_cred_t cred, int *aresid, struct proc *p);
+__private_extern__ int set_package_extensions_table(user_addr_t data, int nentries, int maxwidth);
int vn_rdwr_64(enum uio_rw rw, struct vnode *vp, uint64_t base,
int64_t len, off_t offset, enum uio_seg segflg,
- int ioflg, kauth_cred_t cred, int *aresid,
+ int ioflg, kauth_cred_t cred, int64_t *aresid,
struct proc *p);
#if CONFIG_MACF
int vn_setlabel (struct vnode *vp, struct label *intlabel,
vfs_context_t context);
#endif
void fifo_printinfo(struct vnode *vp);
-int vn_lock(struct vnode *vp, int flags, struct proc *p);
int vn_open(struct nameidata *ndp, int fmode, int cmode);
int vn_open_modflags(struct nameidata *ndp, int *fmode, int cmode);
int vn_open_auth(struct nameidata *ndp, int *fmode, struct vnode_attr *);
int vn_close(vnode_t, int flags, vfs_context_t ctx);
+void lock_vnode_and_post(vnode_t, int);
+
+#define post_event_if_success(_vp, _error, _event) \
+ do { \
+ if (0 == (_error)) { \
+ lock_vnode_and_post((_vp), (_event)); \
+ } \
+ } while (0)
+
+
+
#define VN_CREATE_NOAUTH (1<<0)
#define VN_CREATE_NOINHERIT (1<<1)
#define VN_CREATE_UNION (1<<2)
int default_setxattr(vnode_t, const char *, uio_t, int, vfs_context_t);
int default_removexattr(vnode_t, const char *, int, vfs_context_t);
+int check_appledouble_header(vnode_t, vfs_context_t);
+
#if NAMEDSTREAMS
errno_t vnode_getnamedstream(vnode_t, vnode_t *, const char *, enum nsoperation, int, vfs_context_t);
errno_t vnode_makenamedstream(vnode_t, vnode_t *, const char *, int, vfs_context_t);
errno_t vnode_relenamedstream(vnode_t vp, vnode_t svp, vfs_context_t context);
#endif
-int vn_path_package_check(vnode_t vp, char *path, int pathlen, int *component);
void nchinit(void) __attribute__((section("__TEXT, initcode")));
-int resize_namecache(u_int newsize);
+int resize_namecache(uint32_t newsize);
void name_cache_lock_shared(void);
void name_cache_lock(void);
void name_cache_unlock(void);
void cache_enter_with_gen(vnode_t dvp, vnode_t vp, struct componentname *cnp, int gen);
+const char *cache_enter_create(vnode_t dvp, vnode_t vp, struct componentname *cnp);
-const char *vnode_getname(vnode_t vp);
-void vnode_putname(const char *name);
-
-vnode_t vnode_getparent(vnode_t vp);
-
-int vn_pathconf(vnode_t, int, register_t *, vfs_context_t);
+int vn_pathconf(vnode_t, int, int32_t *, vfs_context_t);
#define vnode_lock_convert(v) lck_mtx_convert_spin(&(v)->v_lock)
int vnode_ref_ext(vnode_t, int);
void vnode_rele_ext(vnode_t, int, int);
void vnode_rele_internal(vnode_t, int, int, int);
-int vnode_getwithref(vnode_t);
+#ifdef BSD_KERNEL_PRIVATE
+int vnode_getalways(vnode_t);
+int vget_internal(vnode_t, int, int);
+#endif /* BSD_KERNEL_PRIVATE */
int vnode_get_locked(vnode_t);
int vnode_put_locked(vnode_t);
int vnode_issock(vnode_t);
+int vnode_isaliased(vnode_t);
void unlock_fsnode(vnode_t, int *);
int lock_fsnode(vnode_t, int *);
errno_t vnode_size(vnode_t, off_t *, vfs_context_t);
errno_t vnode_setsize(vnode_t, off_t, int ioflag, vfs_context_t);
int vnode_setattr_fallback(vnode_t vp, struct vnode_attr *vap, vfs_context_t ctx);
+int vnode_isspec(vnode_t vp);
void vn_setunionwait(vnode_t);
void vn_checkunionwait(vnode_t);
void SPECHASH_LOCK(void);
void SPECHASH_UNLOCK(void);
-int check_cdevmounted(dev_t, enum vtype, int *);
-
void vnode_authorize_init(void) __attribute__((section("__TEXT, initcode")));
-void vfsinit(void);
+void vfsinit(void) __attribute__((section("__TEXT, initcode")));
+void vnode_lock(vnode_t);
+void vnode_unlock(vnode_t);
/*
* XXX exported symbols; should be static
*/
void vfs_op_init(void) __attribute__((section("__TEXT, initcode")));
void vfs_opv_init(void) __attribute__((section("__TEXT, initcode")));
-int vfs_sysctl(int *name, u_int namelen, user_addr_t oldp, size_t *oldlenp,
+int vfs_sysctl(int *name, uint32_t namelen, user_addr_t oldp, size_t *oldlenp,
user_addr_t newp, size_t newlen, struct proc *p);
int sysctl_vnode(struct sysctl_oid *oidp, void *arg1, int arg2, struct sysctl_req *req);
+#ifdef BSD_KERNEL_PRIVATE
+void vnode_knoteupdate(struct knote *kn);
+void vnode_setneedinactive(vnode_t);
+int vnode_hasnamedstreams(vnode_t); /* Does this vnode have associated named streams? */
+#endif
+
#endif /* !_SYS_VNODE_INTERNAL_H_ */