Changeset 79dbc3e in mainline
- Timestamp:
- 2008-04-08T01:19:31Z (17 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 5446bee0
- Parents:
- f689a3e
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/fat/fat_ops.c
rf689a3e r79dbc3e 83 83 } 84 84 85 static fat_dentry_t *fat_dentry_get(fat_node_t *dirnode, unsigned idx) 85 /* TODO and also move somewhere else */ 86 typedef struct { 87 void *data; 88 } block_t; 89 90 static block_t *block_get(dev_handle_t dev_handle, off_t offset) 86 91 { 87 92 return NULL; /* TODO */ 88 93 } 89 94 90 static void fat_dentry_put(fat_dentry_t *dentry) 95 static block_t *fat_block_get(fat_node_t *node, off_t offset) { 96 return NULL; /* TODO */ 97 } 98 99 static void block_put(block_t *block) 91 100 { 92 101 /* TODO */ … … 97 106 return NULL; /* TODO */ 98 107 } 108 109 #define BS_BLOCK 0 99 110 100 111 static void *fat_match(void *prnt, const char *component) … … 102 113 fat_node_t *parentp = (fat_node_t *)prnt; 103 114 char name[FAT_NAME_LEN + 1 + FAT_EXT_LEN + 1]; 104 unsigned i; 105 unsigned dentries; 115 unsigned i, j; 116 unsigned dps; /* dentries per sector */ 117 unsigned blocks; 106 118 fat_dentry_t *d; 107 108 dentries = parentp->size / sizeof(fat_dentry_t); 109 for (i = 0; i < dentries; i++) { 110 d = fat_dentry_get(parentp, i); 111 if (d->attr & FAT_ATTR_VOLLABEL) { 112 /* volume label entry */ 113 fat_dentry_put(d); 114 continue; 119 block_t *bb; 120 block_t *b; 121 fat_bs_t *bs; 122 123 bb = block_get(parentp->dev_handle, BS_BLOCK); 124 if (!bb) 125 return NULL; 126 bs = (fat_bs_t *)bb->data; 127 dps = bs->bps / sizeof(fat_dentry_t); 128 blocks = parentp->size / bs->bps + (parentp->size % bs->bps != 0); 129 block_put(bb); 130 for (i = 0; i < blocks; i++) { 131 unsigned dentries; 132 133 b = fat_block_get(parentp, i); 134 if (!b) 135 return NULL; 136 137 dentries = (i == blocks - 1) ? 138 parentp->size % sizeof(fat_dentry_t) : 139 dps; 140 for (j = 0; j < dentries; j++) { 141 d = ((fat_dentry_t *)b->data) + j; 142 if (d->attr & FAT_ATTR_VOLLABEL) { 143 /* volume label entry */ 144 continue; 145 } 146 if (d->name[0] == FAT_DENTRY_ERASED) { 147 /* not-currently-used entry */ 148 continue; 149 } 150 if (d->name[0] == FAT_DENTRY_UNUSED) { 151 /* never used entry */ 152 block_put(b); 153 return NULL; 154 } 155 if (d->name[0] == FAT_DENTRY_DOT) { 156 /* 157 * Most likely '.' or '..'. 158 * It cannot occur in a regular file name. 159 */ 160 continue; 161 } 162 163 dentry_name_canonify(d, name); 164 if (strcmp(name, component) == 0) { 165 /* hit */ 166 void *node = fat_node_get(parentp->dev_handle, 167 (fs_index_t)uint16_t_le2host(d->firstc)); 168 block_put(b); 169 return node; 170 } 115 171 } 116 if (d->name[0] == FAT_DENTRY_ERASED) { 117 /* not-currently-used entry */ 118 fat_dentry_put(d); 119 continue; 120 } 121 if (d->name[0] == FAT_DENTRY_UNUSED) { 122 /* never used entry */ 123 fat_dentry_put(d); 124 break; 125 } 126 if (d->name[0] == FAT_DENTRY_DOT) { 127 /* 128 * Most likely '.' or '..'. 129 * It cannot occur in a regular file name. 130 */ 131 fat_dentry_put(d); 132 continue; 133 } 134 135 dentry_name_canonify(d, name); 136 if (strcmp(name, component) == 0) { 137 /* hit */ 138 void *node = fat_node_get(parentp->dev_handle, 139 (fs_index_t)uint16_t_le2host(d->firstc)); 140 fat_dentry_put(d); 141 return node; 142 143 } else { 144 /* miss */ 145 fat_dentry_put(d); 146 } 172 block_put(b); 147 173 } 148 174
Note:
See TracChangeset
for help on using the changeset viewer.