hw/9pfs: Use export_flag for indicating whether fs driver use path names.
This allows us to remove another member from the struct Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
This commit is contained in:
parent
7cca27dfde
commit
c98f1d4a8b
@ -57,15 +57,12 @@ typedef struct extended_ops {
|
||||
mode_t, uint64_t *);
|
||||
} extended_ops;
|
||||
|
||||
/* FsContext flag values */
|
||||
#define PATHNAME_FSCONTEXT 0x1
|
||||
|
||||
/* export flags */
|
||||
#define V9FS_IMMEDIATE_WRITEOUT 0x1
|
||||
#define V9FS_IMMEDIATE_WRITEOUT 0x00000001
|
||||
#define V9FS_PATHNAME_FSCONTEXT 0x00000002
|
||||
|
||||
typedef struct FsContext
|
||||
{
|
||||
int flags;
|
||||
char *fs_root;
|
||||
SecModel fs_sm;
|
||||
uid_t uid;
|
||||
|
@ -323,7 +323,7 @@ int v9fs_co_name_to_path(V9fsPDU *pdu, V9fsPath *dirpath,
|
||||
int err;
|
||||
V9fsState *s = pdu->s;
|
||||
|
||||
if (s->ctx.flags & PATHNAME_FSCONTEXT) {
|
||||
if (s->ctx.export_flags & V9FS_PATHNAME_FSCONTEXT) {
|
||||
err = s->ops->name_to_path(&s->ctx, dirpath, name, path);
|
||||
if (err < 0) {
|
||||
err = -errno;
|
||||
|
@ -123,7 +123,6 @@ VirtIODevice *virtio_9p_init(DeviceState *dev, V9fsConf *conf)
|
||||
memcpy(s->tag, conf->tag, len);
|
||||
s->tag_len = len;
|
||||
s->ctx.uid = -1;
|
||||
s->ctx.flags = 0;
|
||||
|
||||
s->ops = fse->ops;
|
||||
s->vdev.get_features = virtio_9p_get_features;
|
||||
|
@ -702,7 +702,7 @@ static int local_init(FsContext *ctx)
|
||||
int err;
|
||||
struct statfs stbuf;
|
||||
|
||||
ctx->flags |= PATHNAME_FSCONTEXT;
|
||||
ctx->export_flags |= V9FS_PATHNAME_FSCONTEXT;
|
||||
err = statfs(ctx->fs_root, &stbuf);
|
||||
if (!err) {
|
||||
switch (stbuf.f_type) {
|
||||
|
@ -2493,7 +2493,7 @@ static void v9fs_remove(void *opaque)
|
||||
goto out_nofid;
|
||||
}
|
||||
/* if fs driver is not path based, return EOPNOTSUPP */
|
||||
if (!pdu->s->ctx.flags & PATHNAME_FSCONTEXT) {
|
||||
if (!(pdu->s->ctx.export_flags & V9FS_PATHNAME_FSCONTEXT)) {
|
||||
err = -EOPNOTSUPP;
|
||||
goto out_err;
|
||||
}
|
||||
@ -2640,7 +2640,7 @@ static void v9fs_rename(void *opaque)
|
||||
}
|
||||
BUG_ON(fidp->fid_type != P9_FID_NONE);
|
||||
/* if fs driver is not path based, return EOPNOTSUPP */
|
||||
if (!pdu->s->ctx.flags & PATHNAME_FSCONTEXT) {
|
||||
if (!(pdu->s->ctx.export_flags & V9FS_PATHNAME_FSCONTEXT)) {
|
||||
err = -EOPNOTSUPP;
|
||||
goto out;
|
||||
}
|
||||
@ -2713,7 +2713,7 @@ static int v9fs_complete_renameat(V9fsPDU *pdu, int32_t olddirfid,
|
||||
if (err < 0) {
|
||||
goto out;
|
||||
}
|
||||
if (s->ctx.flags & PATHNAME_FSCONTEXT) {
|
||||
if (s->ctx.export_flags & V9FS_PATHNAME_FSCONTEXT) {
|
||||
/* Only for path based fid we need to do the below fixup */
|
||||
v9fs_fix_fid_paths(pdu, &olddirfidp->path, old_name,
|
||||
&newdirfidp->path, new_name);
|
||||
|
@ -422,21 +422,21 @@ static inline size_t do_pdu_unpack(void *dst, struct iovec *sg, int sg_count,
|
||||
|
||||
static inline void v9fs_path_write_lock(V9fsState *s)
|
||||
{
|
||||
if (s->ctx.flags & PATHNAME_FSCONTEXT) {
|
||||
if (s->ctx.export_flags & V9FS_PATHNAME_FSCONTEXT) {
|
||||
qemu_co_rwlock_wrlock(&s->rename_lock);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void v9fs_path_read_lock(V9fsState *s)
|
||||
{
|
||||
if (s->ctx.flags & PATHNAME_FSCONTEXT) {
|
||||
if (s->ctx.export_flags & V9FS_PATHNAME_FSCONTEXT) {
|
||||
qemu_co_rwlock_rdlock(&s->rename_lock);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void v9fs_path_unlock(V9fsState *s)
|
||||
{
|
||||
if (s->ctx.flags & PATHNAME_FSCONTEXT) {
|
||||
if (s->ctx.export_flags & V9FS_PATHNAME_FSCONTEXT) {
|
||||
qemu_co_rwlock_unlock(&s->rename_lock);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user