|
|
1.1 root 1: /*
2: * Virtio 9p
3: *
4: * Copyright IBM, Corp. 2010
5: *
6: * Authors:
7: * Aneesh Kumar K.V <[email protected]>
8: *
9: * This work is licensed under the terms of the GNU GPL, version 2. See
10: * the COPYING file in the top-level directory.
11: *
12: */
13: #ifndef _FILEOP_H
14: #define _FILEOP_H
15: #include <sys/types.h>
16: #include <dirent.h>
17: #include <sys/time.h>
18: #include <utime.h>
19: #include <sys/stat.h>
20: #include <sys/uio.h>
21: #include <sys/vfs.h>
1.1.1.2 ! root 22:
1.1 root 23: #define SM_LOCAL_MODE_BITS 0600
24: #define SM_LOCAL_DIR_MODE_BITS 0700
25:
26: typedef struct FsCred
27: {
28: uid_t fc_uid;
29: gid_t fc_gid;
30: mode_t fc_mode;
31: dev_t fc_rdev;
32: } FsCred;
33:
34: struct xattr_operations;
1.1.1.2 ! root 35: struct FsContext;
! 36: struct V9fsPath;
! 37:
! 38: typedef struct extended_ops {
! 39: int (*get_st_gen)(struct FsContext *, struct V9fsPath *,
! 40: mode_t, uint64_t *);
! 41: } extended_ops;
! 42:
! 43: /* export flags */
! 44: #define V9FS_IMMEDIATE_WRITEOUT 0x00000001
! 45: #define V9FS_PATHNAME_FSCONTEXT 0x00000002
! 46: /*
! 47: * uid/gid set on fileserver files
! 48: */
! 49: #define V9FS_SM_PASSTHROUGH 0x00000004
! 50: /*
! 51: * uid/gid part of xattr
! 52: */
! 53: #define V9FS_SM_MAPPED 0x00000008
! 54: /*
! 55: * Server will try to set uid/gid.
! 56: * On failure ignore the error.
! 57: */
! 58: #define V9FS_SM_NONE 0x00000010
! 59: #define V9FS_RDONLY 0x00000020
! 60:
! 61: #define V9FS_SEC_MASK 0x0000001C
! 62:
! 63:
1.1 root 64:
65: typedef struct FsContext
66: {
67: uid_t uid;
1.1.1.2 ! root 68: char *fs_root;
! 69: int export_flags;
1.1 root 70: struct xattr_operations **xops;
1.1.1.2 ! root 71: struct extended_ops exops;
! 72: /* fs driver specific data */
! 73: void *private;
1.1 root 74: } FsContext;
75:
1.1.1.2 ! root 76: typedef struct V9fsPath {
! 77: uint16_t size;
! 78: char *data;
! 79: } V9fsPath;
! 80:
! 81: typedef union V9fsFidOpenState V9fsFidOpenState;
! 82:
1.1 root 83: void cred_init(FsCred *);
84:
85: typedef struct FileOperations
86: {
1.1.1.2 ! root 87: int (*init)(struct FsContext *);
! 88: int (*lstat)(FsContext *, V9fsPath *, struct stat *);
! 89: ssize_t (*readlink)(FsContext *, V9fsPath *, char *, size_t);
! 90: int (*chmod)(FsContext *, V9fsPath *, FsCred *);
! 91: int (*chown)(FsContext *, V9fsPath *, FsCred *);
! 92: int (*mknod)(FsContext *, V9fsPath *, const char *, FsCred *);
! 93: int (*utimensat)(FsContext *, V9fsPath *, const struct timespec *);
1.1 root 94: int (*remove)(FsContext *, const char *);
1.1.1.2 ! root 95: int (*symlink)(FsContext *, const char *, V9fsPath *,
! 96: const char *, FsCred *);
! 97: int (*link)(FsContext *, V9fsPath *, V9fsPath *, const char *);
1.1 root 98: int (*setuid)(FsContext *, uid_t);
1.1.1.2 ! root 99: int (*close)(FsContext *, V9fsFidOpenState *);
! 100: int (*closedir)(FsContext *, V9fsFidOpenState *);
! 101: int (*opendir)(FsContext *, V9fsPath *, V9fsFidOpenState *);
! 102: int (*open)(FsContext *, V9fsPath *, int, V9fsFidOpenState *);
! 103: int (*open2)(FsContext *, V9fsPath *, const char *,
! 104: int, FsCred *, V9fsFidOpenState *);
! 105: void (*rewinddir)(FsContext *, V9fsFidOpenState *);
! 106: off_t (*telldir)(FsContext *, V9fsFidOpenState *);
! 107: int (*readdir_r)(FsContext *, V9fsFidOpenState *,
! 108: struct dirent *, struct dirent **);
! 109: void (*seekdir)(FsContext *, V9fsFidOpenState *, off_t);
! 110: ssize_t (*preadv)(FsContext *, V9fsFidOpenState *,
! 111: const struct iovec *, int, off_t);
! 112: ssize_t (*pwritev)(FsContext *, V9fsFidOpenState *,
! 113: const struct iovec *, int, off_t);
! 114: int (*mkdir)(FsContext *, V9fsPath *, const char *, FsCred *);
! 115: int (*fstat)(FsContext *, int, V9fsFidOpenState *, struct stat *);
1.1 root 116: int (*rename)(FsContext *, const char *, const char *);
1.1.1.2 ! root 117: int (*truncate)(FsContext *, V9fsPath *, off_t);
! 118: int (*fsync)(FsContext *, int, V9fsFidOpenState *, int);
! 119: int (*statfs)(FsContext *s, V9fsPath *path, struct statfs *stbuf);
! 120: ssize_t (*lgetxattr)(FsContext *, V9fsPath *,
1.1 root 121: const char *, void *, size_t);
1.1.1.2 ! root 122: ssize_t (*llistxattr)(FsContext *, V9fsPath *, void *, size_t);
! 123: int (*lsetxattr)(FsContext *, V9fsPath *,
1.1 root 124: const char *, void *, size_t, int);
1.1.1.2 ! root 125: int (*lremovexattr)(FsContext *, V9fsPath *, const char *);
! 126: int (*name_to_path)(FsContext *, V9fsPath *, const char *, V9fsPath *);
! 127: int (*renameat)(FsContext *ctx, V9fsPath *olddir, const char *old_name,
! 128: V9fsPath *newdir, const char *new_name);
! 129: int (*unlinkat)(FsContext *ctx, V9fsPath *dir, const char *name, int flags);
1.1 root 130: void *opaque;
131: } FileOperations;
132:
133: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.