summaryrefslogtreecommitdiff
path: root/hw/9pfs/9p.c
diff options
context:
space:
mode:
authorGreg Kurz <gkurz@linux.vnet.ibm.com>2016-06-06 11:52:34 +0200
committerGreg Kurz <gkurz@linux.vnet.ibm.com>2016-06-06 11:52:34 +0200
commit635324e83e238598e86628dba5ab62ce910e6f72 (patch)
tree959af05a3fb65f914171fa2c343f8b3fef9130b6 /hw/9pfs/9p.c
parent7cde47d4a89d5efefcc805788bc29133f4f3c5c7 (diff)
downloadqemu-635324e83e238598e86628dba5ab62ce910e6f72.tar.gz
qemu-635324e83e238598e86628dba5ab62ce910e6f72.tar.bz2
qemu-635324e83e238598e86628dba5ab62ce910e6f72.zip
9p: switch back to readdir()
This patch changes the 9p code to use readdir() again instead of readdir_r(), which is deprecated in glibc 2.24. All the locking was put in place by a previous patch. Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
Diffstat (limited to 'hw/9pfs/9p.c')
-rw-r--r--hw/9pfs/9p.c21
1 files changed, 6 insertions, 15 deletions
diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c
index 11085f45ad..9acff9293c 100644
--- a/hw/9pfs/9p.c
+++ b/hw/9pfs/9p.c
@@ -1627,7 +1627,7 @@ static int v9fs_do_readdir_with_stat(V9fsPDU *pdu,
int32_t count = 0;
struct stat stbuf;
off_t saved_dir_pos;
- struct dirent *dent, *result;
+ struct dirent *dent;
/* save the directory position */
saved_dir_pos = v9fs_co_telldir(pdu, fidp);
@@ -1635,15 +1635,13 @@ static int v9fs_do_readdir_with_stat(V9fsPDU *pdu,
return saved_dir_pos;
}
- dent = g_malloc(sizeof(struct dirent));
-
while (1) {
v9fs_path_init(&path);
v9fs_readdir_lock(&fidp->fs.dir);
- err = v9fs_co_readdir_r(pdu, fidp, dent, &result);
- if (err || !result) {
+ err = v9fs_co_readdir(pdu, fidp, &dent);
+ if (err || !dent) {
break;
}
err = v9fs_co_name_to_path(pdu, &fidp->path, dent->d_name, &path);
@@ -1668,7 +1666,6 @@ static int v9fs_do_readdir_with_stat(V9fsPDU *pdu,
v9fs_co_seekdir(pdu, fidp, saved_dir_pos);
v9fs_stat_free(&v9stat);
v9fs_path_free(&path);
- g_free(dent);
return count;
}
count += len;
@@ -1679,7 +1676,6 @@ static int v9fs_do_readdir_with_stat(V9fsPDU *pdu,
v9fs_readdir_unlock(&fidp->fs.dir);
- g_free(dent);
v9fs_path_free(&path);
if (err < 0) {
return err;
@@ -1815,7 +1811,7 @@ static int v9fs_do_readdir(V9fsPDU *pdu,
int len, err = 0;
int32_t count = 0;
off_t saved_dir_pos;
- struct dirent *dent, *result;
+ struct dirent *dent;
/* save the directory position */
saved_dir_pos = v9fs_co_telldir(pdu, fidp);
@@ -1823,13 +1819,11 @@ static int v9fs_do_readdir(V9fsPDU *pdu,
return saved_dir_pos;
}
- dent = g_malloc(sizeof(struct dirent));
-
while (1) {
v9fs_readdir_lock(&fidp->fs.dir);
- err = v9fs_co_readdir_r(pdu, fidp, dent, &result);
- if (err || !result) {
+ err = v9fs_co_readdir(pdu, fidp, &dent);
+ if (err || !dent) {
break;
}
v9fs_string_init(&name);
@@ -1840,7 +1834,6 @@ static int v9fs_do_readdir(V9fsPDU *pdu,
/* Ran out of buffer. Set dir back to old position and return */
v9fs_co_seekdir(pdu, fidp, saved_dir_pos);
v9fs_string_free(&name);
- g_free(dent);
return count;
}
/*
@@ -1864,7 +1857,6 @@ static int v9fs_do_readdir(V9fsPDU *pdu,
if (len < 0) {
v9fs_co_seekdir(pdu, fidp, saved_dir_pos);
v9fs_string_free(&name);
- g_free(dent);
return len;
}
count += len;
@@ -1874,7 +1866,6 @@ static int v9fs_do_readdir(V9fsPDU *pdu,
v9fs_readdir_unlock(&fidp->fs.dir);
- g_free(dent);
if (err < 0) {
return err;
}