virtio-9p: Security model for chown
[qemu.git] / hw / file-op-9p.h
bloba53cd35094ace076f687a4f70b23e005a6c31299
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
27 SM_PASSTHROUGH = 1, /* uid/gid set on fileserver files */
28 SM_MAPPED, /* uid/gid part of xattr */
29 } SecModel;
31 typedef struct FsCred
33 uid_t fc_uid;
34 gid_t fc_gid;
35 mode_t fc_mode;
36 dev_t fc_rdev;
37 } FsCred;
39 typedef struct FsContext
41 char *fs_root;
42 SecModel fs_sm;
43 uid_t uid;
44 } FsContext;
46 extern void cred_init(FsCred *);
48 typedef struct FileOperations
50 int (*lstat)(FsContext *, const char *, struct stat *);
51 ssize_t (*readlink)(FsContext *, const char *, char *, size_t);
52 int (*chmod)(FsContext *, const char *, FsCred *);
53 int (*chown)(FsContext *, const char *, FsCred *);
54 int (*mknod)(FsContext *, const char *, mode_t, dev_t);
55 int (*mksock)(FsContext *, const char *);
56 int (*utime)(FsContext *, const char *, const struct utimbuf *);
57 int (*remove)(FsContext *, const char *);
58 int (*symlink)(FsContext *, const char *, const char *);
59 int (*link)(FsContext *, const char *, const char *);
60 int (*setuid)(FsContext *, uid_t);
61 int (*close)(FsContext *, int);
62 int (*closedir)(FsContext *, DIR *);
63 DIR *(*opendir)(FsContext *, const char *);
64 int (*open)(FsContext *, const char *, int);
65 int (*open2)(FsContext *, const char *, int, mode_t);
66 void (*rewinddir)(FsContext *, DIR *);
67 off_t (*telldir)(FsContext *, DIR *);
68 struct dirent *(*readdir)(FsContext *, DIR *);
69 void (*seekdir)(FsContext *, DIR *, off_t);
70 ssize_t (*readv)(FsContext *, int, const struct iovec *, int);
71 ssize_t (*writev)(FsContext *, int, const struct iovec *, int);
72 off_t (*lseek)(FsContext *, int, off_t, int);
73 int (*mkdir)(FsContext *, const char *, mode_t);
74 int (*fstat)(FsContext *, int, struct stat *);
75 int (*rename)(FsContext *, const char *, const char *);
76 int (*truncate)(FsContext *, const char *, off_t);
77 int (*fsync)(FsContext *, int);
78 void *opaque;
79 } FileOperations;
80 #endif