mirror of
https://github.com/qemu/qemu.git
synced 2026-07-08 17:46:10 +00:00
hw/9pfs: change V9fsPath.size to size_t and v9fs_path_sprintf() return type
- Change V9fsPath.size from uint16_t to size_t to support paths larger than 65536 bytes. - Change v9fs_path_sprintf() return type from void to int to allow error reporting. Link: https://lore.kernel.org/qemu-devel/2d2348d94ff43fbe4cc0aea24fb312c5c15ee809.1779126034.git.qemu_oss@crudebyte.com Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
This commit is contained in:
@@ -112,7 +112,7 @@ struct FsContext {
|
||||
};
|
||||
|
||||
struct V9fsPath {
|
||||
uint16_t size;
|
||||
size_t size;
|
||||
char *data;
|
||||
};
|
||||
P9ARRAY_DECLARE_TYPE(V9fsPath);
|
||||
|
||||
14
hw/9pfs/9p.c
14
hw/9pfs/9p.c
@@ -203,16 +203,24 @@ void v9fs_path_free(V9fsPath *path)
|
||||
}
|
||||
|
||||
|
||||
void v9fs_path_sprintf(V9fsPath *path, const char *fmt, ...)
|
||||
int v9fs_path_sprintf(V9fsPath *path, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
int ret;
|
||||
|
||||
v9fs_path_free(path);
|
||||
|
||||
va_start(ap, fmt);
|
||||
/* Bump the size for including terminating NULL */
|
||||
path->size = g_vasprintf(&path->data, fmt, ap) + 1;
|
||||
ret = g_vasprintf(&path->data, fmt, ap);
|
||||
va_end(ap);
|
||||
if (ret < 0) {
|
||||
error_report_once("9pfs: unusual path formatting failure; "
|
||||
"invalidating associated FID");
|
||||
return -1;
|
||||
}
|
||||
/* Bump the size for including terminating NULL */
|
||||
path->size = ret + 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void v9fs_path_copy(V9fsPath *dst, const V9fsPath *src)
|
||||
|
||||
@@ -456,8 +456,8 @@ static inline uint8_t v9fs_request_cancelled(V9fsPDU *pdu)
|
||||
void coroutine_fn v9fs_reclaim_fd(V9fsPDU *pdu);
|
||||
void v9fs_path_init(V9fsPath *path);
|
||||
void v9fs_path_free(V9fsPath *path);
|
||||
void G_GNUC_PRINTF(2, 3) v9fs_path_sprintf(V9fsPath *path, const char *fmt,
|
||||
...);
|
||||
int G_GNUC_PRINTF(2, 3) 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,
|
||||
|
||||
Reference in New Issue
Block a user