Revision 8cf89e00 hw/virtio-9p-local.c
b/hw/virtio-9p-local.c | ||
---|---|---|
212 | 212 |
return err; |
213 | 213 |
} |
214 | 214 |
|
215 |
static int local_truncate(FsContext *ctx, const char *path, off_t size) |
|
216 |
{ |
|
217 |
return truncate(rpath(ctx, path), size); |
|
218 |
} |
|
219 |
|
|
220 |
static int local_rename(FsContext *ctx, const char *oldpath, |
|
221 |
const char *newpath) |
|
222 |
{ |
|
223 |
char *tmp; |
|
224 |
int err; |
|
225 |
|
|
226 |
tmp = qemu_strdup(rpath(ctx, oldpath)); |
|
227 |
if (tmp == NULL) { |
|
228 |
return -1; |
|
229 |
} |
|
230 |
|
|
231 |
err = rename(tmp, rpath(ctx, newpath)); |
|
232 |
if (err == -1) { |
|
233 |
int serrno = errno; |
|
234 |
qemu_free(tmp); |
|
235 |
errno = serrno; |
|
236 |
} else { |
|
237 |
qemu_free(tmp); |
|
238 |
} |
|
239 |
|
|
240 |
return err; |
|
241 |
|
|
242 |
} |
|
243 |
|
|
244 |
static int local_chown(FsContext *ctx, const char *path, uid_t uid, gid_t gid) |
|
245 |
{ |
|
246 |
return chown(rpath(ctx, path), uid, gid); |
|
247 |
} |
|
248 |
|
|
249 |
static int local_utime(FsContext *ctx, const char *path, |
|
250 |
const struct utimbuf *buf) |
|
251 |
{ |
|
252 |
return utime(rpath(ctx, path), buf); |
|
253 |
} |
|
254 |
|
|
255 |
static int local_fsync(FsContext *ctx, int fd) |
|
256 |
{ |
|
257 |
return fsync(fd); |
|
258 |
} |
|
259 |
|
|
215 | 260 |
FileOperations local_ops = { |
216 | 261 |
.lstat = local_lstat, |
217 | 262 |
.setuid = local_setuid, |
... | ... | |
235 | 280 |
.open2 = local_open2, |
236 | 281 |
.symlink = local_symlink, |
237 | 282 |
.link = local_link, |
283 |
.truncate = local_truncate, |
|
284 |
.rename = local_rename, |
|
285 |
.chown = local_chown, |
|
286 |
.utime = local_utime, |
|
287 |
.fsync = local_fsync, |
|
238 | 288 |
}; |
Also available in: Unified diff