Revision 63729c36
b/hw/file-op-9p.h | ||
---|---|---|
52 | 52 |
int (*chmod)(FsContext *, const char *, FsCred *); |
53 | 53 |
int (*chown)(FsContext *, const char *, FsCred *); |
54 | 54 |
int (*mknod)(FsContext *, const char *, FsCred *); |
55 |
int (*mksock)(FsContext *, const char *); |
|
56 | 55 |
int (*utime)(FsContext *, const char *, const struct utimbuf *); |
57 | 56 |
int (*remove)(FsContext *, const char *); |
58 | 57 |
int (*symlink)(FsContext *, const char *, const char *, FsCred *); |
b/hw/virtio-9p-local.c | ||
---|---|---|
230 | 230 |
return err; |
231 | 231 |
} |
232 | 232 |
|
233 |
static int local_mksock(FsContext *ctx2, const char *path) |
|
234 |
{ |
|
235 |
struct sockaddr_un addr; |
|
236 |
int s; |
|
237 |
|
|
238 |
addr.sun_family = AF_UNIX; |
|
239 |
snprintf(addr.sun_path, 108, "%s", rpath(ctx2, path)); |
|
240 |
|
|
241 |
s = socket(PF_UNIX, SOCK_STREAM, 0); |
|
242 |
if (s == -1) { |
|
243 |
return -1; |
|
244 |
} |
|
245 |
|
|
246 |
if (bind(s, (struct sockaddr *)&addr, sizeof(addr))) { |
|
247 |
close(s); |
|
248 |
return -1; |
|
249 |
} |
|
250 |
|
|
251 |
close(s); |
|
252 |
return 0; |
|
253 |
} |
|
254 |
|
|
255 | 233 |
static int local_mkdir(FsContext *fs_ctx, const char *path, FsCred *credp) |
256 | 234 |
{ |
257 | 235 |
int err = -1; |
... | ... | |
507 | 485 |
.writev = local_writev, |
508 | 486 |
.chmod = local_chmod, |
509 | 487 |
.mknod = local_mknod, |
510 |
.mksock = local_mksock, |
|
511 | 488 |
.mkdir = local_mkdir, |
512 | 489 |
.fstat = local_fstat, |
513 | 490 |
.open2 = local_open2, |
b/hw/virtio-9p.c | ||
---|---|---|
171 | 171 |
return s->ops->mknod(&s->ctx, vs->fullname.data, &cred); |
172 | 172 |
} |
173 | 173 |
|
174 |
static int v9fs_do_mksock(V9fsState *s, V9fsString *path) |
|
175 |
{ |
|
176 |
return s->ops->mksock(&s->ctx, path->data); |
|
177 |
} |
|
178 |
|
|
179 | 174 |
static int v9fs_do_mkdir(V9fsState *s, V9fsCreateState *vs) |
180 | 175 |
{ |
181 | 176 |
FsCred cred; |
... | ... | |
1740 | 1735 |
v9fs_post_create(s, vs, err); |
1741 | 1736 |
} |
1742 | 1737 |
|
1743 |
static void v9fs_create_post_mksock(V9fsState *s, V9fsCreateState *vs, |
|
1744 |
int err) |
|
1745 |
{ |
|
1746 |
if (err) { |
|
1747 |
err = -errno; |
|
1748 |
goto out; |
|
1749 |
} |
|
1750 |
|
|
1751 |
err = v9fs_do_chmod(s, &vs->fullname, vs->perm & 0777); |
|
1752 |
v9fs_create_post_perms(s, vs, err); |
|
1753 |
return; |
|
1754 |
|
|
1755 |
out: |
|
1756 |
v9fs_post_create(s, vs, err); |
|
1757 |
} |
|
1758 |
|
|
1759 | 1738 |
static void v9fs_create_post_fstat(V9fsState *s, V9fsCreateState *vs, int err) |
1760 | 1739 |
{ |
1761 | 1740 |
if (err) { |
... | ... | |
1837 | 1816 |
err = v9fs_do_mknod(s, vs, S_IFIFO | (vs->perm & 0777), 0); |
1838 | 1817 |
v9fs_post_create(s, vs, err); |
1839 | 1818 |
} else if (vs->perm & P9_STAT_MODE_SOCKET) { |
1840 |
err = v9fs_do_mksock(s, &vs->fullname);
|
|
1841 |
v9fs_create_post_mksock(s, vs, err);
|
|
1819 |
err = v9fs_do_mknod(s, vs, S_IFSOCK | (vs->perm & 0777), 0);
|
|
1820 |
v9fs_post_create(s, vs, err);
|
|
1842 | 1821 |
} else { |
1843 | 1822 |
vs->fidp->fd = v9fs_do_open2(s, vs); |
1844 | 1823 |
v9fs_create_post_open2(s, vs, err); |
Also available in: Unified diff