4 * Copyright IBM, Corp. 2010
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.
15 #include <sys/types.h>
22 #define SM_LOCAL_MODE_BITS 0600
23 #define SM_LOCAL_DIR_MODE_BITS 0700
28 * Server will try to set uid/gid.
29 * On failure ignore the error.
33 * uid/gid set on fileserver files
37 * uid/gid part of xattr
50 struct xattr_operations
;
52 typedef struct FsContext
57 struct xattr_operations
**xops
;
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, 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 *);
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
);