Changeset a8e9ab8d in mainline for uspace/lib/libfs/libfs.c
- Timestamp:
- 2008-03-09T17:18:30Z (17 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 4072980
- Parents:
- 2664838b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/libfs/libfs.c
r2664838b ra8e9ab8d 142 142 int dev_handle = IPC_GET_ARG3(*request); 143 143 int lflag = IPC_GET_ARG4(*request); 144 int index = IPC_GET_ARG5(*request); /* when L_LINK specified */ 144 145 145 146 if (last < next) … … 181 182 /* handle miss: match amongst siblings */ 182 183 if (!tmp) { 183 if ((next > last) && (lflag & L_CREATE)) { 184 /* no components left and L_CREATE specified */ 184 if (next <= last) { 185 /* there are unprocessed components */ 186 ipc_answer_0(rid, ENOENT); 187 return; 188 } 189 /* miss in the last component */ 190 if (lflag & (L_CREATE | L_LINK)) { 191 /* request to create a new link */ 185 192 if (!ops->is_directory(cur)) { 186 193 ipc_answer_0(rid, ENOTDIR); 187 194 return; 188 } 189 void *nodep = ops->create(lflag); 195 } 196 void *nodep; 197 if (lflag & L_CREATE) 198 nodep = ops->create(lflag); 199 else 200 nodep = ops->node_get(fs_handle, 201 dev_handle, index); 190 202 if (nodep) { 191 203 if (!ops->link(cur, nodep, component)) { 192 ops->destroy(nodep); 204 if (lflag & L_CREATE) 205 ops->destroy(nodep); 193 206 ipc_answer_0(rid, ENOSPC); 194 207 } else { 195 208 ipc_answer_5(rid, EOK, 196 209 fs_handle, dev_handle, 197 ops->index_get(nodep), 0, 210 ops->index_get(nodep), 211 ops->size_get(nodep), 198 212 ops->lnkcnt_get(nodep)); 199 213 } … … 202 216 } 203 217 return; 204 } 218 } else if (lflag & L_PARENT) { 219 /* return parent */ 220 ipc_answer_5(rid, EOK, fs_handle, dev_handle, 221 ops->index_get(cur), ops->size_get(cur), 222 ops->lnkcnt_get(cur)); 223 } 205 224 ipc_answer_0(rid, ENOENT); 206 225 return; … … 215 234 /* handle miss: excessive components */ 216 235 if (!tmp && next <= last) { 217 if (lflag & L_CREATE) {236 if (lflag & (L_CREATE | L_LINK)) { 218 237 if (!ops->is_directory(cur)) { 219 238 ipc_answer_0(rid, ENOTDIR); … … 240 259 len = 0; 241 260 242 void *nodep = ops->create(lflag); 261 void *nodep; 262 if (lflag & L_CREATE) 263 nodep = ops->create(lflag); 264 else 265 nodep = ops->node_get(fs_handle, dev_handle, 266 index); 243 267 if (nodep) { 244 268 if (!ops->link(cur, nodep, component)) { 245 ops->destroy(nodep); 269 if (lflag & L_CREATE) 270 ops->destroy(nodep); 246 271 ipc_answer_0(rid, ENOSPC); 247 272 } else { 248 273 ipc_answer_5(rid, EOK, 249 274 fs_handle, dev_handle, 250 ops->index_get(nodep), 0, 275 ops->index_get(nodep), 276 ops->size_get(nodep), 251 277 ops->lnkcnt_get(nodep)); 252 278 } … … 261 287 262 288 /* handle hit */ 263 if (lflag & L_DESTROY) { 289 if (lflag & L_PARENT) { 290 cur = par; 291 if (!cur) { 292 ipc_answer_0(rid, ENOENT); 293 return; 294 } 295 } 296 if (lflag & L_UNLINK) { 264 297 unsigned old_lnkcnt = ops->lnkcnt_get(cur); 265 298 int res = ops->unlink(par, cur); … … 268 301 return; 269 302 } 270 if ((lflag & (L_CREATE | L_EXCLUSIVE)) == (L_CREATE | L_EXCLUSIVE)) { 303 if (((lflag & (L_CREATE | L_EXCLUSIVE)) == (L_CREATE | L_EXCLUSIVE)) || 304 (lflag & L_LINK)) { 271 305 ipc_answer_0(rid, EEXIST); 272 306 return;
Note:
See TracChangeset
for help on using the changeset viewer.