Statistics
| Branch: | Revision:

root / hw / 9pfs / cofs.c @ 737e150e

History | View | Annotate | Download (8 kB)

1 86e42d74 Venkateswararao Jujjuri (JV)
2 86e42d74 Venkateswararao Jujjuri (JV)
/*
3 86e42d74 Venkateswararao Jujjuri (JV)
 * Virtio 9p backend
4 86e42d74 Venkateswararao Jujjuri (JV)
 *
5 86e42d74 Venkateswararao Jujjuri (JV)
 * Copyright IBM, Corp. 2011
6 86e42d74 Venkateswararao Jujjuri (JV)
 *
7 86e42d74 Venkateswararao Jujjuri (JV)
 * Authors:
8 86e42d74 Venkateswararao Jujjuri (JV)
 *  Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
9 86e42d74 Venkateswararao Jujjuri (JV)
 *
10 86e42d74 Venkateswararao Jujjuri (JV)
 * This work is licensed under the terms of the GNU GPL, version 2.  See
11 86e42d74 Venkateswararao Jujjuri (JV)
 * the COPYING file in the top-level directory.
12 86e42d74 Venkateswararao Jujjuri (JV)
 *
13 86e42d74 Venkateswararao Jujjuri (JV)
 */
14 86e42d74 Venkateswararao Jujjuri (JV)
15 86e42d74 Venkateswararao Jujjuri (JV)
#include "fsdev/qemu-fsdev.h"
16 86e42d74 Venkateswararao Jujjuri (JV)
#include "qemu-thread.h"
17 737e150e Paolo Bonzini
#include "block/coroutine.h"
18 86e42d74 Venkateswararao Jujjuri (JV)
#include "virtio-9p-coth.h"
19 86e42d74 Venkateswararao Jujjuri (JV)
20 bccacf6c Aneesh Kumar K.V
int v9fs_co_readlink(V9fsPDU *pdu, V9fsPath *path, V9fsString *buf)
21 86e42d74 Venkateswararao Jujjuri (JV)
{
22 86e42d74 Venkateswararao Jujjuri (JV)
    int err;
23 86e42d74 Venkateswararao Jujjuri (JV)
    ssize_t len;
24 bccacf6c Aneesh Kumar K.V
    V9fsState *s = pdu->s;
25 86e42d74 Venkateswararao Jujjuri (JV)
26 bccacf6c Aneesh Kumar K.V
    if (v9fs_request_cancelled(pdu)) {
27 bccacf6c Aneesh Kumar K.V
        return -EINTR;
28 bccacf6c Aneesh Kumar K.V
    }
29 7267c094 Anthony Liguori
    buf->data = g_malloc(PATH_MAX);
30 532decb7 Aneesh Kumar K.V
    v9fs_path_read_lock(s);
31 86e42d74 Venkateswararao Jujjuri (JV)
    v9fs_co_run_in_worker(
32 86e42d74 Venkateswararao Jujjuri (JV)
        {
33 2289be19 Aneesh Kumar K.V
            len = s->ops->readlink(&s->ctx, path,
34 86e42d74 Venkateswararao Jujjuri (JV)
                                   buf->data, PATH_MAX - 1);
35 86e42d74 Venkateswararao Jujjuri (JV)
            if (len > -1) {
36 86e42d74 Venkateswararao Jujjuri (JV)
                buf->size = len;
37 86e42d74 Venkateswararao Jujjuri (JV)
                buf->data[len] = 0;
38 86e42d74 Venkateswararao Jujjuri (JV)
                err = 0;
39 86e42d74 Venkateswararao Jujjuri (JV)
            } else {
40 86e42d74 Venkateswararao Jujjuri (JV)
                err = -errno;
41 86e42d74 Venkateswararao Jujjuri (JV)
            }
42 86e42d74 Venkateswararao Jujjuri (JV)
        });
43 532decb7 Aneesh Kumar K.V
    v9fs_path_unlock(s);
44 86e42d74 Venkateswararao Jujjuri (JV)
    if (err) {
45 7267c094 Anthony Liguori
        g_free(buf->data);
46 86e42d74 Venkateswararao Jujjuri (JV)
        buf->data = NULL;
47 86e42d74 Venkateswararao Jujjuri (JV)
        buf->size = 0;
48 86e42d74 Venkateswararao Jujjuri (JV)
    }
49 86e42d74 Venkateswararao Jujjuri (JV)
    return err;
50 86e42d74 Venkateswararao Jujjuri (JV)
}
51 94840ff9 Aneesh Kumar K.V
52 bccacf6c Aneesh Kumar K.V
int v9fs_co_statfs(V9fsPDU *pdu, V9fsPath *path, struct statfs *stbuf)
53 94840ff9 Aneesh Kumar K.V
{
54 94840ff9 Aneesh Kumar K.V
    int err;
55 bccacf6c Aneesh Kumar K.V
    V9fsState *s = pdu->s;
56 94840ff9 Aneesh Kumar K.V
57 bccacf6c Aneesh Kumar K.V
    if (v9fs_request_cancelled(pdu)) {
58 bccacf6c Aneesh Kumar K.V
        return -EINTR;
59 bccacf6c Aneesh Kumar K.V
    }
60 532decb7 Aneesh Kumar K.V
    v9fs_path_read_lock(s);
61 94840ff9 Aneesh Kumar K.V
    v9fs_co_run_in_worker(
62 94840ff9 Aneesh Kumar K.V
        {
63 2289be19 Aneesh Kumar K.V
            err = s->ops->statfs(&s->ctx, path, stbuf);
64 94840ff9 Aneesh Kumar K.V
            if (err < 0) {
65 94840ff9 Aneesh Kumar K.V
                err = -errno;
66 94840ff9 Aneesh Kumar K.V
            }
67 94840ff9 Aneesh Kumar K.V
        });
68 532decb7 Aneesh Kumar K.V
    v9fs_path_unlock(s);
69 94840ff9 Aneesh Kumar K.V
    return err;
70 94840ff9 Aneesh Kumar K.V
}
71 4011ead2 Aneesh Kumar K.V
72 bccacf6c Aneesh Kumar K.V
int v9fs_co_chmod(V9fsPDU *pdu, V9fsPath *path, mode_t mode)
73 4011ead2 Aneesh Kumar K.V
{
74 4011ead2 Aneesh Kumar K.V
    int err;
75 4011ead2 Aneesh Kumar K.V
    FsCred cred;
76 bccacf6c Aneesh Kumar K.V
    V9fsState *s = pdu->s;
77 4011ead2 Aneesh Kumar K.V
78 bccacf6c Aneesh Kumar K.V
    if (v9fs_request_cancelled(pdu)) {
79 bccacf6c Aneesh Kumar K.V
        return -EINTR;
80 bccacf6c Aneesh Kumar K.V
    }
81 4011ead2 Aneesh Kumar K.V
    cred_init(&cred);
82 4011ead2 Aneesh Kumar K.V
    cred.fc_mode = mode;
83 532decb7 Aneesh Kumar K.V
    v9fs_path_read_lock(s);
84 4011ead2 Aneesh Kumar K.V
    v9fs_co_run_in_worker(
85 4011ead2 Aneesh Kumar K.V
        {
86 2289be19 Aneesh Kumar K.V
            err = s->ops->chmod(&s->ctx, path, &cred);
87 4011ead2 Aneesh Kumar K.V
            if (err < 0) {
88 4011ead2 Aneesh Kumar K.V
                err = -errno;
89 4011ead2 Aneesh Kumar K.V
            }
90 4011ead2 Aneesh Kumar K.V
        });
91 532decb7 Aneesh Kumar K.V
    v9fs_path_unlock(s);
92 4011ead2 Aneesh Kumar K.V
    return err;
93 4011ead2 Aneesh Kumar K.V
}
94 4011ead2 Aneesh Kumar K.V
95 bccacf6c Aneesh Kumar K.V
int v9fs_co_utimensat(V9fsPDU *pdu, V9fsPath *path,
96 4011ead2 Aneesh Kumar K.V
                      struct timespec times[2])
97 4011ead2 Aneesh Kumar K.V
{
98 4011ead2 Aneesh Kumar K.V
    int err;
99 bccacf6c Aneesh Kumar K.V
    V9fsState *s = pdu->s;
100 4011ead2 Aneesh Kumar K.V
101 bccacf6c Aneesh Kumar K.V
    if (v9fs_request_cancelled(pdu)) {
102 bccacf6c Aneesh Kumar K.V
        return -EINTR;
103 bccacf6c Aneesh Kumar K.V
    }
104 532decb7 Aneesh Kumar K.V
    v9fs_path_read_lock(s);
105 4011ead2 Aneesh Kumar K.V
    v9fs_co_run_in_worker(
106 4011ead2 Aneesh Kumar K.V
        {
107 2289be19 Aneesh Kumar K.V
            err = s->ops->utimensat(&s->ctx, path, times);
108 4011ead2 Aneesh Kumar K.V
            if (err < 0) {
109 4011ead2 Aneesh Kumar K.V
                err = -errno;
110 4011ead2 Aneesh Kumar K.V
            }
111 4011ead2 Aneesh Kumar K.V
        });
112 532decb7 Aneesh Kumar K.V
    v9fs_path_unlock(s);
113 4011ead2 Aneesh Kumar K.V
    return err;
114 4011ead2 Aneesh Kumar K.V
}
115 4011ead2 Aneesh Kumar K.V
116 bccacf6c Aneesh Kumar K.V
int v9fs_co_chown(V9fsPDU *pdu, V9fsPath *path, uid_t uid, gid_t gid)
117 4011ead2 Aneesh Kumar K.V
{
118 4011ead2 Aneesh Kumar K.V
    int err;
119 4011ead2 Aneesh Kumar K.V
    FsCred cred;
120 bccacf6c Aneesh Kumar K.V
    V9fsState *s = pdu->s;
121 4011ead2 Aneesh Kumar K.V
122 bccacf6c Aneesh Kumar K.V
    if (v9fs_request_cancelled(pdu)) {
123 bccacf6c Aneesh Kumar K.V
        return -EINTR;
124 bccacf6c Aneesh Kumar K.V
    }
125 4011ead2 Aneesh Kumar K.V
    cred_init(&cred);
126 4011ead2 Aneesh Kumar K.V
    cred.fc_uid = uid;
127 4011ead2 Aneesh Kumar K.V
    cred.fc_gid = gid;
128 532decb7 Aneesh Kumar K.V
    v9fs_path_read_lock(s);
129 4011ead2 Aneesh Kumar K.V
    v9fs_co_run_in_worker(
130 4011ead2 Aneesh Kumar K.V
        {
131 2289be19 Aneesh Kumar K.V
            err = s->ops->chown(&s->ctx, path, &cred);
132 4011ead2 Aneesh Kumar K.V
            if (err < 0) {
133 4011ead2 Aneesh Kumar K.V
                err = -errno;
134 4011ead2 Aneesh Kumar K.V
            }
135 4011ead2 Aneesh Kumar K.V
        });
136 532decb7 Aneesh Kumar K.V
    v9fs_path_unlock(s);
137 4011ead2 Aneesh Kumar K.V
    return err;
138 4011ead2 Aneesh Kumar K.V
}
139 4011ead2 Aneesh Kumar K.V
140 bccacf6c Aneesh Kumar K.V
int v9fs_co_truncate(V9fsPDU *pdu, V9fsPath *path, off_t size)
141 4011ead2 Aneesh Kumar K.V
{
142 4011ead2 Aneesh Kumar K.V
    int err;
143 bccacf6c Aneesh Kumar K.V
    V9fsState *s = pdu->s;
144 4011ead2 Aneesh Kumar K.V
145 bccacf6c Aneesh Kumar K.V
    if (v9fs_request_cancelled(pdu)) {
146 bccacf6c Aneesh Kumar K.V
        return -EINTR;
147 bccacf6c Aneesh Kumar K.V
    }
148 532decb7 Aneesh Kumar K.V
    v9fs_path_read_lock(s);
149 4011ead2 Aneesh Kumar K.V
    v9fs_co_run_in_worker(
150 4011ead2 Aneesh Kumar K.V
        {
151 2289be19 Aneesh Kumar K.V
            err = s->ops->truncate(&s->ctx, path, size);
152 4011ead2 Aneesh Kumar K.V
            if (err < 0) {
153 4011ead2 Aneesh Kumar K.V
                err = -errno;
154 4011ead2 Aneesh Kumar K.V
            }
155 4011ead2 Aneesh Kumar K.V
        });
156 532decb7 Aneesh Kumar K.V
    v9fs_path_unlock(s);
157 4011ead2 Aneesh Kumar K.V
    return err;
158 4011ead2 Aneesh Kumar K.V
}
159 00ace8c5 Aneesh Kumar K.V
160 bccacf6c Aneesh Kumar K.V
int v9fs_co_mknod(V9fsPDU *pdu, V9fsFidState *fidp, V9fsString *name, uid_t uid,
161 02cb7f3a Aneesh Kumar K.V
                  gid_t gid, dev_t dev, mode_t mode, struct stat *stbuf)
162 00ace8c5 Aneesh Kumar K.V
{
163 00ace8c5 Aneesh Kumar K.V
    int err;
164 2289be19 Aneesh Kumar K.V
    V9fsPath path;
165 00ace8c5 Aneesh Kumar K.V
    FsCred cred;
166 bccacf6c Aneesh Kumar K.V
    V9fsState *s = pdu->s;
167 00ace8c5 Aneesh Kumar K.V
168 bccacf6c Aneesh Kumar K.V
    if (v9fs_request_cancelled(pdu)) {
169 bccacf6c Aneesh Kumar K.V
        return -EINTR;
170 bccacf6c Aneesh Kumar K.V
    }
171 00ace8c5 Aneesh Kumar K.V
    cred_init(&cred);
172 00ace8c5 Aneesh Kumar K.V
    cred.fc_uid  = uid;
173 00ace8c5 Aneesh Kumar K.V
    cred.fc_gid  = gid;
174 00ace8c5 Aneesh Kumar K.V
    cred.fc_mode = mode;
175 00ace8c5 Aneesh Kumar K.V
    cred.fc_rdev = dev;
176 532decb7 Aneesh Kumar K.V
    v9fs_path_read_lock(s);
177 00ace8c5 Aneesh Kumar K.V
    v9fs_co_run_in_worker(
178 00ace8c5 Aneesh Kumar K.V
        {
179 2289be19 Aneesh Kumar K.V
            err = s->ops->mknod(&s->ctx, &fidp->path, name->data, &cred);
180 00ace8c5 Aneesh Kumar K.V
            if (err < 0) {
181 00ace8c5 Aneesh Kumar K.V
                err = -errno;
182 02cb7f3a Aneesh Kumar K.V
            } else {
183 2289be19 Aneesh Kumar K.V
                v9fs_path_init(&path);
184 2289be19 Aneesh Kumar K.V
                err = v9fs_name_to_path(s, &fidp->path, name->data, &path);
185 2289be19 Aneesh Kumar K.V
                if (!err) {
186 2289be19 Aneesh Kumar K.V
                    err = s->ops->lstat(&s->ctx, &path, stbuf);
187 2289be19 Aneesh Kumar K.V
                    if (err < 0) {
188 2289be19 Aneesh Kumar K.V
                        err = -errno;
189 2289be19 Aneesh Kumar K.V
                    }
190 02cb7f3a Aneesh Kumar K.V
                }
191 2289be19 Aneesh Kumar K.V
                v9fs_path_free(&path);
192 00ace8c5 Aneesh Kumar K.V
            }
193 00ace8c5 Aneesh Kumar K.V
        });
194 532decb7 Aneesh Kumar K.V
    v9fs_path_unlock(s);
195 00ace8c5 Aneesh Kumar K.V
    return err;
196 00ace8c5 Aneesh Kumar K.V
}
197 b4b1537b Venkateswararao Jujjuri
198 2289be19 Aneesh Kumar K.V
/* Only works with path name based fid */
199 bccacf6c Aneesh Kumar K.V
int v9fs_co_remove(V9fsPDU *pdu, V9fsPath *path)
200 b4b1537b Venkateswararao Jujjuri
{
201 b4b1537b Venkateswararao Jujjuri
    int err;
202 bccacf6c Aneesh Kumar K.V
    V9fsState *s = pdu->s;
203 b4b1537b Venkateswararao Jujjuri
204 bccacf6c Aneesh Kumar K.V
    if (v9fs_request_cancelled(pdu)) {
205 bccacf6c Aneesh Kumar K.V
        return -EINTR;
206 bccacf6c Aneesh Kumar K.V
    }
207 532decb7 Aneesh Kumar K.V
    v9fs_path_read_lock(s);
208 b4b1537b Venkateswararao Jujjuri
    v9fs_co_run_in_worker(
209 b4b1537b Venkateswararao Jujjuri
        {
210 b4b1537b Venkateswararao Jujjuri
            err = s->ops->remove(&s->ctx, path->data);
211 b4b1537b Venkateswararao Jujjuri
            if (err < 0) {
212 b4b1537b Venkateswararao Jujjuri
                err = -errno;
213 b4b1537b Venkateswararao Jujjuri
            }
214 b4b1537b Venkateswararao Jujjuri
        });
215 532decb7 Aneesh Kumar K.V
    v9fs_path_unlock(s);
216 b4b1537b Venkateswararao Jujjuri
    return err;
217 b4b1537b Venkateswararao Jujjuri
}
218 2a487e05 Aneesh Kumar K.V
219 bccacf6c Aneesh Kumar K.V
int v9fs_co_unlinkat(V9fsPDU *pdu, V9fsPath *path, V9fsString *name, int flags)
220 2289be19 Aneesh Kumar K.V
{
221 2289be19 Aneesh Kumar K.V
    int err;
222 bccacf6c Aneesh Kumar K.V
    V9fsState *s = pdu->s;
223 2289be19 Aneesh Kumar K.V
224 bccacf6c Aneesh Kumar K.V
    if (v9fs_request_cancelled(pdu)) {
225 bccacf6c Aneesh Kumar K.V
        return -EINTR;
226 bccacf6c Aneesh Kumar K.V
    }
227 532decb7 Aneesh Kumar K.V
    v9fs_path_read_lock(s);
228 2289be19 Aneesh Kumar K.V
    v9fs_co_run_in_worker(
229 2289be19 Aneesh Kumar K.V
        {
230 2289be19 Aneesh Kumar K.V
            err = s->ops->unlinkat(&s->ctx, path, name->data, flags);
231 2289be19 Aneesh Kumar K.V
            if (err < 0) {
232 2289be19 Aneesh Kumar K.V
                err = -errno;
233 2289be19 Aneesh Kumar K.V
            }
234 2289be19 Aneesh Kumar K.V
        });
235 532decb7 Aneesh Kumar K.V
    v9fs_path_unlock(s);
236 2289be19 Aneesh Kumar K.V
    return err;
237 2289be19 Aneesh Kumar K.V
}
238 2289be19 Aneesh Kumar K.V
239 2289be19 Aneesh Kumar K.V
/* Only work with path name based fid */
240 bccacf6c Aneesh Kumar K.V
int v9fs_co_rename(V9fsPDU *pdu, V9fsPath *oldpath, V9fsPath *newpath)
241 2a487e05 Aneesh Kumar K.V
{
242 2a487e05 Aneesh Kumar K.V
    int err;
243 bccacf6c Aneesh Kumar K.V
    V9fsState *s = pdu->s;
244 2a487e05 Aneesh Kumar K.V
245 bccacf6c Aneesh Kumar K.V
    if (v9fs_request_cancelled(pdu)) {
246 bccacf6c Aneesh Kumar K.V
        return -EINTR;
247 bccacf6c Aneesh Kumar K.V
    }
248 2a487e05 Aneesh Kumar K.V
    v9fs_co_run_in_worker(
249 2a487e05 Aneesh Kumar K.V
        {
250 2a487e05 Aneesh Kumar K.V
            err = s->ops->rename(&s->ctx, oldpath->data, newpath->data);
251 2a487e05 Aneesh Kumar K.V
            if (err < 0) {
252 2a487e05 Aneesh Kumar K.V
                err = -errno;
253 2a487e05 Aneesh Kumar K.V
            }
254 2a487e05 Aneesh Kumar K.V
        });
255 2a487e05 Aneesh Kumar K.V
    return err;
256 2a487e05 Aneesh Kumar K.V
}
257 02ac7a34 Venkateswararao Jujjuri
258 bccacf6c Aneesh Kumar K.V
int v9fs_co_renameat(V9fsPDU *pdu, V9fsPath *olddirpath, V9fsString *oldname,
259 2289be19 Aneesh Kumar K.V
                     V9fsPath *newdirpath, V9fsString *newname)
260 2289be19 Aneesh Kumar K.V
{
261 2289be19 Aneesh Kumar K.V
    int err;
262 bccacf6c Aneesh Kumar K.V
    V9fsState *s = pdu->s;
263 2289be19 Aneesh Kumar K.V
264 bccacf6c Aneesh Kumar K.V
    if (v9fs_request_cancelled(pdu)) {
265 bccacf6c Aneesh Kumar K.V
        return -EINTR;
266 bccacf6c Aneesh Kumar K.V
    }
267 2289be19 Aneesh Kumar K.V
    v9fs_co_run_in_worker(
268 2289be19 Aneesh Kumar K.V
        {
269 2289be19 Aneesh Kumar K.V
            err = s->ops->renameat(&s->ctx, olddirpath, oldname->data,
270 2289be19 Aneesh Kumar K.V
                                   newdirpath, newname->data);
271 2289be19 Aneesh Kumar K.V
            if (err < 0) {
272 2289be19 Aneesh Kumar K.V
                err = -errno;
273 2289be19 Aneesh Kumar K.V
            }
274 2289be19 Aneesh Kumar K.V
        });
275 2289be19 Aneesh Kumar K.V
    return err;
276 2289be19 Aneesh Kumar K.V
}
277 2289be19 Aneesh Kumar K.V
278 bccacf6c Aneesh Kumar K.V
int v9fs_co_symlink(V9fsPDU *pdu, V9fsFidState *dfidp, V9fsString *name,
279 02cb7f3a Aneesh Kumar K.V
                    const char *oldpath, gid_t gid, struct stat *stbuf)
280 02ac7a34 Venkateswararao Jujjuri
{
281 02ac7a34 Venkateswararao Jujjuri
    int err;
282 02ac7a34 Venkateswararao Jujjuri
    FsCred cred;
283 2289be19 Aneesh Kumar K.V
    V9fsPath path;
284 bccacf6c Aneesh Kumar K.V
    V9fsState *s = pdu->s;
285 02cb7f3a Aneesh Kumar K.V
286 bccacf6c Aneesh Kumar K.V
    if (v9fs_request_cancelled(pdu)) {
287 bccacf6c Aneesh Kumar K.V
        return -EINTR;
288 bccacf6c Aneesh Kumar K.V
    }
289 02ac7a34 Venkateswararao Jujjuri
    cred_init(&cred);
290 02cb7f3a Aneesh Kumar K.V
    cred.fc_uid = dfidp->uid;
291 02ac7a34 Venkateswararao Jujjuri
    cred.fc_gid = gid;
292 02ac7a34 Venkateswararao Jujjuri
    cred.fc_mode = 0777;
293 532decb7 Aneesh Kumar K.V
    v9fs_path_read_lock(s);
294 02ac7a34 Venkateswararao Jujjuri
    v9fs_co_run_in_worker(
295 02ac7a34 Venkateswararao Jujjuri
        {
296 2289be19 Aneesh Kumar K.V
            err = s->ops->symlink(&s->ctx, oldpath, &dfidp->path,
297 2289be19 Aneesh Kumar K.V
                                  name->data, &cred);
298 02ac7a34 Venkateswararao Jujjuri
            if (err < 0) {
299 02ac7a34 Venkateswararao Jujjuri
                err = -errno;
300 02cb7f3a Aneesh Kumar K.V
            } else {
301 2289be19 Aneesh Kumar K.V
                v9fs_path_init(&path);
302 2289be19 Aneesh Kumar K.V
                err = v9fs_name_to_path(s, &dfidp->path, name->data, &path);
303 2289be19 Aneesh Kumar K.V
                if (!err) {
304 2289be19 Aneesh Kumar K.V
                    err = s->ops->lstat(&s->ctx, &path, stbuf);
305 2289be19 Aneesh Kumar K.V
                    if (err < 0) {
306 2289be19 Aneesh Kumar K.V
                        err = -errno;
307 2289be19 Aneesh Kumar K.V
                    }
308 02cb7f3a Aneesh Kumar K.V
                }
309 2289be19 Aneesh Kumar K.V
                v9fs_path_free(&path);
310 02ac7a34 Venkateswararao Jujjuri
            }
311 02ac7a34 Venkateswararao Jujjuri
        });
312 532decb7 Aneesh Kumar K.V
    v9fs_path_unlock(s);
313 2289be19 Aneesh Kumar K.V
    return err;
314 2289be19 Aneesh Kumar K.V
}
315 2289be19 Aneesh Kumar K.V
316 2289be19 Aneesh Kumar K.V
/*
317 2289be19 Aneesh Kumar K.V
 * For path name based fid we don't block. So we can
318 2289be19 Aneesh Kumar K.V
 * directly call the fs driver ops.
319 2289be19 Aneesh Kumar K.V
 */
320 bccacf6c Aneesh Kumar K.V
int v9fs_co_name_to_path(V9fsPDU *pdu, V9fsPath *dirpath,
321 2289be19 Aneesh Kumar K.V
                         const char *name, V9fsPath *path)
322 2289be19 Aneesh Kumar K.V
{
323 2289be19 Aneesh Kumar K.V
    int err;
324 bccacf6c Aneesh Kumar K.V
    V9fsState *s = pdu->s;
325 532decb7 Aneesh Kumar K.V
326 c98f1d4a Aneesh Kumar K.V
    if (s->ctx.export_flags & V9FS_PATHNAME_FSCONTEXT) {
327 532decb7 Aneesh Kumar K.V
        err = s->ops->name_to_path(&s->ctx, dirpath, name, path);
328 532decb7 Aneesh Kumar K.V
        if (err < 0) {
329 532decb7 Aneesh Kumar K.V
            err = -errno;
330 532decb7 Aneesh Kumar K.V
        }
331 532decb7 Aneesh Kumar K.V
    } else {
332 bccacf6c Aneesh Kumar K.V
        if (v9fs_request_cancelled(pdu)) {
333 bccacf6c Aneesh Kumar K.V
            return -EINTR;
334 bccacf6c Aneesh Kumar K.V
        }
335 532decb7 Aneesh Kumar K.V
        v9fs_co_run_in_worker(
336 532decb7 Aneesh Kumar K.V
            {
337 532decb7 Aneesh Kumar K.V
                err = s->ops->name_to_path(&s->ctx, dirpath, name, path);
338 532decb7 Aneesh Kumar K.V
                if (err < 0) {
339 532decb7 Aneesh Kumar K.V
                    err = -errno;
340 532decb7 Aneesh Kumar K.V
                }
341 532decb7 Aneesh Kumar K.V
            });
342 2289be19 Aneesh Kumar K.V
    }
343 02ac7a34 Venkateswararao Jujjuri
    return err;
344 02ac7a34 Venkateswararao Jujjuri
}