aboutsummaryrefslogtreecommitdiff
path: root/hw/9pfs/9p.h
diff options
context:
space:
mode:
Diffstat (limited to 'hw/9pfs/9p.h')
-rw-r--r--hw/9pfs/9p.h50
1 files changed, 45 insertions, 5 deletions
diff --git a/hw/9pfs/9p.h b/hw/9pfs/9p.h
index ee2271663c..3dd1b50b1a 100644
--- a/hw/9pfs/9p.h
+++ b/hw/9pfs/9p.h
@@ -197,24 +197,63 @@ typedef struct V9fsXattr
typedef struct V9fsDir {
DIR *stream;
- CoMutex readdir_mutex;
+ P9ProtoVersion proto_version;
+ /* readdir mutex type used for 9P2000.u protocol variant */
+ CoMutex readdir_mutex_u;
+ /* readdir mutex type used for 9P2000.L protocol variant */
+ QemuMutex readdir_mutex_L;
} V9fsDir;
static inline void v9fs_readdir_lock(V9fsDir *dir)
{
- qemu_co_mutex_lock(&dir->readdir_mutex);
+ if (dir->proto_version == V9FS_PROTO_2000U) {
+ qemu_co_mutex_lock(&dir->readdir_mutex_u);
+ } else {
+ qemu_mutex_lock(&dir->readdir_mutex_L);
+ }
}
static inline void v9fs_readdir_unlock(V9fsDir *dir)
{
- qemu_co_mutex_unlock(&dir->readdir_mutex);
+ if (dir->proto_version == V9FS_PROTO_2000U) {
+ qemu_co_mutex_unlock(&dir->readdir_mutex_u);
+ } else {
+ qemu_mutex_unlock(&dir->readdir_mutex_L);
+ }
}
-static inline void v9fs_readdir_init(V9fsDir *dir)
+static inline void v9fs_readdir_init(P9ProtoVersion proto_version, V9fsDir *dir)
{
- qemu_co_mutex_init(&dir->readdir_mutex);
+ dir->proto_version = proto_version;
+ if (proto_version == V9FS_PROTO_2000U) {
+ qemu_co_mutex_init(&dir->readdir_mutex_u);
+ } else {
+ qemu_mutex_init(&dir->readdir_mutex_L);
+ }
}
+/**
+ * Type for 9p fs drivers' (a.k.a. 9p backends) result of readdir requests,
+ * which is a chained list of directory entries.
+ */
+typedef struct V9fsDirEnt {
+ /* mandatory (must not be NULL) information for all readdir requests */
+ struct dirent *dent;
+ /*
+ * optional (may be NULL): A full stat of each directory entry is just
+ * done if explicitly told to fs driver.
+ */
+ struct stat *st;
+ /*
+ * instead of an array, directory entries are always returned as
+ * chained list, that's because the amount of entries retrieved by fs
+ * drivers is dependent on the individual entries' name (since response
+ * messages are size limited), so the final amount cannot be estimated
+ * before hand
+ */
+ struct V9fsDirEnt *next;
+} V9fsDirEnt;
+
/*
* Filled by fs driver on open and other
* calls.
@@ -419,6 +458,7 @@ void v9fs_path_init(V9fsPath *path);
void v9fs_path_free(V9fsPath *path);
void v9fs_path_sprintf(V9fsPath *path, const char *fmt, ...);
void v9fs_path_copy(V9fsPath *dst, const V9fsPath *src);
+size_t v9fs_readdir_response_size(V9fsString *name);
int v9fs_name_to_path(V9fsState *s, V9fsPath *dirpath,
const char *name, V9fsPath *path);
int v9fs_device_realize_common(V9fsState *s, const V9fsTransport *t,