Changeset 711e1f32 in mainline
- Timestamp:
- 2010-01-13T21:33:58Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 2ffaab5, 990c70e
- Parents:
- 65737d4
- Location:
- uspace/srv/fs/fat
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/fat/fat_fat.c
r65737d4 r711e1f32 247 247 */ 248 248 int 249 fat_get_cluster(fat_bs_t *bs, dev_handle_t dev_handle, fat_cluster_t clst,250 fat_cluster_t *value)249 fat_get_cluster(fat_bs_t *bs, dev_handle_t dev_handle, unsigned fatno, 250 fat_cluster_t clst, 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; 255 256 fat_cluster_t *cp; 256 257 int rc; … … 258 259 bps = uint16_t_le2host(bs->bps); 259 260 rscnt = uint16_t_le2host(bs->rscnt); 260 261 rc = block_get(&b, dev_handle, rscnt + 261 sf = uint16_t_le2host(bs->sec_per_fat); 262 263 rc = block_get(&b, dev_handle, rscnt + sf * fatno + 262 264 (clst * sizeof(fat_cluster_t)) / bps, BLOCK_FLAGS_NONE); 263 265 if (rc != EOK) … … 480 482 while (firstc < FAT_CLST_LAST1) { 481 483 assert(firstc >= FAT_CLST_FIRST && firstc < FAT_CLST_BAD); 482 rc = fat_get_cluster(bs, dev_handle, firstc, &nextc);484 rc = fat_get_cluster(bs, dev_handle, FAT1, firstc, &nextc); 483 485 if (rc != EOK) 484 486 return rc; … … 560 562 unsigned fatno; 561 563 562 rc = fat_get_cluster(bs, dev_handle, lastc, &nextc);564 rc = fat_get_cluster(bs, dev_handle, FAT1, lastc, &nextc); 563 565 if (rc != EOK) 564 566 return rc; -
uspace/srv/fs/fat/fat_fat.h
r65737d4 r711e1f32 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, fat_cluster_t,83 fat_cluster_t *);82 extern int fat_get_cluster(struct fat_bs *, dev_handle_t, unsigned, 83 fat_cluster_t, 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
r65737d4 r711e1f32 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 media 298 * descriptor. This is used to rule out cases when a device obviously 299 * 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 are 352 * set to one. 353 */ 354 if ((e0 >> 8) != 0xff || e1 != 0xffff) 355 return ENOTSUP; 356 } 357 292 358 return EOK; 293 359 } … … 981 1047 } 982 1048 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 983 1057 rc = fat_idx_init_by_dev_handle(dev_handle); 984 1058 if (rc != EOK) {
Note:
See TracChangeset
for help on using the changeset viewer.