summaryrefslogtreecommitdiffstats
path: root/sys/fs/coda/coda.h
diff options
context:
space:
mode:
authortjr <tjr@FreeBSD.org>2003-09-07 07:43:10 +0000
committertjr <tjr@FreeBSD.org>2003-09-07 07:43:10 +0000
commitffc45a6f38ccebcfc3c288c480c7d4b50ce07097 (patch)
treec3cf2ae6864b0278a40f0dfa5991f2f8900c75eb /sys/fs/coda/coda.h
parent0e8da904ef6c53f55935dad56701ad688b7b737c (diff)
downloadFreeBSD-src-ffc45a6f38ccebcfc3c288c480c7d4b50ce07097.zip
FreeBSD-src-ffc45a6f38ccebcfc3c288c480c7d4b50ce07097.tar.gz
Add support for the Coda 6.x venus<->kernel interface. This extends
FIDs to be 128-bits wide and adds support for realms. Add a new CODA_COMPAT_5 option, which requests support for the old Coda 5.x interface instead of the new one. Create a new coda5.ko module that supports the 5.x interface, and make the existing coda.ko module use the new 6.x interface. These modules cannot both be loaded at the same time. Obtained from: Jan Harkes & the coda-6.0.2 distribution, NetBSD (drochner) (CODA_COMPAT_5 option).
Diffstat (limited to 'sys/fs/coda/coda.h')
-rw-r--r--sys/fs/coda/coda.h298
1 files changed, 181 insertions, 117 deletions
diff --git a/sys/fs/coda/coda.h b/sys/fs/coda/coda.h
index 2e59cfc..e7f1e0d 100644
--- a/sys/fs/coda/coda.h
+++ b/sys/fs/coda/coda.h
@@ -41,7 +41,7 @@
#ifndef _CODA_HEADER_
#define _CODA_HEADER_
-
+#include "opt_coda.h" /* for COMPAT_CODA_5 option */
/* Catch new _KERNEL defn for NetBSD */
#ifdef __NetBSD__
@@ -162,59 +162,70 @@ struct venus_dirent {
#endif
-#ifndef _FID_T_
-#define _FID_T_ 1
-typedef u_long VolumeId;
-typedef u_long VnodeId;
-typedef u_long Unique_t;
-typedef u_long FileVersion;
-#endif
-
-#ifndef _VICEFID_T_
-#define _VICEFID_T_ 1
-typedef struct ViceFid {
- VolumeId Volume;
- VnodeId Vnode;
- Unique_t Unique;
-} ViceFid;
-#endif /* VICEFID */
+#ifdef CODA_COMPAT_5
+typedef struct {
+ u_long Volume;
+ u_long Vnode;
+ u_long Unique;
+} CodaFid;
-#ifdef __linux__
-static __inline__ ino_t coda_f2i(struct ViceFid *fid)
+static __inline__ ino_t coda_f2i(CodaFid *fid)
{
- if ( ! fid )
- return 0;
- if (fid->Vnode == 0xfffffffe || fid->Vnode == 0xffffffff)
- return ((fid->Volume << 20) | (fid->Unique & 0xfffff));
- else
- return (fid->Unique + (fid->Vnode<<10) + (fid->Volume<<20));
+ if (!fid) return 0;
+ return (fid->Unique + (fid->Vnode<<10) + (fid->Volume<<20));
}
-
-#else
-#define coda_f2i(fid)\
- ((fid) ? ((fid)->Unique + ((fid)->Vnode<<10) + ((fid)->Volume<<20)) : 0)
-#endif
+static __inline__ char * coda_f2s(CodaFid *fid)
+{
+ static char fid_str [35];
+ snprintf (fid_str, 35, "[%lx.%lx.%lx]", fid->Volume,
+ fid->Vnode, fid->Unique);
+ return fid_str;
+}
+
+static __inline__ int coda_fid_eq (CodaFid *fid1, CodaFid *fid2)
+{
+ return (fid1->Volume == fid2->Volume &&
+ fid1->Vnode == fid2->Vnode &&
+ fid1->Unique == fid2->Unique);
+}
+
+struct coda_cred {
+ u_int32_t cr_uid, cr_euid, cr_suid, cr_fsuid; /* Real, efftve, set, fs uid*/
+ u_int32_t cr_groupid, cr_egid, cr_sgid, cr_fsgid; /* same for groups */
+};
-#ifndef __BIT_TYPES_DEFINED__
-#define u_int32_t unsigned int
-#endif
+#else /* CODA_COMPAT_5 */
+typedef struct {
+ u_int32_t opaque[4];
+} CodaFid;
-#ifndef _VUID_T_
-#define _VUID_T_
-typedef u_int32_t vuid_t;
-typedef u_int32_t vgid_t;
-#endif /*_VUID_T_ */
+static __inline__ ino_t coda_f2i(CodaFid *fid)
+{
+ if ( ! fid )
+ return 0;
+ return (fid->opaque[3] ^ (fid->opaque[2]<<10) ^ (fid->opaque[1]<<20) ^ fid->opaque[0]);
+}
+
+static __inline__ char * coda_f2s(CodaFid *fid)
+ {
+ static char fid_str [35];
+ snprintf (fid_str, 35, "[%x.%x.%x.%x]", fid->opaque[0],
+ fid->opaque[1], fid->opaque[2], fid->opaque[3]);
+ return fid_str;
+ }
+
+static __inline__ int coda_fid_eq (CodaFid *fid1, CodaFid *fid2)
+{
+ return (fid1->opaque[0] == fid2->opaque[0] &&
+ fid1->opaque[1] == fid2->opaque[1] &&
+ fid1->opaque[2] == fid2->opaque[2] &&
+ fid1->opaque[3] == fid2->opaque[3]);
+}
-#ifndef _CODACRED_T_
-#define _CODACRED_T_
-struct coda_cred {
- vuid_t cr_uid, cr_euid, cr_suid, cr_fsuid; /* Real, efftve, set, fs uid*/
- vgid_t cr_groupid, cr_egid, cr_sgid, cr_fsgid; /* same for groups */
-};
-#endif
+#endif /* CODA_COMPAT_5 */
#ifndef _VENUS_VATTR_T_
#define _VENUS_VATTR_T_
@@ -227,8 +238,8 @@ struct coda_vattr {
int va_type; /* vnode type (for create) */
u_short va_mode; /* files access mode and type */
short va_nlink; /* number of references to file */
- vuid_t va_uid; /* owner user id */
- vgid_t va_gid; /* owner group id */
+ uid_t va_uid; /* owner user id */
+ gid_t va_gid; /* owner group id */
long va_fileid; /* file id */
u_quad_t va_size; /* file size in bytes */
long va_blocksize; /* blocksize preferred for i/o */
@@ -244,12 +255,21 @@ struct coda_vattr {
#endif
+/* structure used by CODA_STATFS for getting cache information from venus */
+struct coda_statfs {
+ int32_t f_blocks;
+ int32_t f_bfree;
+ int32_t f_bavail;
+ int32_t f_files;
+ int32_t f_ffree;
+};
+
/*
* Kernel <--> Venus communications.
*/
#define CODA_ROOT 2
-#define CODA_SYNC 3
+#define CODA_OPEN_BY_FD 3
#define CODA_OPEN 4
#define CODA_CLOSE 5
#define CODA_IOCTL 6
@@ -279,7 +299,8 @@ struct coda_vattr {
#define CODA_OPEN_BY_PATH 31
#define CODA_RESOLVE 32
#define CODA_REINTEGRATE 33
-#define CODA_NCALLS 34
+#define CODA_STATFS 34
+#define CODA_NCALLS 35
#define DOWNCALL(opcode) (opcode >= CODA_REPLACE && opcode <= CODA_PURGEFID)
@@ -293,21 +314,36 @@ struct coda_vattr {
#define CODA_KERNEL_VERSION 0
/* The old venus 4.6 compatible interface */
#define CODA_KERNEL_VERSION 1
-#endif
+#endif /* realms/cells */
+#ifdef CODA_COMPAT_5
/* venus_lookup gets an extra parameter to aid windows.*/
#define CODA_KERNEL_VERSION 2
+#else
+ /* 128-bit fids for realms */
+#define CODA_KERNEL_VERSION 3
+#endif
/*
* Venus <-> Coda RPC arguments
*/
+#ifdef CODA_COMPAT_5
struct coda_in_hdr {
unsigned long opcode;
- unsigned long unique; /* Keep multiple outstanding msgs distinct */
- u_short pid; /* Common to all */
- u_short pgid; /* Common to all */
+ unsigned long unique; /* Keep multiple outstanding msgs distinct */
+ u_short pid; /* Common to all */
+ u_short pgid; /* Common to all */
u_short sid; /* Common to all */
- struct coda_cred cred; /* Common to all */
+ struct coda_cred cred; /* Common to all */
};
+#else
+struct coda_in_hdr {
+ u_int32_t opcode;
+ u_int32_t unique; /* Keep multiple outstanding msgs distinct */
+ pid_t pid; /* Common to all */
+ pid_t pgid; /* Common to all */
+ uid_t uid; /* Common to all */
+};
+#endif
/* Really important that opcode and unique are 1st two fields! */
struct coda_out_hdr {
@@ -319,7 +355,7 @@ struct coda_out_hdr {
/* coda_root: NO_IN */
struct coda_root_out {
struct coda_out_hdr oh;
- ViceFid VFid;
+ CodaFid Fid;
};
struct coda_root_in {
@@ -332,7 +368,7 @@ struct coda_root_in {
/* coda_open: */
struct coda_open_in {
struct coda_in_hdr ih;
- ViceFid VFid;
+ CodaFid Fid;
int flags;
};
@@ -346,7 +382,7 @@ struct coda_open_out {
/* coda_close: */
struct coda_close_in {
struct coda_in_hdr ih;
- ViceFid VFid;
+ CodaFid Fid;
int flags;
};
@@ -357,7 +393,7 @@ struct coda_close_out {
/* coda_ioctl: */
struct coda_ioctl_in {
struct coda_in_hdr ih;
- ViceFid VFid;
+ CodaFid Fid;
int cmd;
int len;
int rwflag;
@@ -374,7 +410,7 @@ struct coda_ioctl_out {
/* coda_getattr: */
struct coda_getattr_in {
struct coda_in_hdr ih;
- ViceFid VFid;
+ CodaFid Fid;
};
struct coda_getattr_out {
@@ -386,7 +422,7 @@ struct coda_getattr_out {
/* coda_setattr: NO_OUT */
struct coda_setattr_in {
struct coda_in_hdr ih;
- ViceFid VFid;
+ CodaFid Fid;
struct coda_vattr attr;
};
@@ -397,7 +433,7 @@ struct coda_setattr_out {
/* coda_access: NO_OUT */
struct coda_access_in {
struct coda_in_hdr ih;
- ViceFid VFid;
+ CodaFid Fid;
int flags;
};
@@ -413,14 +449,14 @@ struct coda_access_out {
/* coda_lookup: */
struct coda_lookup_in {
struct coda_in_hdr ih;
- ViceFid VFid;
+ CodaFid Fid;
int name; /* Place holder for data. */
int flags;
};
struct coda_lookup_out {
struct coda_out_hdr oh;
- ViceFid VFid;
+ CodaFid Fid;
int vtype;
};
@@ -428,7 +464,7 @@ struct coda_lookup_out {
/* coda_create: */
struct coda_create_in {
struct coda_in_hdr ih;
- ViceFid VFid;
+ CodaFid Fid;
struct coda_vattr attr;
int excl;
int mode;
@@ -437,7 +473,7 @@ struct coda_create_in {
struct coda_create_out {
struct coda_out_hdr oh;
- ViceFid VFid;
+ CodaFid Fid;
struct coda_vattr attr;
};
@@ -445,7 +481,7 @@ struct coda_create_out {
/* coda_remove: NO_OUT */
struct coda_remove_in {
struct coda_in_hdr ih;
- ViceFid VFid;
+ CodaFid Fid;
int name; /* Place holder for data. */
};
@@ -456,8 +492,8 @@ struct coda_remove_out {
/* coda_link: NO_OUT */
struct coda_link_in {
struct coda_in_hdr ih;
- ViceFid sourceFid; /* cnode to link *to* */
- ViceFid destFid; /* Directory in which to place link */
+ CodaFid sourceFid; /* cnode to link *to* */
+ CodaFid destFid; /* Directory in which to place link */
int tname; /* Place holder for data. */
};
@@ -469,9 +505,9 @@ struct coda_link_out {
/* coda_rename: NO_OUT */
struct coda_rename_in {
struct coda_in_hdr ih;
- ViceFid sourceFid;
+ CodaFid sourceFid;
int srcname;
- ViceFid destFid;
+ CodaFid destFid;
int destname;
};
@@ -482,14 +518,14 @@ struct coda_rename_out {
/* coda_mkdir: */
struct coda_mkdir_in {
struct coda_in_hdr ih;
- ViceFid VFid;
+ CodaFid Fid;
struct coda_vattr attr;
int name; /* Place holder for data. */
};
struct coda_mkdir_out {
struct coda_out_hdr oh;
- ViceFid VFid;
+ CodaFid Fid;
struct coda_vattr attr;
};
@@ -497,7 +533,7 @@ struct coda_mkdir_out {
/* coda_rmdir: NO_OUT */
struct coda_rmdir_in {
struct coda_in_hdr ih;
- ViceFid VFid;
+ CodaFid Fid;
int name; /* Place holder for data. */
};
@@ -508,7 +544,7 @@ struct coda_rmdir_out {
/* coda_readdir: */
struct coda_readdir_in {
struct coda_in_hdr ih;
- ViceFid VFid;
+ CodaFid Fid;
int count;
int offset;
};
@@ -522,7 +558,7 @@ struct coda_readdir_out {
/* coda_symlink: NO_OUT */
struct coda_symlink_in {
struct coda_in_hdr ih;
- ViceFid VFid; /* Directory to put symlink in */
+ CodaFid Fid; /* Directory to put symlink in */
int srcname;
struct coda_vattr attr;
int tname;
@@ -535,7 +571,7 @@ struct coda_symlink_out {
/* coda_readlink: */
struct coda_readlink_in {
struct coda_in_hdr ih;
- ViceFid VFid;
+ CodaFid Fid;
};
struct coda_readlink_out {
@@ -548,7 +584,7 @@ struct coda_readlink_out {
/* coda_fsync: NO_OUT */
struct coda_fsync_in {
struct coda_in_hdr ih;
- ViceFid VFid;
+ CodaFid Fid;
};
struct coda_fsync_out {
@@ -558,18 +594,18 @@ struct coda_fsync_out {
/* coda_inactive: NO_OUT */
struct coda_inactive_in {
struct coda_in_hdr ih;
- ViceFid VFid;
+ CodaFid Fid;
};
/* coda_vget: */
struct coda_vget_in {
struct coda_in_hdr ih;
- ViceFid VFid;
+ CodaFid Fid;
};
struct coda_vget_out {
struct coda_out_hdr oh;
- ViceFid VFid;
+ CodaFid Fid;
int vtype;
};
@@ -582,75 +618,85 @@ struct coda_vget_out {
/* CODA_PURGEUSER is a venus->kernel call */
struct coda_purgeuser_out {
struct coda_out_hdr oh;
+#ifdef CODA_COMPAT_5
struct coda_cred cred;
+#else
+ uid_t uid;
+#endif
};
/* coda_zapfile: */
/* CODA_ZAPFILE is a venus->kernel call */
struct coda_zapfile_out {
struct coda_out_hdr oh;
- ViceFid CodaFid;
+ CodaFid Fid;
};
/* coda_zapdir: */
/* CODA_ZAPDIR is a venus->kernel call */
struct coda_zapdir_out {
struct coda_out_hdr oh;
- ViceFid CodaFid;
+ CodaFid Fid;
};
/* coda_zapnode: */
/* CODA_ZAPVNODE is a venus->kernel call */
struct coda_zapvnode_out {
struct coda_out_hdr oh;
+#ifdef CODA_COMPAT_5
struct coda_cred cred;
- ViceFid VFid;
+#endif
+ CodaFid Fid;
};
/* coda_purgefid: */
/* CODA_PURGEFID is a venus->kernel call */
struct coda_purgefid_out {
struct coda_out_hdr oh;
- ViceFid CodaFid;
+ CodaFid Fid;
};
-/* coda_rdwr: */
-struct coda_rdwr_in {
- struct coda_in_hdr ih;
- ViceFid VFid;
- int rwflag;
- int count;
- int offset;
- int ioflag;
- caddr_t data; /* Place holder for data. */
+/* coda_replace: */
+/* CODA_REPLACE is a venus->kernel call */
+struct coda_replace_out { /* coda_replace is a venus->kernel call */
+ struct coda_out_hdr oh;
+ CodaFid NewFid;
+ CodaFid OldFid;
};
-struct coda_rdwr_out {
- struct coda_out_hdr oh;
- int rwflag;
- int count;
- caddr_t data; /* Place holder for data. */
+/* coda_open_by_fd: */
+struct coda_open_by_fd_in {
+ struct coda_in_hdr ih;
+ CodaFid Fid;
+ int flags;
};
-
-/* coda_replace: */
-/* CODA_REPLACE is a venus->kernel call */
-struct coda_replace_out { /* coda_replace is a venus->kernel call */
+struct coda_open_by_fd_out {
struct coda_out_hdr oh;
- ViceFid NewFid;
- ViceFid OldFid;
+ int fd;
+ struct file *fh;
};
/* coda_open_by_path: */
struct coda_open_by_path_in {
struct coda_in_hdr ih;
- ViceFid VFid;
+ CodaFid Fid;
int flags;
};
struct coda_open_by_path_out {
struct coda_out_hdr oh;
- int path;
+ int path;
+};
+
+/* coda_statfs: NO_IN */
+struct coda_statfs_in {
+ struct coda_in_hdr ih;
+};
+
+struct coda_statfs_out {
+ struct coda_out_hdr oh;
+ struct coda_statfs stat;
};
/*
@@ -679,10 +725,10 @@ union inputArgs {
struct coda_symlink_in coda_symlink;
struct coda_readlink_in coda_readlink;
struct coda_fsync_in coda_fsync;
- struct coda_inactive_in coda_inactive;
struct coda_vget_in coda_vget;
- struct coda_rdwr_in coda_rdwr;
- struct coda_open_by_path_in coda_open_by_path;
+ struct coda_open_by_fd_in coda_open_by_fd;
+ struct coda_open_by_path_in coda_open_by_path;
+ struct coda_statfs_in coda_statfs;
};
union outputArgs {
@@ -702,9 +748,10 @@ union outputArgs {
struct coda_zapdir_out coda_zapdir;
struct coda_zapvnode_out coda_zapvnode;
struct coda_purgefid_out coda_purgefid;
- struct coda_rdwr_out coda_rdwr;
struct coda_replace_out coda_replace;
- struct coda_open_by_path_out coda_open_by_path;
+ struct coda_open_by_fd_out coda_open_by_fd;
+ struct coda_open_by_path_out coda_open_by_path;
+ struct coda_statfs_out coda_statfs;
};
union coda_downcalls {
@@ -747,15 +794,32 @@ struct PioctlData {
#define CODA_CONTROL ".CONTROL"
#define CODA_CONTROLLEN 8
-#define CTL_VOL -1
-#define CTL_VNO -1
-#define CTL_UNI -1
#define CTL_INO -1
#define CTL_FILE "/coda/.CONTROL"
+#ifdef CODA_COMPAT_5
+#define CTL_FID { -1, -1, -1 }
+#define IS_CTL_FID(fidp) ((fidp)->Volume == -1 &&\
+ (fidp)->Vnode == -1 &&\
+ (fidp)->Unique == -1)
+#define INVAL_FID { 0, 0, 0 }
+#else
+#define CTL_FID { { -1, -1, -1, -1 } }
+#define IS_CTL_FID(fidp) ((fidp)->opaque[0] == -1 &&\
+ (fidp)->opaque[1] == -1 &&\
+ (fidp)->opaque[2] == -1 &&\
+ (fidp)->opaque[3] == -1)
+#define INVAL_FID { { 0, 0, 0, 0 } }
+#endif
+
+/* Data passed to mount */
+
+#define CODA_MOUNT_VERSION 1
+
+struct coda_mount_data {
+ int version;
+ int fd; /* Opened device */
+};
-#define IS_CTL_FID(fidp) ((fidp)->Volume == CTL_VOL &&\
- (fidp)->Vnode == CTL_VNO &&\
- (fidp)->Unique == CTL_UNI)
#endif
OpenPOWER on IntegriCloud