You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
qemu/hw/9pfs
Christian Schoenebeck c81e7219e0 9pfs: fix 'Tgetattr' after unlink
With a valid file ID (FID) of an open file, it should be possible to send
a 'Tgettattr' 9p request and successfully receive a 'Rgetattr' response,
even if the file has been removed in the meantime. Currently this would
fail with ENOENT.

I.e. this fixes the following misbehaviour with a 9p Linux client:

  open("/home/tst/filename", O_RDWR|O_CREAT|O_EXCL, 0600) = 3
  unlink("/home/tst/filename") = 0
  fstat(3, 0x23aa1a8) = -1 ENOENT (No such file or directory)

Expected results:

  open("/home/tst/filename", O_RDWR|O_CREAT|O_EXCL, 0600) = 3
  unlink("/home/tst/filename") = 0
  fstat(3, {st_mode=S_IFREG|0600, st_size=0, ...}) = 0

This is because 9p server is always using a path name based lstat() call
which fails as soon as the file got removed. So to fix this, use fstat()
whenever we have an open file descriptor already.

Fixes: 00ede4c252 ("virtio-9p: getattr server implementation...")
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/103
Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
Reviewed-by: Greg Kurz <groug@kaod.org>
Message-Id: <4c41ad47f449a5cc8bfa9285743e029080d5f324.1732465720.git.qemu_oss@crudebyte.com>
6 days ago
..
9p-local.c hw/9pfs: spelling fixes 1 year ago
9p-local.h
9p-posix-acl.c 9pfs: fix removing non-existent POSIX ACL xattr on macOS host 3 years ago
9p-synth.c hw/9pfs: spelling fixes 1 year ago
9p-synth.h 9pfs: Fix segfault in do_readdir_many caused by struct dirent overread 3 years ago
9p-util-darwin.c 9pfs: fix qemu_mknodat() to always return -1 on error on macOS host 3 years ago
9p-util-linux.c 9p: darwin: Implement compatibility for mknodat 3 years ago
9p-util.h hw/9pfs: spelling fixes 1 year ago
9p-xattr-user.c trivial typos: namesapce 2 years ago
9p-xattr.c 9pfs: add link to 9p developer docs 3 years ago
9p-xattr.h 9pfs: fix XattrOperations typedef 7 years ago
9p.c 9pfs: fix 'Tgetattr' after unlink 6 days ago
9p.h 9pfs: cleanup V9fsFidState 6 days ago
Kconfig hw/9pfs: Fix Kconfig dependency problem between 9pfs and Xen 4 years ago
codir.c 9pfs: mark more coroutine_fns 2 years ago
cofile.c fsdev: Use ThrottleDirection instread of bool is_write 1 year ago
cofs.c coroutine: Clean up superfluous inclusion of qemu/coroutine.h 2 years ago
coth.c thread-pool: avoid passing the pool parameter every time 2 years ago
coth.h coroutine: Split qemu/coroutine-core.h off qemu/coroutine.h 2 years ago
coxattr.c coroutine: Clean up superfluous inclusion of qemu/coroutine.h 2 years ago
meson.build 9p: remove 'proxy' filesystem backend driver 2 months ago
trace-events 9pfs/xen: Fix segfault on shutdown 2 years ago
trace.h trace: switch position of headers to what Meson requires 4 years ago
virtio-9p-device.c hw/9pfs: Constify VMState 11 months ago
virtio-9p.h Use OBJECT_DECLARE_SIMPLE_TYPE when possible 4 years ago
xen-9p-backend.c hw/xen: Make XenDevOps structures const 6 months ago
xen-9pfs.h xen: Import other xen/io/*.h 6 years ago