2010-04-29 14:14:43 +02:00
|
|
|
/*
|
|
|
|
* Virtio 9p
|
|
|
|
*
|
|
|
|
* Copyright IBM, Corp. 2010
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
|
|
|
|
*
|
|
|
|
* This work is licensed under the terms of the GNU GPL, version 2. See
|
|
|
|
* the COPYING file in the top-level directory.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#ifndef _FILEOP_H
|
|
|
|
#define _FILEOP_H
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <dirent.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include <utime.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/uio.h>
|
2010-06-14 22:34:41 +02:00
|
|
|
#include <sys/vfs.h>
|
2011-08-02 08:05:54 +02:00
|
|
|
|
2010-06-14 22:34:41 +02:00
|
|
|
#define SM_LOCAL_MODE_BITS 0600
|
|
|
|
#define SM_LOCAL_DIR_MODE_BITS 0700
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
2010-09-02 07:39:07 +02:00
|
|
|
/*
|
|
|
|
* Server will try to set uid/gid.
|
|
|
|
* On failure ignore the error.
|
|
|
|
*/
|
|
|
|
SM_NONE = 0,
|
|
|
|
/*
|
|
|
|
* uid/gid set on fileserver files
|
|
|
|
*/
|
|
|
|
SM_PASSTHROUGH = 1,
|
|
|
|
/*
|
|
|
|
* uid/gid part of xattr
|
|
|
|
*/
|
|
|
|
SM_MAPPED,
|
2010-06-14 22:34:41 +02:00
|
|
|
} SecModel;
|
|
|
|
|
|
|
|
typedef struct FsCred
|
|
|
|
{
|
|
|
|
uid_t fc_uid;
|
|
|
|
gid_t fc_gid;
|
|
|
|
mode_t fc_mode;
|
|
|
|
dev_t fc_rdev;
|
|
|
|
} FsCred;
|
2010-04-29 14:14:43 +02:00
|
|
|
|
2010-10-18 11:58:16 +02:00
|
|
|
struct xattr_operations;
|
|
|
|
|
2011-08-02 08:05:54 +02:00
|
|
|
/* FsContext flag values */
|
|
|
|
#define PATHNAME_FSCONTEXT 0x1
|
|
|
|
|
2010-04-29 14:14:43 +02:00
|
|
|
typedef struct FsContext
|
|
|
|
{
|
2011-08-02 08:05:54 +02:00
|
|
|
int flags;
|
2010-04-29 14:14:43 +02:00
|
|
|
char *fs_root;
|
2010-06-14 22:34:41 +02:00
|
|
|
SecModel fs_sm;
|
2010-04-29 14:14:43 +02:00
|
|
|
uid_t uid;
|
2010-10-18 11:58:16 +02:00
|
|
|
struct xattr_operations **xops;
|
2011-08-02 08:05:54 +02:00
|
|
|
/* fs driver specific data */
|
|
|
|
void *private;
|
2010-04-29 14:14:43 +02:00
|
|
|
} FsContext;
|
|
|
|
|
2011-09-09 11:44:18 +02:00
|
|
|
typedef struct V9fsPath {
|
|
|
|
int16_t size;
|
|
|
|
char *data;
|
|
|
|
} V9fsPath;
|
|
|
|
|
2011-01-23 17:21:20 +01:00
|
|
|
void cred_init(FsCred *);
|
2010-06-14 22:34:41 +02:00
|
|
|
|
2010-04-29 14:14:43 +02:00
|
|
|
typedef struct FileOperations
|
|
|
|
{
|
2011-08-02 08:05:54 +02:00
|
|
|
int (*init)(struct FsContext *);
|
2011-09-09 11:44:18 +02:00
|
|
|
int (*lstat)(FsContext *, V9fsPath *, struct stat *);
|
|
|
|
ssize_t (*readlink)(FsContext *, V9fsPath *, char *, size_t);
|
|
|
|
int (*chmod)(FsContext *, V9fsPath *, FsCred *);
|
|
|
|
int (*chown)(FsContext *, V9fsPath *, FsCred *);
|
|
|
|
int (*mknod)(FsContext *, V9fsPath *, const char *, FsCred *);
|
|
|
|
int (*utimensat)(FsContext *, V9fsPath *, const struct timespec *);
|
2010-04-29 14:15:01 +02:00
|
|
|
int (*remove)(FsContext *, const char *);
|
2011-09-09 11:44:18 +02:00
|
|
|
int (*symlink)(FsContext *, const char *, V9fsPath *,
|
|
|
|
const char *, FsCred *);
|
|
|
|
int (*link)(FsContext *, V9fsPath *, V9fsPath *, const char *);
|
2010-04-29 14:14:47 +02:00
|
|
|
int (*setuid)(FsContext *, uid_t);
|
|
|
|
int (*close)(FsContext *, int);
|
|
|
|
int (*closedir)(FsContext *, DIR *);
|
2011-09-09 11:44:18 +02:00
|
|
|
DIR *(*opendir)(FsContext *, V9fsPath *);
|
|
|
|
int (*open)(FsContext *, V9fsPath *, int);
|
|
|
|
int (*open2)(FsContext *, V9fsPath *, const char *, int, FsCred *);
|
2010-04-29 14:14:56 +02:00
|
|
|
void (*rewinddir)(FsContext *, DIR *);
|
|
|
|
off_t (*telldir)(FsContext *, DIR *);
|
2011-05-18 13:53:00 +02:00
|
|
|
int (*readdir_r)(FsContext *, DIR *, struct dirent *, struct dirent **);
|
2010-04-29 14:14:56 +02:00
|
|
|
void (*seekdir)(FsContext *, DIR *, off_t);
|
2010-10-08 08:00:16 +02:00
|
|
|
ssize_t (*preadv)(FsContext *, int, const struct iovec *, int, off_t);
|
|
|
|
ssize_t (*pwritev)(FsContext *, int, const struct iovec *, int, off_t);
|
2011-09-09 11:44:18 +02:00
|
|
|
int (*mkdir)(FsContext *, V9fsPath *, const char *, FsCred *);
|
2010-04-29 14:14:59 +02:00
|
|
|
int (*fstat)(FsContext *, int, struct stat *);
|
2010-04-29 14:15:00 +02:00
|
|
|
int (*rename)(FsContext *, const char *, const char *);
|
2011-09-09 11:44:18 +02:00
|
|
|
int (*truncate)(FsContext *, V9fsPath *, off_t);
|
2010-10-22 19:08:45 +02:00
|
|
|
int (*fsync)(FsContext *, int, int);
|
2011-09-09 11:44:18 +02:00
|
|
|
int (*statfs)(FsContext *s, V9fsPath *path, struct statfs *stbuf);
|
|
|
|
ssize_t (*lgetxattr)(FsContext *, V9fsPath *,
|
2010-09-02 07:39:06 +02:00
|
|
|
const char *, void *, size_t);
|
2011-09-09 11:44:18 +02:00
|
|
|
ssize_t (*llistxattr)(FsContext *, V9fsPath *, void *, size_t);
|
|
|
|
int (*lsetxattr)(FsContext *, V9fsPath *,
|
2010-09-02 07:39:07 +02:00
|
|
|
const char *, void *, size_t, int);
|
2011-09-09 11:44:18 +02:00
|
|
|
int (*lremovexattr)(FsContext *, V9fsPath *, const char *);
|
|
|
|
int (*name_to_path)(FsContext *, V9fsPath *, const char *, V9fsPath *);
|
|
|
|
int (*renameat)(FsContext *ctx, V9fsPath *olddir, const char *old_name,
|
|
|
|
V9fsPath *newdir, const char *new_name);
|
|
|
|
int (*unlinkat)(FsContext *ctx, V9fsPath *dir, const char *name, int flags);
|
2010-04-29 14:14:43 +02:00
|
|
|
void *opaque;
|
|
|
|
} FileOperations;
|
2010-10-18 11:58:16 +02:00
|
|
|
|
2010-04-29 14:14:43 +02:00
|
|
|
#endif
|