Merge remote-tracking branch 'aneesh/for-upstream-2' into staging

This commit is contained in:
Anthony Liguori 2011-08-25 07:48:15 -05:00
commit 444dc48298
9 changed files with 856 additions and 1335 deletions

View File

@ -78,7 +78,7 @@ typedef struct FileOperations
int (*open2)(FsContext *, const char *, int, FsCred *);
void (*rewinddir)(FsContext *, DIR *);
off_t (*telldir)(FsContext *, DIR *);
struct dirent *(*readdir)(FsContext *, DIR *);
int (*readdir_r)(FsContext *, DIR *, struct dirent *, struct dirent **);
void (*seekdir)(FsContext *, DIR *, off_t);
ssize_t (*preadv)(FsContext *, int, const struct iovec *, int, off_t);
ssize_t (*pwritev)(FsContext *, int, const struct iovec *, int, off_t);

View File

@ -17,16 +17,16 @@
#include "qemu-coroutine.h"
#include "virtio-9p-coth.h"
int v9fs_co_readdir(V9fsState *s, V9fsFidState *fidp, struct dirent **dent)
int v9fs_co_readdir_r(V9fsState *s, V9fsFidState *fidp, struct dirent *dent,
struct dirent **result)
{
int err;
v9fs_co_run_in_worker(
{
errno = 0;
/*FIXME!! need to switch to readdir_r */
*dent = s->ops->readdir(&s->ctx, fidp->fs.dir);
if (!*dent && errno) {
err = s->ops->readdir_r(&s->ctx, fidp->fs.dir, dent, result);
if (!*result && errno) {
err = -errno;
} else {
err = 0;
@ -83,3 +83,35 @@ int v9fs_co_mkdir(V9fsState *s, char *name, mode_t mode, uid_t uid, gid_t gid)
});
return err;
}
int v9fs_co_opendir(V9fsState *s, V9fsFidState *fidp)
{
int err;
v9fs_co_run_in_worker(
{
fidp->fs.dir = s->ops->opendir(&s->ctx, fidp->path.data);
if (!fidp->fs.dir) {
err = -errno;
} else {
err = 0;
}
});
return err;
}
int v9fs_co_closedir(V9fsState *s, V9fsFidState *fidp)
{
int err;
DIR *dir;
dir = fidp->fs.dir;
v9fs_co_run_in_worker(
{
err = s->ops->closedir(&s->ctx, dir);
if (err < 0) {
err = -errno;
}
});
return err;
}

View File

@ -30,3 +30,134 @@ int v9fs_co_lstat(V9fsState *s, V9fsString *path, struct stat *stbuf)
});
return err;
}
int v9fs_co_fstat(V9fsState *s, int fd, struct stat *stbuf)
{
int err;
v9fs_co_run_in_worker(
{
err = s->ops->fstat(&s->ctx, fd, stbuf);
if (err < 0) {
err = -errno;
}
});
return err;
}
int v9fs_co_open(V9fsState *s, V9fsFidState *fidp, int flags)
{
int err;
v9fs_co_run_in_worker(
{
fidp->fs.fd = s->ops->open(&s->ctx, fidp->path.data, flags);
if (fidp->fs.fd == -1) {
err = -errno;
} else {
err = 0;
}
});
return err;
}
int v9fs_co_open2(V9fsState *s, V9fsFidState *fidp, char *fullname, gid_t gid,
int flags, int mode)
{
int err;
FsCred cred;
cred_init(&cred);
cred.fc_mode = mode & 07777;
cred.fc_uid = fidp->uid;
cred.fc_gid = gid;
v9fs_co_run_in_worker(
{
fidp->fs.fd = s->ops->open2(&s->ctx, fullname, flags, &cred);
err = 0;
if (fidp->fs.fd == -1) {
err = -errno;
}
});
return err;
}
int v9fs_co_close(V9fsState *s, V9fsFidState *fidp)
{
int fd;
int err;
fd = fidp->fs.fd;
v9fs_co_run_in_worker(
{
err = s->ops->close(&s->ctx, fd);
if (err < 0) {
err = -errno;
}
});
return err;
}
int v9fs_co_fsync(V9fsState *s, V9fsFidState *fidp, int datasync)
{
int fd;
int err;
fd = fidp->fs.fd;
v9fs_co_run_in_worker(
{
err = s->ops->fsync(&s->ctx, fd, datasync);
if (err < 0) {
err = -errno;
}
});
return err;
}
int v9fs_co_link(V9fsState *s, V9fsString *oldpath, V9fsString *newpath)
{
int err;
v9fs_co_run_in_worker(
{
err = s->ops->link(&s->ctx, oldpath->data, newpath->data);
if (err < 0) {
err = -errno;
}
});
return err;
}
int v9fs_co_pwritev(V9fsState *s, V9fsFidState *fidp,
struct iovec *iov, int iovcnt, int64_t offset)
{
int fd;
int err;
fd = fidp->fs.fd;
v9fs_co_run_in_worker(
{
err = s->ops->pwritev(&s->ctx, fd, iov, iovcnt, offset);
if (err < 0) {
err = -errno;
}
});
return err;
}
int v9fs_co_preadv(V9fsState *s, V9fsFidState *fidp,
struct iovec *iov, int iovcnt, int64_t offset)
{
int fd;
int err;
fd = fidp->fs.fd;
v9fs_co_run_in_worker(
{
err = s->ops->preadv(&s->ctx, fd, iov, iovcnt, offset);
if (err < 0) {
err = -errno;
}
});
return err;
}

View File

@ -169,3 +169,23 @@ int v9fs_co_rename(V9fsState *s, V9fsString *oldpath, V9fsString *newpath)
});
return err;
}
int v9fs_co_symlink(V9fsState *s, V9fsFidState *fidp,
const char *oldpath, const char *newpath, gid_t gid)
{
int err;
FsCred cred;
cred_init(&cred);
cred.fc_uid = fidp->uid;
cred.fc_gid = gid;
cred.fc_mode = 0777;
v9fs_co_run_in_worker(
{
err = s->ops->symlink(&s->ctx, oldpath, newpath, &cred);
if (err < 0) {
err = -errno;
}
});
return err;
}

View File

@ -48,3 +48,37 @@ int v9fs_co_lgetxattr(V9fsState *s, V9fsString *path,
});
return err;
}
int v9fs_co_lsetxattr(V9fsState *s, V9fsString *path,
V9fsString *xattr_name, void *value,
size_t size, int flags)
{
int err;
v9fs_co_run_in_worker(
{
err = s->ops->lsetxattr(&s->ctx, path->data,
xattr_name->data, value,
size, flags);
if (err < 0) {
err = -errno;
}
});
return err;
}
int v9fs_co_lremovexattr(V9fsState *s, V9fsString *path,
V9fsString *xattr_name)
{
int err;
v9fs_co_run_in_worker(
{
err = s->ops->lremovexattr(&s->ctx, path->data,
xattr_name->data);
if (err < 0) {
err = -errno;
}
});
return err;
}

View File

@ -57,8 +57,8 @@ typedef struct V9fsThPool {
extern void co_run_in_worker_bh(void *);
extern int v9fs_init_worker_threads(void);
extern int v9fs_co_readlink(V9fsState *, V9fsString *, V9fsString *);
extern int v9fs_co_readdir(V9fsState *, V9fsFidState *,
struct dirent **);
extern int v9fs_co_readdir_r(V9fsState *, V9fsFidState *,
struct dirent *, struct dirent **result);
extern off_t v9fs_co_telldir(V9fsState *, V9fsFidState *);
extern void v9fs_co_seekdir(V9fsState *, V9fsFidState *, off_t);
extern void v9fs_co_rewinddir(V9fsState *, V9fsFidState *);
@ -76,4 +76,21 @@ extern int v9fs_co_mknod(V9fsState *, V9fsString *, uid_t,
extern int v9fs_co_mkdir(V9fsState *, char *, mode_t, uid_t, gid_t);
extern int v9fs_co_remove(V9fsState *, V9fsString *);
extern int v9fs_co_rename(V9fsState *, V9fsString *, V9fsString *);
extern int v9fs_co_fstat(V9fsState *, int, struct stat *);
extern int v9fs_co_opendir(V9fsState *, V9fsFidState *);
extern int v9fs_co_open(V9fsState *, V9fsFidState *, int);
extern int v9fs_co_open2(V9fsState *, V9fsFidState *, char *, gid_t, int, int);
extern int v9fs_co_lsetxattr(V9fsState *, V9fsString *, V9fsString *,
void *, size_t, int);
extern int v9fs_co_lremovexattr(V9fsState *, V9fsString *, V9fsString *);
extern int v9fs_co_closedir(V9fsState *, V9fsFidState *);
extern int v9fs_co_close(V9fsState *, V9fsFidState *);
extern int v9fs_co_fsync(V9fsState *, V9fsFidState *, int);
extern int v9fs_co_symlink(V9fsState *, V9fsFidState *, const char *,
const char *, gid_t);
extern int v9fs_co_link(V9fsState *, V9fsString *, V9fsString *);
extern int v9fs_co_pwritev(V9fsState *, V9fsFidState *,
struct iovec *, int, int64_t);
extern int v9fs_co_preadv(V9fsState *, V9fsFidState *,
struct iovec *, int, int64_t);
#endif

View File

@ -165,9 +165,10 @@ static off_t local_telldir(FsContext *ctx, DIR *dir)
return telldir(dir);
}
static struct dirent *local_readdir(FsContext *ctx, DIR *dir)
static int local_readdir_r(FsContext *ctx, DIR *dir, struct dirent *entry,
struct dirent **result)
{
return readdir(dir);
return readdir_r(dir, entry, result);
}
static void local_seekdir(FsContext *ctx, DIR *dir, off_t off)
@ -532,7 +533,7 @@ FileOperations local_ops = {
.opendir = local_opendir,
.rewinddir = local_rewinddir,
.telldir = local_telldir,
.readdir = local_readdir,
.readdir_r = local_readdir_r,
.seekdir = local_seekdir,
.preadv = local_preadv,
.pwritev = local_pwritev,

File diff suppressed because it is too large Load Diff

View File

@ -222,31 +222,6 @@ typedef struct V9fsState
int32_t msize;
} V9fsState;
typedef struct V9fsCreateState {
V9fsPDU *pdu;
size_t offset;
V9fsFidState *fidp;
V9fsQID qid;
int32_t perm;
int8_t mode;
struct stat stbuf;
V9fsString name;
V9fsString extension;
V9fsString fullname;
int iounit;
} V9fsCreateState;
typedef struct V9fsLcreateState {
V9fsPDU *pdu;
size_t offset;
V9fsFidState *fidp;
V9fsQID qid;
int32_t iounit;
struct stat stbuf;
V9fsString name;
V9fsString fullname;
} V9fsLcreateState;
typedef struct V9fsStatState {
V9fsPDU *pdu;
size_t offset;
@ -278,19 +253,6 @@ typedef struct V9fsStatDotl {
uint64_t st_data_version;
} V9fsStatDotl;
typedef struct V9fsWalkState {
V9fsPDU *pdu;
size_t offset;
uint16_t nwnames;
int name_idx;
V9fsQID *qids;
V9fsFidState *fidp;
V9fsFidState *newfidp;
V9fsString path;
V9fsString *wnames;
struct stat stbuf;
} V9fsWalkState;
typedef struct V9fsOpenState {
V9fsPDU *pdu;
size_t offset;
@ -333,28 +295,6 @@ typedef struct V9fsWriteState {
int cnt;
} V9fsWriteState;
typedef struct V9fsWstatState
{
V9fsPDU *pdu;
size_t offset;
int16_t unused;
V9fsStat v9stat;
V9fsFidState *fidp;
struct stat stbuf;
} V9fsWstatState;
typedef struct V9fsSymlinkState
{
V9fsPDU *pdu;
size_t offset;
V9fsString name;
V9fsString symname;
V9fsString fullname;
V9fsFidState *dfidp;
V9fsQID qid;
struct stat stbuf;
} V9fsSymlinkState;
typedef struct V9fsIattr
{
int32_t valid;
@ -403,16 +343,6 @@ typedef struct V9fsFlock
V9fsString client_id;
} V9fsFlock;
typedef struct V9fsLockState
{
V9fsPDU *pdu;
size_t offset;
int8_t status;
struct stat stbuf;
V9fsFidState *fidp;
V9fsFlock *flock;
} V9fsLockState;
typedef struct V9fsGetlock
{
uint8_t type;
@ -422,15 +352,6 @@ typedef struct V9fsGetlock
V9fsString client_id;
} V9fsGetlock;
typedef struct V9fsGetlockState
{
V9fsPDU *pdu;
size_t offset;
struct stat stbuf;
V9fsFidState *fidp;
V9fsGetlock *glock;
} V9fsGetlockState;
size_t pdu_packunpack(void *addr, struct iovec *sg, int sg_count,
size_t offset, size_t size, int pack);