Revision 00ec5c37
b/hw/file-op-9p.h | ||
---|---|---|
70 | 70 |
ssize_t (*readv)(FsContext *, int, const struct iovec *, int); |
71 | 71 |
ssize_t (*writev)(FsContext *, int, const struct iovec *, int); |
72 | 72 |
off_t (*lseek)(FsContext *, int, off_t, int); |
73 |
int (*mkdir)(FsContext *, const char *, mode_t);
|
|
73 |
int (*mkdir)(FsContext *, const char *, FsCred *);
|
|
74 | 74 |
int (*fstat)(FsContext *, int, struct stat *); |
75 | 75 |
int (*rename)(FsContext *, const char *, const char *); |
76 | 76 |
int (*truncate)(FsContext *, const char *, off_t); |
b/hw/virtio-9p-local.c | ||
---|---|---|
207 | 207 |
return 0; |
208 | 208 |
} |
209 | 209 |
|
210 |
static int local_mkdir(FsContext *ctx, const char *path, mode_t mode)
|
|
210 |
static int local_mkdir(FsContext *fs_ctx, const char *path, FsCred *credp)
|
|
211 | 211 |
{ |
212 |
return mkdir(rpath(ctx, path), mode); |
|
212 |
int err = -1; |
|
213 |
int serrno = 0; |
|
214 |
|
|
215 |
/* Determine the security model */ |
|
216 |
if (fs_ctx->fs_sm == SM_MAPPED) { |
|
217 |
err = mkdir(rpath(fs_ctx, path), SM_LOCAL_DIR_MODE_BITS); |
|
218 |
if (err == -1) { |
|
219 |
return err; |
|
220 |
} |
|
221 |
credp->fc_mode = credp->fc_mode|S_IFDIR; |
|
222 |
err = local_set_xattr(rpath(fs_ctx, path), credp); |
|
223 |
if (err == -1) { |
|
224 |
serrno = errno; |
|
225 |
goto err_end; |
|
226 |
} |
|
227 |
} else if (fs_ctx->fs_sm == SM_PASSTHROUGH) { |
|
228 |
err = mkdir(rpath(fs_ctx, path), credp->fc_mode); |
|
229 |
if (err == -1) { |
|
230 |
return err; |
|
231 |
} |
|
232 |
err = local_post_create_passthrough(fs_ctx, path, credp); |
|
233 |
if (err == -1) { |
|
234 |
serrno = errno; |
|
235 |
goto err_end; |
|
236 |
} |
|
237 |
} |
|
238 |
return err; |
|
239 |
|
|
240 |
err_end: |
|
241 |
remove(rpath(fs_ctx, path)); |
|
242 |
errno = serrno; |
|
243 |
return err; |
|
213 | 244 |
} |
214 | 245 |
|
215 | 246 |
static int local_fstat(FsContext *fs_ctx, int fd, struct stat *stbuf) |
b/hw/virtio-9p.c | ||
---|---|---|
170 | 170 |
return s->ops->mksock(&s->ctx, path->data); |
171 | 171 |
} |
172 | 172 |
|
173 |
static int v9fs_do_mkdir(V9fsState *s, V9fsString *path, mode_t mode)
|
|
173 |
static int v9fs_do_mkdir(V9fsState *s, V9fsCreateState *vs)
|
|
174 | 174 |
{ |
175 |
return s->ops->mkdir(&s->ctx, path->data, mode); |
|
175 |
FsCred cred; |
|
176 |
|
|
177 |
cred_init(&cred); |
|
178 |
cred.fc_uid = vs->fidp->uid; |
|
179 |
cred.fc_mode = vs->perm & 0777; |
|
180 |
|
|
181 |
return s->ops->mkdir(&s->ctx, vs->fullname.data, &cred); |
|
176 | 182 |
} |
177 | 183 |
|
178 | 184 |
static int v9fs_do_fstat(V9fsState *s, int fd, struct stat *stbuf) |
... | ... | |
1776 | 1782 |
} |
1777 | 1783 |
|
1778 | 1784 |
if (vs->perm & P9_STAT_MODE_DIR) { |
1779 |
err = v9fs_do_mkdir(s, &vs->fullname, vs->perm & 0777);
|
|
1785 |
err = v9fs_do_mkdir(s, vs);
|
|
1780 | 1786 |
v9fs_create_post_mkdir(s, vs, err); |
1781 | 1787 |
} else if (vs->perm & P9_STAT_MODE_SYMLINK) { |
1782 | 1788 |
err = v9fs_do_symlink(s, &vs->extension, &vs->fullname); |
Also available in: Unified diff