vfs.h revision d7de0cea9111a93d26efcfa259585dabbde02eea
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
*/
/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
* Portions of this source code were derived from Berkeley 4.3 BSD
* under license from the Regents of the University of California.
*/
#ifndef _SYS_VFS_H
#define _SYS_VFS_H
#ifdef __cplusplus
extern "C" {
#endif
/*
* Data associated with mounted file systems.
*/
/*
* Operations vector. This is used internal to the kernel; file systems
* supply their list of operations via vfs_setfsops().
*/
/*
* File system identifier. Should be unique (at least per machine).
*/
typedef struct {
} fsid_t;
/*
* File identifier. Should be unique per filesystem on a single
* machine. This is typically called by a stateless file server
* in order to generate "file handles".
*
* Do not change the definition of struct fid ... fid_t without
* letting the CacheFS group know about it! They will have to do at
* least two things, in the same change that changes this structure:
* 2. put the old version # in the canupgrade array
* This is necessary because CacheFS stores FIDs on disk.
*
* Many underlying file systems cast a struct fid into other
* file system dependent structures which may require 4 byte alignment.
* Because a fid starts with a short it may not be 4 byte aligned, the
* fid_pad will force the alignment.
*/
#define MAXFIDSZ 64
#define OLD_MAXFIDSZ 16
typedef struct fid {
union {
long fid_pad;
struct {
} _fid;
} un;
} fid_t;
#ifdef _SYSCALL32
/*
* Solaris 64 - use old-style cache format with 32-bit aligned fid for on-disk
* struct compatibility.
*/
typedef struct fid32 {
union {
struct {
} _fid;
} un;
} fid32_t;
#else /* not _SYSCALL32 */
#endif /* _SYSCALL32 */
/*
* Structure defining a mount option for a filesystem.
* option names are found in mntent.h
*/
typedef struct mntopt {
char *mo_name; /* option name */
char **mo_cancel; /* list of options cancelled by this one */
char *mo_arg; /* argument string for this option */
int mo_flags; /* flags for this mount option */
void *mo_data; /* filesystem specific data */
} mntopt_t;
/*
* Flags that apply to mount options
*/
/*
* Structure holding mount option strings for the mounted file system.
*/
typedef struct mntopts {
} mntopts_t;
/*
* The kstat structures associated with the vopstats are kept in an
* AVL tree. This is to avoid the case where a file system does not
* use a unique fsid_t for each vfs (e.g., namefs). In order to do
* this, we need a structure that the AVL tree can use that also
* references the kstat.
* Note that the vks_fsid is generated from the value reported by
* VFS_STATVFS().
*/
typedef struct vskstat_anchor {
} vsk_anchor_t;
extern avl_tree_t vskstat_tree;
extern kmutex_t vskstat_tree_lock;
/*
* Private vfs data, NOT to be used by a file system implementation.
*/
#define VFS_FEATURE_MAXSZ 4
typedef struct vfs_impl {
/* Counted array - Bitmap of vfs features */
/*
* Support for statistics on the vnode operations
*/
} vfs_impl_t;
/*
* Structure per mounted file system. Each mounted file system has
* an array of operations and an instance record.
*
* The file systems are kept on a doubly linked circular list headed by
* "rootvfs".
* File system implementations should not access this list;
* it's intended for use only in the kernel's vfs layer.
*
* Each zone also has its own list of mounts, containing filesystems mounted
* somewhere within the filesystem tree rooted at the zone's rootpath. The
* list is doubly linked to match the global list.
*
* mnttab locking: the in-kernel mnttab uses the vfs_mntpt, vfs_resource and
* vfs_mntopts fields in the vfs_t. mntpt and resource are refstr_ts that
* are set at mount time and can only be modified during a remount.
* It is safe to read these fields if you can prevent a remount on the vfs,
* or through the convenience funcs vfs_getmntpoint() and vfs_getresource().
* The mntopts field may only be accessed through the provided convenience
* functions, as it is protected by the vfs list lock. Modifying a mount
* option requires grabbing the vfs list write lock, which can be a very
* high latency lock.
*/
typedef struct vfs {
/* vfs_op should not be used directly. Accessor functions are provided */
int vfs_fstype; /* file system type index */
void *vfs_data; /* private data */
/*
* Zones support. Note that the zone that "owns" the mount isn't
* necessarily the same as the zone in which the zone is visible.
* That is, vfs_zone and (vfs_zone_next|vfs_zone_prev) may refer to
* different zones.
*/
} vfs_t;
/*
* VFS flags.
*/
#define VFS_NORESOURCE "unspecified_resource"
#define VFS_NOMNTPT "unspecified_mountpoint"
/*
* VFS features are implemented as bits set in the vfs_t.
* The vfs_feature_t typedef is a 64-bit number that will translate
* into an element in an array of bitmaps and a bit in that element.
* Developers must not depend on the implementation of this and
* need to use vfs_has_feature()/vfs_set_feature() routines.
*/
typedef uint64_t vfs_feature_t;
#define VFSFT_ZEROCOPY_SUPPORTED 0x100000200
/* Support loaning /returning cache buffer */
/*
* Argument structure for mount(2).
*
*
* Note that if the MS_SYSSPACE bit is set in flags, the pointer fields in
* this structure are to be interpreted as kernel addresses. File systems
* should be prepared for this possibility.
*/
struct mounta {
char *spec;
char *dir;
int flags;
char *fstype;
char *dataptr;
int datalen;
char *optptr;
int optlen;
};
/*
* Reasons for calling the vfs_mountroot() operation.
*/
typedef enum whymountroot whymountroot_t;
/*
* Reasons for calling the VFS_VNSTATE():
*/
enum vntrans {
};
/*
* VFS_OPS defines all the vfs operations. It is used to define
* the vfsops structure (below) and the fs_func_p union (vfs_opreg.h).
*/
#define VFS_OPS \
void (*vfs_freevfs)(vfs_t *); \
/*
* Operations supported on virtual file system.
*/
struct vfsops {
VFS_OPS; /* Signature of all vfs operations (vfsops) */
};
extern void fsop_freefs(vfs_t *);
extern int fsop_sync_by_kind(int, short, cred_t *);
#define VFSNAME_MOUNT "mount"
#define VFSNAME_UNMOUNT "unmount"
#define VFSNAME_ROOT "root"
#define VFSNAME_STATVFS "statvfs"
#define VFSNAME_SYNC "sync"
#define VFSNAME_VGET "vget"
#define VFSNAME_MOUNTROOT "mountroot"
#define VFSNAME_FREEVFS "freevfs"
#define VFSNAME_VNSTATE "vnstate"
/*
* Filesystem type switch table.
*/
typedef struct vfssw {
char *vsw_name; /* type name -- max len _ST_FSTYPSZ */
int (*vsw_init) (int, char *);
/* init routine (for non-loadable fs only) */
int vsw_flag; /* flags */
} vfssw_t;
/*
* Filesystem type definition record. All file systems must export a record
* of this type through their modlfs structure. N.B., changing the version
*/
typedef struct vfsdef_v5 {
int def_version; /* structure version, must be first */
char *name; /* filesystem type name */
int (*init) (int, char *); /* init routine */
int flags; /* filesystem flags */
} vfsdef_v5;
enum {
VFSDEF_VERSION = 5
};
/*
* flags for vfssw and vfsdef
*/
/*
* A flag for vfs_setpath().
*/
#if defined(_KERNEL)
/*
* Public operations.
*/
struct umounta;
struct statvfsa;
struct fstatvfsa;
void vfs_freevfsops(vfsops_t *);
int vfs_freevfsops_by_type(int);
void vn_reclaim(vnode_t *);
void vn_invalid(vnode_t *);
int rootconf(void);
int svm_rootconf(void);
struct vfs **);
void vfs_lock_wait(struct vfs *);
void vfs_rlock_wait(struct vfs *);
void vfs_unlock(struct vfs *);
int vfs_lock_held(struct vfs *);
void sync(void);
void vfs_sync(int);
void vfs_mountroot(void);
void vfs_remove(struct vfs *);
/* VFS feature routines */
/* The following functions are not for general use by filesystems */
void vfs_createopttbl(mntopts_t *, const char *);
void vfs_freeopttbl(mntopts_t *);
void vfs_parsemntopts(mntopts_t *, char *, int);
int vfs_buildoptionstr(const mntopts_t *, char *, int);
void vfs_mnttab_modtimeupd(void);
void vfs_clearmntopt(struct vfs *, const char *);
void vfs_setmntopt(struct vfs *, const char *, const char *, int);
int vfs_optionisset(const struct vfs *, const char *, char **);
void vfs_syncall(void);
void vfs_syncprogress(void);
void vfsinit(void);
void vfs_unmountall(void);
void vfs_delmip(struct vfs *);
int vfs_devismounted(dev_t);
int vfs_opsinuse(vfsops_t *);
struct vfs *vfs_mntpoint2vfsp(const char *);
struct vfssw *allocate_vfssw(const char *);
struct vfssw *vfs_getvfssw(const char *);
struct vfssw *vfs_getvfsswbyname(const char *);
void vfs_refvfssw(struct vfssw *);
void vfs_unrefvfssw(struct vfssw *);
void vfs_mnttab_modtime(timespec_t *);
void vfs_list_lock(void);
void vfs_list_read_lock(void);
void vfs_list_unlock(void);
void vfs_list_add(struct vfs *);
void vfs_list_remove(struct vfs *);
void fs_freevfs(vfs_t *);
int vfs_zone_change_safe(vfs_t *);
#define VFS_ON_LIST(vfsp) \
/*
* Globals.
*/
extern krwlock_t vfssw_lock;
extern char rootfstype[]; /* name of root fstype */
extern const int nfstype; /* # of elements in vfssw array */
/*
* The following variables are private to the the kernel's vfs layer. File
* system implementations should not access them.
*/
typedef struct {
} rvfs_t;
extern int vfshsz; /* # of elements in rvfs_head array */
#endif /* defined(_KERNEL) */
}
}
}
/*
* VFS_SYNC flags.
*/
#ifdef __cplusplus
}
#endif
#endif /* _SYS_VFS_H */