diff options
Diffstat (limited to 'hw/virtio-9p-local.c')
-rw-r--r-- | hw/virtio-9p-local.c | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/hw/virtio-9p-local.c b/hw/virtio-9p-local.c index 711f2b5ca1..791a8ba088 100644 --- a/hw/virtio-9p-local.c +++ b/hw/virtio-9p-local.c @@ -195,9 +195,39 @@ static int local_chmod(FsContext *fs_ctx, const char *path, FsCred *credp) return -1; } -static int local_mknod(FsContext *ctx, const char *path, mode_t mode, dev_t dev) +static int local_mknod(FsContext *fs_ctx, const char *path, FsCred *credp) { - return mknod(rpath(ctx, path), mode, dev); + int err = -1; + int serrno = 0; + + /* Determine the security model */ + if (fs_ctx->fs_sm == SM_MAPPED) { + err = mknod(rpath(fs_ctx, path), SM_LOCAL_MODE_BITS|S_IFREG, 0); + if (err == -1) { + return err; + } + local_set_xattr(rpath(fs_ctx, path), credp); + if (err == -1) { + serrno = errno; + goto err_end; + } + } else if (fs_ctx->fs_sm == SM_PASSTHROUGH) { + err = mknod(rpath(fs_ctx, path), credp->fc_mode, credp->fc_rdev); + if (err == -1) { + return err; + } + err = local_post_create_passthrough(fs_ctx, path, credp); + if (err == -1) { + serrno = errno; + goto err_end; + } + } + return err; + +err_end: + remove(rpath(fs_ctx, path)); + errno = serrno; + return err; } static int local_mksock(FsContext *ctx2, const char *path) |