]> git.proxmox.com Git - qemu.git/blame - fsdev/file-op-9p.h
hw/9pfs: Use fs driver specific lstat
[qemu.git] / fsdev / file-op-9p.h
CommitLineData
74db920c
GS
1/*
2 * Virtio 9p
3 *
4 * Copyright IBM, Corp. 2010
5 *
6 * Authors:
7 * Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
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>
758e8e38 21#include <sys/vfs.h>
0174fe73 22
758e8e38
VJJ
23#define SM_LOCAL_MODE_BITS 0600
24#define SM_LOCAL_DIR_MODE_BITS 0700
25
26typedef enum
27{
12848bfc
AK
28 /*
29 * Server will try to set uid/gid.
30 * On failure ignore the error.
31 */
32 SM_NONE = 0,
33 /*
34 * uid/gid set on fileserver files
35 */
36 SM_PASSTHROUGH = 1,
37 /*
38 * uid/gid part of xattr
39 */
40 SM_MAPPED,
758e8e38
VJJ
41} SecModel;
42
43typedef struct FsCred
44{
45 uid_t fc_uid;
46 gid_t fc_gid;
47 mode_t fc_mode;
48 dev_t fc_rdev;
49} FsCred;
74db920c 50
fc22118d 51struct xattr_operations;
e06a765e
HPB
52struct FsContext;
53struct V9fsPath;
54
55typedef struct extended_ops {
56 int (*get_st_gen)(struct FsContext *, struct V9fsPath *,
57 mode_t, uint64_t *);
58} extended_ops;
fc22118d 59
532decb7
AK
60/* FsContext flag values */
61#define PATHNAME_FSCONTEXT 0x1
62
d3ab98e6
AK
63/* export flags */
64#define V9FS_IMMEDIATE_WRITEOUT 0x1
65
74db920c
GS
66typedef struct FsContext
67{
532decb7 68 int flags;
74db920c 69 char *fs_root;
758e8e38 70 SecModel fs_sm;
74db920c 71 uid_t uid;
d3ab98e6 72 int export_flags;
fc22118d 73 struct xattr_operations **xops;
e06a765e 74 struct extended_ops exops;
532decb7
AK
75 /* fs driver specific data */
76 void *private;
74db920c
GS
77} FsContext;
78
2289be19
AK
79typedef struct V9fsPath {
80 int16_t size;
81 char *data;
82} V9fsPath;
83
64b85a8f 84void cred_init(FsCred *);
758e8e38 85
74db920c
GS
86typedef struct FileOperations
87{
0174fe73 88 int (*init)(struct FsContext *);
2289be19
AK
89 int (*lstat)(FsContext *, V9fsPath *, struct stat *);
90 ssize_t (*readlink)(FsContext *, V9fsPath *, char *, size_t);
91 int (*chmod)(FsContext *, V9fsPath *, FsCred *);
92 int (*chown)(FsContext *, V9fsPath *, FsCred *);
93 int (*mknod)(FsContext *, V9fsPath *, const char *, FsCred *);
94 int (*utimensat)(FsContext *, V9fsPath *, const struct timespec *);
5bae1900 95 int (*remove)(FsContext *, const char *);
2289be19
AK
96 int (*symlink)(FsContext *, const char *, V9fsPath *,
97 const char *, FsCred *);
98 int (*link)(FsContext *, V9fsPath *, V9fsPath *, const char *);
131dcb25
AL
99 int (*setuid)(FsContext *, uid_t);
100 int (*close)(FsContext *, int);
101 int (*closedir)(FsContext *, DIR *);
2289be19
AK
102 DIR *(*opendir)(FsContext *, V9fsPath *);
103 int (*open)(FsContext *, V9fsPath *, int);
104 int (*open2)(FsContext *, V9fsPath *, const char *, int, FsCred *);
a9231555
AL
105 void (*rewinddir)(FsContext *, DIR *);
106 off_t (*telldir)(FsContext *, DIR *);
5f524c1e 107 int (*readdir_r)(FsContext *, DIR *, struct dirent *, struct dirent **);
a9231555 108 void (*seekdir)(FsContext *, DIR *, off_t);
56d15a53
SG
109 ssize_t (*preadv)(FsContext *, int, const struct iovec *, int, off_t);
110 ssize_t (*pwritev)(FsContext *, int, const struct iovec *, int, off_t);
2289be19 111 int (*mkdir)(FsContext *, V9fsPath *, const char *, FsCred *);
c494dd6f 112 int (*fstat)(FsContext *, int, struct stat *);
8cf89e00 113 int (*rename)(FsContext *, const char *, const char *);
2289be19 114 int (*truncate)(FsContext *, V9fsPath *, off_t);
49594973 115 int (*fsync)(FsContext *, int, int);
2289be19
AK
116 int (*statfs)(FsContext *s, V9fsPath *path, struct statfs *stbuf);
117 ssize_t (*lgetxattr)(FsContext *, V9fsPath *,
fa32ef88 118 const char *, void *, size_t);
2289be19
AK
119 ssize_t (*llistxattr)(FsContext *, V9fsPath *, void *, size_t);
120 int (*lsetxattr)(FsContext *, V9fsPath *,
10b468bd 121 const char *, void *, size_t, int);
2289be19
AK
122 int (*lremovexattr)(FsContext *, V9fsPath *, const char *);
123 int (*name_to_path)(FsContext *, V9fsPath *, const char *, V9fsPath *);
124 int (*renameat)(FsContext *ctx, V9fsPath *olddir, const char *old_name,
125 V9fsPath *newdir, const char *new_name);
126 int (*unlinkat)(FsContext *ctx, V9fsPath *dir, const char *name, int flags);
74db920c
GS
127 void *opaque;
128} FileOperations;
fc22118d 129
74db920c 130#endif