Revision 5bae1900
b/hw/file-op-9p.h | ||
---|---|---|
34 | 34 |
int (*mknod)(FsContext *, const char *, mode_t, dev_t); |
35 | 35 |
int (*mksock)(FsContext *, const char *); |
36 | 36 |
int (*utime)(FsContext *, const char *, const struct utimbuf *); |
37 |
int (*remove)(FsContext *, const char *); |
|
37 | 38 |
int (*symlink)(FsContext *, const char *, const char *); |
38 | 39 |
int (*link)(FsContext *, const char *, const char *); |
39 | 40 |
int (*setuid)(FsContext *, uid_t); |
b/hw/virtio-9p-local.c | ||
---|---|---|
252 | 252 |
return utime(rpath(ctx, path), buf); |
253 | 253 |
} |
254 | 254 |
|
255 |
static int local_remove(FsContext *ctx, const char *path) |
|
256 |
{ |
|
257 |
return remove(rpath(ctx, path)); |
|
258 |
} |
|
259 |
|
|
255 | 260 |
static int local_fsync(FsContext *ctx, int fd) |
256 | 261 |
{ |
257 | 262 |
return fsync(fd); |
... | ... | |
284 | 289 |
.rename = local_rename, |
285 | 290 |
.chown = local_chown, |
286 | 291 |
.utime = local_utime, |
292 |
.remove = local_remove, |
|
287 | 293 |
.fsync = local_fsync, |
288 | 294 |
}; |
b/hw/virtio-9p.c | ||
---|---|---|
166 | 166 |
return s->ops->utime(&s->ctx, path->data, buf); |
167 | 167 |
} |
168 | 168 |
|
169 |
static int v9fs_do_remove(V9fsState *s, V9fsString *path) |
|
170 |
{ |
|
171 |
return s->ops->remove(&s->ctx, path->data); |
|
172 |
} |
|
173 |
|
|
169 | 174 |
static int v9fs_do_fsync(V9fsState *s, int fd) |
170 | 175 |
{ |
171 | 176 |
return s->ops->fsync(&s->ctx, fd); |
... | ... | |
1960 | 1965 |
} |
1961 | 1966 |
} |
1962 | 1967 |
|
1968 |
typedef struct V9fsRemoveState { |
|
1969 |
V9fsPDU *pdu; |
|
1970 |
size_t offset; |
|
1971 |
V9fsFidState *fidp; |
|
1972 |
} V9fsRemoveState; |
|
1973 |
|
|
1974 |
static void v9fs_remove_post_remove(V9fsState *s, V9fsRemoveState *vs, |
|
1975 |
int err) |
|
1976 |
{ |
|
1977 |
/* For TREMOVE we need to clunk the fid even on failed remove */ |
|
1978 |
err = free_fid(s, vs->fidp->fid); |
|
1979 |
if (err < 0) { |
|
1980 |
goto out; |
|
1981 |
} |
|
1982 |
|
|
1983 |
err = vs->offset; |
|
1984 |
out: |
|
1985 |
complete_pdu(s, vs->pdu, err); |
|
1986 |
qemu_free(vs); |
|
1987 |
} |
|
1988 |
|
|
1963 | 1989 |
static void v9fs_remove(V9fsState *s, V9fsPDU *pdu) |
1964 | 1990 |
{ |
1965 |
if (debug_9p_pdu) { |
|
1966 |
pprint_pdu(pdu); |
|
1991 |
int32_t fid; |
|
1992 |
V9fsRemoveState *vs; |
|
1993 |
int err = 0; |
|
1994 |
|
|
1995 |
vs = qemu_malloc(sizeof(*vs)); |
|
1996 |
vs->pdu = pdu; |
|
1997 |
vs->offset = 7; |
|
1998 |
|
|
1999 |
pdu_unmarshal(vs->pdu, vs->offset, "d", &fid); |
|
2000 |
|
|
2001 |
vs->fidp = lookup_fid(s, fid); |
|
2002 |
if (vs->fidp == NULL) { |
|
2003 |
err = -EINVAL; |
|
2004 |
goto out; |
|
1967 | 2005 |
} |
2006 |
|
|
2007 |
err = v9fs_do_remove(s, &vs->fidp->path); |
|
2008 |
v9fs_remove_post_remove(s, vs, err); |
|
2009 |
return; |
|
2010 |
|
|
2011 |
out: |
|
2012 |
complete_pdu(s, pdu, err); |
|
2013 |
qemu_free(vs); |
|
1968 | 2014 |
} |
1969 | 2015 |
|
1970 | 2016 |
typedef struct V9fsWstatState |
Also available in: Unified diff