mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-09 10:34:58 -06:00
9p: pass dotl flags to the unlinkat method
AT_REMOVEDIR is not defined on all systems. Pass the raw flags from the 9p protocol, which are always there. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
parent
f565403949
commit
930b588395
2 changed files with 11 additions and 11 deletions
|
@ -65,6 +65,9 @@ struct rpl_file_handle {
|
||||||
};
|
};
|
||||||
#define file_handle rpl_file_handle
|
#define file_handle rpl_file_handle
|
||||||
|
|
||||||
|
#ifndef AT_REMOVEDIR
|
||||||
|
#define AT_REMOVEDIR 0x200
|
||||||
|
#endif
|
||||||
#ifndef AT_EMPTY_PATH
|
#ifndef AT_EMPTY_PATH
|
||||||
#define AT_EMPTY_PATH 0x1000 /* Allow empty relative pathname */
|
#define AT_EMPTY_PATH 0x1000 /* Allow empty relative pathname */
|
||||||
#endif
|
#endif
|
||||||
|
@ -575,13 +578,20 @@ static int handle_unlinkat(FsContext *ctx, V9fsPath *dir,
|
||||||
{
|
{
|
||||||
int dirfd, ret;
|
int dirfd, ret;
|
||||||
struct handle_data *data = (struct handle_data *)ctx->private;
|
struct handle_data *data = (struct handle_data *)ctx->private;
|
||||||
|
int rflags;
|
||||||
|
|
||||||
dirfd = open_by_handle(data->mountfd, dir->data, O_PATH);
|
dirfd = open_by_handle(data->mountfd, dir->data, O_PATH);
|
||||||
if (dirfd < 0) {
|
if (dirfd < 0) {
|
||||||
return dirfd;
|
return dirfd;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = unlinkat(dirfd, name, flags);
|
rflags = 0;
|
||||||
|
if (flags & P9_DOTL_AT_REMOVEDIR) {
|
||||||
|
rflags |= AT_REMOVEDIR;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = unlinkat(dirfd, name, rflags);
|
||||||
|
|
||||||
close(dirfd);
|
close(dirfd);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,15 +74,6 @@ static int omode_to_uflags(int8_t mode)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dotl_to_at_flags(int flags)
|
|
||||||
{
|
|
||||||
int rflags = 0;
|
|
||||||
if (flags & P9_DOTL_AT_REMOVEDIR) {
|
|
||||||
rflags |= AT_REMOVEDIR;
|
|
||||||
}
|
|
||||||
return rflags;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct dotl_openflag_map {
|
struct dotl_openflag_map {
|
||||||
int dotl_flag;
|
int dotl_flag;
|
||||||
int open_flag;
|
int open_flag;
|
||||||
|
@ -2444,7 +2435,6 @@ static void v9fs_unlinkat(void *opaque)
|
||||||
V9fsPDU *pdu = opaque;
|
V9fsPDU *pdu = opaque;
|
||||||
|
|
||||||
pdu_unmarshal(pdu, offset, "dsd", &dfid, &name, &flags);
|
pdu_unmarshal(pdu, offset, "dsd", &dfid, &name, &flags);
|
||||||
flags = dotl_to_at_flags(flags);
|
|
||||||
|
|
||||||
dfidp = get_fid(pdu, dfid);
|
dfidp = get_fid(pdu, dfid);
|
||||||
if (dfidp == NULL) {
|
if (dfidp == NULL) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue