Changes in / [990c70e:fd608dc] in mainline
- Location:
- uspace/srv/fs/fat
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/fat/fat_fat.c
r990c70e rfd608dc 247 247 */ 248 248 int 249 fat_get_cluster(fat_bs_t *bs, dev_handle_t dev_handle, unsigned fatno,250 fat_cluster_t clst, fat_cluster_t*value)249 fat_get_cluster(fat_bs_t *bs, dev_handle_t dev_handle, fat_cluster_t clst, 250 fat_cluster_t *value) 251 251 { 252 252 block_t *b; 253 253 uint16_t bps; 254 254 uint16_t rscnt; 255 uint16_t sf;256 255 fat_cluster_t *cp; 257 256 int rc; … … 259 258 bps = uint16_t_le2host(bs->bps); 260 259 rscnt = uint16_t_le2host(bs->rscnt); 261 sf = uint16_t_le2host(bs->sec_per_fat); 262 263 rc = block_get(&b, dev_handle, rscnt + sf * fatno + 260 261 rc = block_get(&b, dev_handle, rscnt + 264 262 (clst * sizeof(fat_cluster_t)) / bps, BLOCK_FLAGS_NONE); 265 263 if (rc != EOK) … … 482 480 while (firstc < FAT_CLST_LAST1) { 483 481 assert(firstc >= FAT_CLST_FIRST && firstc < FAT_CLST_BAD); 484 rc = fat_get_cluster(bs, dev_handle, FAT1,firstc, &nextc);482 rc = fat_get_cluster(bs, dev_handle, firstc, &nextc); 485 483 if (rc != EOK) 486 484 return rc; … … 562 560 unsigned fatno; 563 561 564 rc = fat_get_cluster(bs, dev_handle, FAT1,lastc, &nextc);562 rc = fat_get_cluster(bs, dev_handle, lastc, &nextc); 565 563 if (rc != EOK) 566 564 return rc; -
uspace/srv/fs/fat/fat_fat.h
r990c70e rfd608dc 80 80 extern int fat_alloc_shadow_clusters(struct fat_bs *, dev_handle_t, 81 81 fat_cluster_t *, unsigned); 82 extern int fat_get_cluster(struct fat_bs *, dev_handle_t, unsigned,83 fat_cluster_t , fat_cluster_t*);82 extern int fat_get_cluster(struct fat_bs *, dev_handle_t, fat_cluster_t, 83 fat_cluster_t *); 84 84 extern int fat_set_cluster(struct fat_bs *, dev_handle_t, unsigned, 85 85 fat_cluster_t, fat_cluster_t); -
uspace/srv/fs/fat/fat_ops.c
r990c70e rfd608dc 290 290 291 291 *nodepp = nodep; 292 return EOK;293 }294 295 /** Perform basic sanity checks on the file system.296 *297 * Verify if values of boot sector fields are sane. Also verify media298 * descriptor. This is used to rule out cases when a device obviously299 * does not contain a fat file system.300 */301 static int fat_sanity_check(fat_bs_t *bs, dev_handle_t dev_handle)302 {303 fat_cluster_t e0, e1;304 unsigned fat_no;305 int rc;306 307 printf("fatcnt\n");308 /* Check number of FATs. */309 if (bs->fatcnt == 0)310 return ENOTSUP;311 312 /* Check total number of sectors. */313 314 printf("totsec\n");315 if (bs->totsec16 == 0 && bs->totsec32 == 0)316 return ENOTSUP;317 318 if (bs->totsec16 != 0 && bs->totsec32 != 0 &&319 bs->totsec16 != bs->totsec32)320 return ENOTSUP;321 322 printf("mdesc\n");323 /* Check media descriptor. Must be between 0xf0 and 0xff. */324 if ((bs->mdesc & 0xf0) != 0xf0)325 return ENOTSUP;326 327 printf("sec_per_fat\n");328 /* Check number of sectors per FAT. */329 if (bs->sec_per_fat == 0)330 return ENOTSUP;331 332 /* Check signature of each FAT. */333 334 for (fat_no = 0; fat_no < bs->fatcnt; fat_no++) {335 printf("clst-read\n");336 rc = fat_get_cluster(bs, dev_handle, fat_no, 0, &e0);337 if (rc != EOK)338 return EIO;339 340 rc = fat_get_cluster(bs, dev_handle, fat_no, 1, &e1);341 if (rc != EOK)342 return EIO;343 344 printf("mdesc-fat\n");345 /* Check that first byte of FAT contains the media descriptor. */346 if ((e0 & 0xff) != bs->mdesc)347 return ENOTSUP;348 349 printf("fat-signat\n");350 /*351 * Check that remaining bits of the first two entries are352 * set to one.353 */354 if ((e0 >> 8) != 0xff || e1 != 0xffff)355 return ENOTSUP;356 }357 358 292 return EOK; 359 293 } … … 1047 981 } 1048 982 1049 /* Do some simple sanity checks on the boot blocks. */1050 rc = fat_sanity_check(bs, dev_handle);1051 if (rc != EOK) {1052 block_fini(dev_handle);1053 ipc_answer_0(rid, rc);1054 return;1055 }1056 1057 983 rc = fat_idx_init_by_dev_handle(dev_handle); 1058 984 if (rc != EOK) {
Note:
See TracChangeset
for help on using the changeset viewer.
