mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-11 03:24:58 -06:00
9pfs: local : Introduce local_fid_fd() helper
Factor out duplicated code to a single helper. More users to come. Signed-off-by: Greg Kurz <groug@kaod.org> Reviewed-by: Christian Schoenebeck <qemu_oss@crudebyte.com> Message-Id: <20250312152933.383967-2-groug@kaod.org> Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
This commit is contained in:
parent
89f7b4da76
commit
4f82ce8cd9
1 changed files with 11 additions and 14 deletions
|
@ -766,16 +766,19 @@ out:
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int local_fid_fd(int fid_type, V9fsFidOpenState *fs)
|
||||||
|
{
|
||||||
|
if (fid_type == P9_FID_DIR) {
|
||||||
|
return dirfd(fs->dir.stream);
|
||||||
|
} else {
|
||||||
|
return fs->fd;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int local_fstat(FsContext *fs_ctx, int fid_type,
|
static int local_fstat(FsContext *fs_ctx, int fid_type,
|
||||||
V9fsFidOpenState *fs, struct stat *stbuf)
|
V9fsFidOpenState *fs, struct stat *stbuf)
|
||||||
{
|
{
|
||||||
int err, fd;
|
int err, fd = local_fid_fd(fid_type, fs);
|
||||||
|
|
||||||
if (fid_type == P9_FID_DIR) {
|
|
||||||
fd = dirfd(fs->dir.stream);
|
|
||||||
} else {
|
|
||||||
fd = fs->fd;
|
|
||||||
}
|
|
||||||
|
|
||||||
err = fstat(fd, stbuf);
|
err = fstat(fd, stbuf);
|
||||||
if (err) {
|
if (err) {
|
||||||
|
@ -1167,13 +1170,7 @@ out:
|
||||||
static int local_fsync(FsContext *ctx, int fid_type,
|
static int local_fsync(FsContext *ctx, int fid_type,
|
||||||
V9fsFidOpenState *fs, int datasync)
|
V9fsFidOpenState *fs, int datasync)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd = local_fid_fd(fid_type, fs);
|
||||||
|
|
||||||
if (fid_type == P9_FID_DIR) {
|
|
||||||
fd = dirfd(fs->dir.stream);
|
|
||||||
} else {
|
|
||||||
fd = fs->fd;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (datasync) {
|
if (datasync) {
|
||||||
return qemu_fdatasync(fd);
|
return qemu_fdatasync(fd);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue