Rev 3675 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 3675 | Rev 4377 | ||
|---|---|---|---|
| Line 146... | Line 146... | ||
| 146 | int len; |
146 | int len; |
| 147 | 147 | ||
| 148 | if (last < next) |
148 | if (last < next) |
| 149 | last += PLB_SIZE; |
149 | last += PLB_SIZE; |
| 150 | 150 | ||
| 151 | void *par = NULL; |
151 | fs_node_t *par = NULL; |
| 152 | void *cur = ops->root_get(dev_handle); |
152 | fs_node_t *cur = ops->root_get(dev_handle); |
| 153 | void *tmp = NULL; |
153 | fs_node_t *tmp = NULL; |
| 154 | 154 | ||
| 155 | if (ops->plb_get_char(next) == '/') |
155 | if (ops->plb_get_char(next) == '/') |
| 156 | next++; /* eat slash */ |
156 | next++; /* eat slash */ |
| 157 | 157 | ||
| 158 | while (next <= last && ops->has_children(cur)) { |
158 | while (next <= last && ops->has_children(cur)) { |
| Line 187... | Line 187... | ||
| 187 | /* request to create a new link */ |
187 | /* request to create a new link */ |
| 188 | if (!ops->is_directory(cur)) { |
188 | if (!ops->is_directory(cur)) { |
| 189 | ipc_answer_0(rid, ENOTDIR); |
189 | ipc_answer_0(rid, ENOTDIR); |
| 190 | goto out; |
190 | goto out; |
| 191 | } |
191 | } |
| 192 | void *nodep; |
192 | fs_node_t *fn; |
| 193 | if (lflag & L_CREATE) |
193 | if (lflag & L_CREATE) |
| 194 | nodep = ops->create(dev_handle, lflag); |
194 | fn = ops->create(dev_handle, lflag); |
| 195 | else |
195 | else |
| 196 | nodep = ops->node_get(dev_handle, |
196 | fn = ops->node_get(dev_handle, |
| 197 | index); |
197 | index); |
| 198 | if (nodep) { |
198 | if (fn) { |
| 199 | int rc; |
199 | int rc; |
| 200 | 200 | ||
| 201 | rc = ops->link(cur, nodep, component); |
201 | rc = ops->link(cur, fn, component); |
| 202 | if (rc != EOK) { |
202 | if (rc != EOK) { |
| 203 | if (lflag & L_CREATE) { |
203 | if (lflag & L_CREATE) { |
| 204 | (void)ops->destroy( |
204 | (void)ops->destroy(fn); |
| 205 | nodep); |
- | |
| 206 | } |
205 | } |
| 207 | ipc_answer_0(rid, rc); |
206 | ipc_answer_0(rid, rc); |
| 208 | } else { |
207 | } else { |
| 209 | ipc_answer_5(rid, EOK, |
208 | ipc_answer_5(rid, EOK, |
| 210 | fs_handle, dev_handle, |
209 | fs_handle, dev_handle, |
| 211 | ops->index_get(nodep), |
210 | ops->index_get(fn), |
| 212 | ops->size_get(nodep), |
211 | ops->size_get(fn), |
| 213 | ops->lnkcnt_get(nodep)); |
212 | ops->lnkcnt_get(fn)); |
| 214 | ops->node_put(nodep); |
213 | ops->node_put(fn); |
| 215 | } |
214 | } |
| 216 | } else { |
215 | } else { |
| 217 | ipc_answer_0(rid, ENOSPC); |
216 | ipc_answer_0(rid, ENOSPC); |
| 218 | } |
217 | } |
| 219 | goto out; |
218 | goto out; |
| 220 | } else if (lflag & L_PARENT) { |
- | |
| 221 | /* return parent */ |
- | |
| 222 | ipc_answer_5(rid, EOK, fs_handle, dev_handle, |
- | |
| 223 | ops->index_get(cur), ops->size_get(cur), |
- | |
| 224 | ops->lnkcnt_get(cur)); |
- | |
| 225 | } |
219 | } |
| 226 | ipc_answer_0(rid, ENOENT); |
220 | ipc_answer_0(rid, ENOENT); |
| 227 | goto out; |
221 | goto out; |
| 228 | } |
222 | } |
| 229 | 223 | ||
| Line 261... | Line 255... | ||
| 261 | next++; /* process next character */ |
255 | next++; /* process next character */ |
| 262 | } |
256 | } |
| 263 | assert(len); |
257 | assert(len); |
| 264 | component[len] = '\0'; |
258 | component[len] = '\0'; |
| 265 | 259 | ||
| 266 | void *nodep; |
260 | fs_node_t *fn; |
| 267 | if (lflag & L_CREATE) |
261 | if (lflag & L_CREATE) |
| 268 | nodep = ops->create(dev_handle, lflag); |
262 | fn = ops->create(dev_handle, lflag); |
| 269 | else |
263 | else |
| 270 | nodep = ops->node_get(dev_handle, index); |
264 | fn = ops->node_get(dev_handle, index); |
| 271 | if (nodep) { |
265 | if (fn) { |
| 272 | int rc; |
266 | int rc; |
| 273 | 267 | ||
| 274 | rc = ops->link(cur, nodep, component); |
268 | rc = ops->link(cur, fn, component); |
| 275 | if (rc != EOK) { |
269 | if (rc != EOK) { |
| 276 | if (lflag & L_CREATE) |
270 | if (lflag & L_CREATE) |
| 277 | (void)ops->destroy(nodep); |
271 | (void)ops->destroy(fn); |
| 278 | ipc_answer_0(rid, rc); |
272 | ipc_answer_0(rid, rc); |
| 279 | } else { |
273 | } else { |
| 280 | ipc_answer_5(rid, EOK, |
274 | ipc_answer_5(rid, EOK, |
| 281 | fs_handle, dev_handle, |
275 | fs_handle, dev_handle, |
| 282 | ops->index_get(nodep), |
276 | ops->index_get(fn), |
| 283 | ops->size_get(nodep), |
277 | ops->size_get(fn), |
| 284 | ops->lnkcnt_get(nodep)); |
278 | ops->lnkcnt_get(fn)); |
| 285 | ops->node_put(nodep); |
279 | ops->node_put(fn); |
| 286 | } |
280 | } |
| 287 | } else { |
281 | } else { |
| 288 | ipc_answer_0(rid, ENOSPC); |
282 | ipc_answer_0(rid, ENOSPC); |
| 289 | } |
283 | } |
| 290 | goto out; |
284 | goto out; |
| Line 292... | Line 286... | ||
| 292 | ipc_answer_0(rid, ENOENT); |
286 | ipc_answer_0(rid, ENOENT); |
| 293 | goto out; |
287 | goto out; |
| 294 | } |
288 | } |
| 295 | 289 | ||
| 296 | /* handle hit */ |
290 | /* handle hit */ |
| 297 | if (lflag & L_PARENT) { |
- | |
| 298 | ops->node_put(cur); |
- | |
| 299 | cur = par; |
- | |
| 300 | par = NULL; |
- | |
| 301 | if (!cur) { |
- | |
| 302 | ipc_answer_0(rid, ENOENT); |
- | |
| 303 | goto out; |
- | |
| 304 | } |
- | |
| 305 | } |
- | |
| 306 | if (lflag & L_UNLINK) { |
291 | if (lflag & L_UNLINK) { |
| 307 | unsigned old_lnkcnt = ops->lnkcnt_get(cur); |
292 | unsigned old_lnkcnt = ops->lnkcnt_get(cur); |
| 308 | int res = ops->unlink(par, cur); |
293 | int res = ops->unlink(par, cur, component); |
| 309 | ipc_answer_5(rid, (ipcarg_t)res, fs_handle, dev_handle, |
294 | ipc_answer_5(rid, (ipcarg_t)res, fs_handle, dev_handle, |
| 310 | ops->index_get(cur), ops->size_get(cur), old_lnkcnt); |
295 | ops->index_get(cur), ops->size_get(cur), old_lnkcnt); |
| 311 | goto out; |
296 | goto out; |
| 312 | } |
297 | } |
| 313 | if (((lflag & (L_CREATE | L_EXCLUSIVE)) == (L_CREATE | L_EXCLUSIVE)) || |
298 | if (((lflag & (L_CREATE | L_EXCLUSIVE)) == (L_CREATE | L_EXCLUSIVE)) || |