Changeset 32fb10ed in mainline
- Timestamp:
- 2008-04-12T23:13:51Z (17 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 9ad75d5
- Parents:
- 74ea3c6
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/fat/fat_ops.c
r74ea3c6 r32fb10ed 144 144 } 145 145 146 typedef enum { 147 FAT_DENTRY_SKIP, 148 FAT_DENTRY_LAST, 149 FAT_DENTRY_VALID 150 } fat_dentry_clsf_t; 151 152 static fat_dentry_clsf_t fat_classify_dentry(fat_dentry_t *d) 153 { 154 if (d->attr & FAT_ATTR_VOLLABEL) { 155 /* volume label entry */ 156 return FAT_DENTRY_SKIP; 157 } 158 if (d->name[0] == FAT_DENTRY_ERASED) { 159 /* not-currently-used entry */ 160 return FAT_DENTRY_SKIP; 161 } 162 if (d->name[0] == FAT_DENTRY_UNUSED) { 163 /* never used entry */ 164 return FAT_DENTRY_LAST; 165 } 166 if (d->name[0] == FAT_DENTRY_DOT) { 167 /* 168 * Most likely '.' or '..'. 169 * It cannot occur in a regular file name. 170 */ 171 return FAT_DENTRY_SKIP; 172 } 173 return FAT_DENTRY_VALID; 174 } 175 146 176 static void fat_sync_node(fat_node_t *node) 147 177 { … … 222 252 for (i = 0; ; i++) { 223 253 b = fat_block_get(node->dev_handle, node->pindex, i); 224 if (!b) {225 node->refcnt--;226 list_append(&node->ffn_link, &ffn_head);227 return NULL;228 }229 254 for (j = 0; j < dps; j++) { 230 255 d = ((fat_dentry_t *)b->data) + j; … … 270 295 271 296 b = fat_block_get(parentp->dev_handle, parentp->index, i); 272 if (!b)273 return NULL;274 275 297 dentries = (i == blocks - 1) ? 276 298 parentp->size % sizeof(fat_dentry_t) : … … 278 300 for (j = 0; j < dentries; j++) { 279 301 d = ((fat_dentry_t *)b->data) + j; 280 if (d->attr & FAT_ATTR_VOLLABEL) {281 /* volume label entry */302 switch (fat_classify_dentry(d)) { 303 case FAT_DENTRY_SKIP: 282 304 continue; 283 } 284 if (d->name[0] == FAT_DENTRY_ERASED) { 285 /* not-currently-used entry */ 286 continue; 287 } 288 if (d->name[0] == FAT_DENTRY_UNUSED) { 289 /* never used entry */ 305 case FAT_DENTRY_LAST: 290 306 block_put(b); 291 307 return NULL; 308 default: 309 case FAT_DENTRY_VALID: 310 dentry_name_canonify(d, name); 311 break; 292 312 } 293 if (d->name[0] == FAT_DENTRY_DOT) {294 /*295 * Most likely '.' or '..'.296 * It cannot occur in a regular file name.297 */298 continue;299 }300 301 dentry_name_canonify(d, name);302 313 if (strcmp(name, component) == 0) { 303 314 /* hit */ … … 331 342 { 332 343 return ((fat_node_t *)node)->lnkcnt; 344 } 345 346 static bool fat_has_children(void *node) 347 { 348 fat_node_t *nodep = (fat_node_t *)node; 349 unsigned bps; 350 unsigned dps; 351 unsigned blocks; 352 block_t *b; 353 unsigned i, j; 354 355 if (nodep->type != FAT_DIRECTORY) 356 return false; 357 358 bps = fat_bps_get(nodep->dev_handle); 359 dps = bps / sizeof(fat_dentry_t); 360 361 blocks = nodep->size / bps + (nodep->size % bps != 0); 362 363 for (i = 0; i < blocks; i++) { 364 unsigned dentries; 365 fat_dentry_t *d; 366 367 b = fat_block_get(nodep->dev_handle, nodep->index, i); 368 dentries = (i == blocks - 1) ? 369 nodep->size % sizeof(fat_dentry_t) : 370 dps; 371 for (j = 0; j < dentries; j++) { 372 d = ((fat_dentry_t *)b->data) + j; 373 switch (fat_classify_dentry(d)) { 374 case FAT_DENTRY_SKIP: 375 continue; 376 case FAT_DENTRY_LAST: 377 block_put(b); 378 return false; 379 default: 380 case FAT_DENTRY_VALID: 381 block_put(b); 382 return true; 383 } 384 block_put(b); 385 return true; 386 } 387 block_put(b); 388 } 389 390 return false; 333 391 } 334 392 … … 364 422 .size_get = fat_size_get, 365 423 .lnkcnt_get = fat_lnkcnt_get, 366 .has_children = NULL,424 .has_children = fat_has_children, 367 425 .root_get = fat_root_get, 368 426 .plb_get_char = fat_plb_get_char,
Note:
See TracChangeset
for help on using the changeset viewer.