[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v5 3/6] 9pfs: make v9fs_readdir_response_size() public
From: |
Christian Schoenebeck |
Subject: |
[PATCH v5 3/6] 9pfs: make v9fs_readdir_response_size() public |
Date: |
Thu, 26 Mar 2020 22:24:51 +0100 |
Rename function v9fs_readdir_data_size() -> v9fs_readdir_response_size()
and make it callable from other units. So far this function is only
used by 9p.c, however subsequent patch requires the function to be
callable from another 9pfs unit. And as we're at it; also make it clear
for what this function is used for.
Signed-off-by: Christian Schoenebeck <address@hidden>
---
hw/9pfs/9p.c | 10 ++++++++--
hw/9pfs/9p.h | 1 +
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c
index 1aff4f1fa8..bd8a7cbfac 100644
--- a/hw/9pfs/9p.c
+++ b/hw/9pfs/9p.c
@@ -2322,7 +2322,13 @@ out_nofid:
pdu_complete(pdu, err);
}
-static size_t v9fs_readdir_data_size(V9fsString *name)
+/**
+ * Returns size required in Rreaddir response for the passed dirent @p name.
+ *
+ * @param name - directory entry's name (i.e. file name, directory name)
+ * @returns required size in bytes
+ */
+size_t v9fs_readdir_response_size(V9fsString *name)
{
/*
* Size of each dirent on the wire: size of qid (13) + size of offset (8)
@@ -2357,7 +2363,7 @@ static int coroutine_fn v9fs_do_readdir(V9fsPDU *pdu,
V9fsFidState *fidp,
}
v9fs_string_init(&name);
v9fs_string_sprintf(&name, "%s", dent->d_name);
- if ((count + v9fs_readdir_data_size(&name)) > maxsize) {
+ if ((count + v9fs_readdir_response_size(&name)) > maxsize) {
v9fs_readdir_unlock(&fidp->fs.dir);
/* Ran out of buffer. Set dir back to old position and return */
diff --git a/hw/9pfs/9p.h b/hw/9pfs/9p.h
index b8f72a3bd9..9553700dbb 100644
--- a/hw/9pfs/9p.h
+++ b/hw/9pfs/9p.h
@@ -419,6 +419,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,
--
2.20.1
- [PATCH v5 0/6] 9pfs: readdir optimization, Christian Schoenebeck, 2020/03/26
- [PATCH v5 4/6] 9pfs: add new function v9fs_co_readdir_many(), Christian Schoenebeck, 2020/03/26
- [PATCH v5 6/6] 9pfs: clarify latency of v9fs_co_run_in_worker(), Christian Schoenebeck, 2020/03/26
- [PATCH v5 1/6] tests/virtio-9p: added split readdir tests, Christian Schoenebeck, 2020/03/26
- [PATCH v5 2/6] 9pfs readdir: rename max_count -> maxsize, Christian Schoenebeck, 2020/03/26
- [PATCH v5 5/6] 9pfs: T_readdir latency optimization, Christian Schoenebeck, 2020/03/26
- [PATCH v5 3/6] 9pfs: make v9fs_readdir_response_size() public,
Christian Schoenebeck <=