Statistics
| Branch: | Revision:

root / hw / file-op-9p.h @ ab03b63d

History | View | Annotate | Download (2.9 kB)

1 74db920c Gautham R Shenoy
/*
2 74db920c Gautham R Shenoy
 * Virtio 9p
3 74db920c Gautham R Shenoy
 *
4 74db920c Gautham R Shenoy
 * Copyright IBM, Corp. 2010
5 74db920c Gautham R Shenoy
 *
6 74db920c Gautham R Shenoy
 * Authors:
7 74db920c Gautham R Shenoy
 *  Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
8 74db920c Gautham R Shenoy
 *
9 74db920c Gautham R Shenoy
 * This work is licensed under the terms of the GNU GPL, version 2.  See
10 74db920c Gautham R Shenoy
 * the COPYING file in the top-level directory.
11 74db920c Gautham R Shenoy
 *
12 74db920c Gautham R Shenoy
 */
13 74db920c Gautham R Shenoy
#ifndef _FILEOP_H
14 74db920c Gautham R Shenoy
#define _FILEOP_H
15 74db920c Gautham R Shenoy
#include <sys/types.h>
16 74db920c Gautham R Shenoy
#include <dirent.h>
17 74db920c Gautham R Shenoy
#include <sys/time.h>
18 74db920c Gautham R Shenoy
#include <utime.h>
19 74db920c Gautham R Shenoy
#include <sys/stat.h>
20 74db920c Gautham R Shenoy
#include <sys/uio.h>
21 758e8e38 Venkateswararao Jujjuri (JV)
#include <sys/vfs.h>
22 758e8e38 Venkateswararao Jujjuri (JV)
#define SM_LOCAL_MODE_BITS    0600
23 758e8e38 Venkateswararao Jujjuri (JV)
#define SM_LOCAL_DIR_MODE_BITS    0700
24 758e8e38 Venkateswararao Jujjuri (JV)
25 758e8e38 Venkateswararao Jujjuri (JV)
typedef enum
26 758e8e38 Venkateswararao Jujjuri (JV)
{
27 12848bfc Aneesh Kumar K.V
    /*
28 12848bfc Aneesh Kumar K.V
     * Server will try to set uid/gid.
29 12848bfc Aneesh Kumar K.V
     * On failure ignore the error.
30 12848bfc Aneesh Kumar K.V
     */
31 12848bfc Aneesh Kumar K.V
    SM_NONE = 0,
32 12848bfc Aneesh Kumar K.V
    /*
33 12848bfc Aneesh Kumar K.V
     * uid/gid set on fileserver files
34 12848bfc Aneesh Kumar K.V
     */
35 12848bfc Aneesh Kumar K.V
    SM_PASSTHROUGH = 1,
36 12848bfc Aneesh Kumar K.V
    /*
37 12848bfc Aneesh Kumar K.V
     * uid/gid part of xattr
38 12848bfc Aneesh Kumar K.V
     */
39 12848bfc Aneesh Kumar K.V
    SM_MAPPED,
40 758e8e38 Venkateswararao Jujjuri (JV)
} SecModel;
41 758e8e38 Venkateswararao Jujjuri (JV)
42 758e8e38 Venkateswararao Jujjuri (JV)
typedef struct FsCred
43 758e8e38 Venkateswararao Jujjuri (JV)
{
44 758e8e38 Venkateswararao Jujjuri (JV)
    uid_t   fc_uid;
45 758e8e38 Venkateswararao Jujjuri (JV)
    gid_t   fc_gid;
46 758e8e38 Venkateswararao Jujjuri (JV)
    mode_t  fc_mode;
47 758e8e38 Venkateswararao Jujjuri (JV)
    dev_t   fc_rdev;
48 758e8e38 Venkateswararao Jujjuri (JV)
} FsCred;
49 74db920c Gautham R Shenoy
50 74db920c Gautham R Shenoy
typedef struct FsContext
51 74db920c Gautham R Shenoy
{
52 74db920c Gautham R Shenoy
    char *fs_root;
53 758e8e38 Venkateswararao Jujjuri (JV)
    SecModel fs_sm;
54 74db920c Gautham R Shenoy
    uid_t uid;
55 74db920c Gautham R Shenoy
} FsContext;
56 74db920c Gautham R Shenoy
57 758e8e38 Venkateswararao Jujjuri (JV)
extern void cred_init(FsCred *);
58 758e8e38 Venkateswararao Jujjuri (JV)
59 74db920c Gautham R Shenoy
typedef struct FileOperations
60 74db920c Gautham R Shenoy
{
61 131dcb25 Anthony Liguori
    int (*lstat)(FsContext *, const char *, struct stat *);
62 131dcb25 Anthony Liguori
    ssize_t (*readlink)(FsContext *, const char *, char *, size_t);
63 e95ead32 Venkateswararao Jujjuri (JV)
    int (*chmod)(FsContext *, const char *, FsCred *);
64 f7613bee Venkateswararao Jujjuri (JV)
    int (*chown)(FsContext *, const char *, FsCred *);
65 1c293312 Venkateswararao Jujjuri (JV)
    int (*mknod)(FsContext *, const char *, FsCred *);
66 74bc02b2 M. Mohan Kumar
    int (*utimensat)(FsContext *, const char *, const struct timespec *);
67 5bae1900 Anthony Liguori
    int (*remove)(FsContext *, const char *);
68 879c2813 Venkateswararao Jujjuri (JV)
    int (*symlink)(FsContext *, const char *, const char *, FsCred *);
69 c494dd6f Anthony Liguori
    int (*link)(FsContext *, const char *, const char *);
70 131dcb25 Anthony Liguori
    int (*setuid)(FsContext *, uid_t);
71 131dcb25 Anthony Liguori
    int (*close)(FsContext *, int);
72 131dcb25 Anthony Liguori
    int (*closedir)(FsContext *, DIR *);
73 a6568fe2 Anthony Liguori
    DIR *(*opendir)(FsContext *, const char *);
74 a6568fe2 Anthony Liguori
    int (*open)(FsContext *, const char *, int);
75 4750a96f Venkateswararao Jujjuri (JV)
    int (*open2)(FsContext *, const char *, int, FsCred *);
76 a9231555 Anthony Liguori
    void (*rewinddir)(FsContext *, DIR *);
77 a9231555 Anthony Liguori
    off_t (*telldir)(FsContext *, DIR *);
78 a9231555 Anthony Liguori
    struct dirent *(*readdir)(FsContext *, DIR *);
79 a9231555 Anthony Liguori
    void (*seekdir)(FsContext *, DIR *, off_t);
80 a9231555 Anthony Liguori
    ssize_t (*readv)(FsContext *, int, const struct iovec *, int);
81 8449360c Anthony Liguori
    ssize_t (*writev)(FsContext *, int, const struct iovec *, int);
82 a9231555 Anthony Liguori
    off_t (*lseek)(FsContext *, int, off_t, int);
83 00ec5c37 Venkateswararao Jujjuri (JV)
    int (*mkdir)(FsContext *, const char *, FsCred *);
84 c494dd6f Anthony Liguori
    int (*fstat)(FsContext *, int, struct stat *);
85 8cf89e00 Anthony Liguori
    int (*rename)(FsContext *, const char *, const char *);
86 8cf89e00 Anthony Liguori
    int (*truncate)(FsContext *, const char *, off_t);
87 8cf89e00 Anthony Liguori
    int (*fsync)(FsContext *, int);
88 be940c87 M. Mohan Kumar
    int (*statfs)(FsContext *s, const char *path, struct statfs *stbuf);
89 fa32ef88 Aneesh Kumar K.V
    ssize_t (*lgetxattr)(FsContext *, const char *,
90 fa32ef88 Aneesh Kumar K.V
                         const char *, void *, size_t);
91 fa32ef88 Aneesh Kumar K.V
    ssize_t (*llistxattr)(FsContext *, const char *, void *, size_t);
92 10b468bd Aneesh Kumar K.V
    int (*lsetxattr)(FsContext *, const char *,
93 10b468bd Aneesh Kumar K.V
                     const char *, void *, size_t, int);
94 9ed3ef26 Aneesh Kumar K.V
    int (*lremovexattr)(FsContext *, const char *, const char *);
95 74db920c Gautham R Shenoy
    void *opaque;
96 74db920c Gautham R Shenoy
} FileOperations;
97 74db920c Gautham R Shenoy
#endif