dbdma: Make little endian
[qemu.git] / hw / file-op-9p.h
blob21d60b58556639e53eb00720da59ab03fdd87abc
1 /*
2 * Virtio 9p
4 * Copyright IBM, Corp. 2010
6 * Authors:
7 * Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
9 * This work is licensed under the terms of the GNU GPL, version 2. See
10 * the COPYING file in the top-level directory.
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>
22 #define SM_LOCAL_MODE_BITS 0600
23 #define SM_LOCAL_DIR_MODE_BITS 0700
25 typedef enum
28 * Server will try to set uid/gid.
29 * On failure ignore the error.
31 SM_NONE = 0,
33 * uid/gid set on fileserver files
35 SM_PASSTHROUGH = 1,
37 * uid/gid part of xattr
39 SM_MAPPED,
40 } SecModel;
42 typedef struct FsCred
44 uid_t fc_uid;
45 gid_t fc_gid;
46 mode_t fc_mode;
47 dev_t fc_rdev;
48 } FsCred;
50 struct xattr_operations;
52 typedef struct FsContext
54 char *fs_root;
55 SecModel fs_sm;
56 uid_t uid;
57 struct xattr_operations **xops;
58 } FsContext;
60 extern void cred_init(FsCred *);
62 typedef struct FileOperations
64 int (*lstat)(FsContext *, const char *, struct stat *);
65 ssize_t (*readlink)(FsContext *, const char *, char *, size_t);
66 int (*chmod)(FsContext *, const char *, FsCred *);
67 int (*chown)(FsContext *, const char *, FsCred *);
68 int (*mknod)(FsContext *, const char *, FsCred *);
69 int (*utimensat)(FsContext *, const char *, const struct timespec *);
70 int (*remove)(FsContext *, const char *);
71 int (*symlink)(FsContext *, const char *, const char *, FsCred *);
72 int (*link)(FsContext *, const char *, const char *);
73 int (*setuid)(FsContext *, uid_t);
74 int (*close)(FsContext *, int);
75 int (*closedir)(FsContext *, DIR *);
76 DIR *(*opendir)(FsContext *, const char *);
77 int (*open)(FsContext *, const char *, int);
78 int (*open2)(FsContext *, const char *, int, FsCred *);
79 void (*rewinddir)(FsContext *, DIR *);
80 off_t (*telldir)(FsContext *, DIR *);
81 struct dirent *(*readdir)(FsContext *, DIR *);
82 void (*seekdir)(FsContext *, DIR *, off_t);
83 ssize_t (*preadv)(FsContext *, int, const struct iovec *, int, off_t);
84 ssize_t (*pwritev)(FsContext *, int, const struct iovec *, int, off_t);
85 int (*mkdir)(FsContext *, const char *, FsCred *);
86 int (*fstat)(FsContext *, int, struct stat *);
87 int (*rename)(FsContext *, const char *, const char *);
88 int (*truncate)(FsContext *, const char *, off_t);
89 int (*fsync)(FsContext *, int);
90 int (*statfs)(FsContext *s, const char *path, struct statfs *stbuf);
91 ssize_t (*lgetxattr)(FsContext *, const char *,
92 const char *, void *, size_t);
93 ssize_t (*llistxattr)(FsContext *, const char *, void *, size_t);
94 int (*lsetxattr)(FsContext *, const char *,
95 const char *, void *, size_t, int);
96 int (*lremovexattr)(FsContext *, const char *, const char *);
97 void *opaque;
98 } FileOperations;
100 static inline const char *rpath(FsContext *ctx, const char *path)
102 /* FIXME: so wrong... */
103 static char buffer[4096];
104 snprintf(buffer, sizeof(buffer), "%s/%s", ctx->fs_root, path);
105 return buffer;
107 #endif