Changeset c91f2d1b in mainline
- Timestamp:
- 2009-08-27T18:31:27Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- cd688d9
- Parents:
- 02ee6bf5
- Location:
- uspace
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bdsh/cmds/modules/bdd/bdd.c
r02ee6bf5 rc91f2d1b 40 40 #include <devmap.h> 41 41 #include <errno.h> 42 #include <assert.h> 42 43 43 44 #define BLOCK_SIZE 512 … … 110 111 111 112 while (size > 0) { 112 block = block_get(handle, boff, 0); 113 rc = block_get(&block, handle, boff, 0); 114 assert(rc == EOK); 113 115 blk = (uint8_t *) block->data; 114 116 … … 139 141 } 140 142 141 block_put(block); 143 rc = block_put(block); 144 assert(rc == EOK); 142 145 143 146 if (size > rows * BPR) -
uspace/lib/libblock/libblock.c
r02ee6bf5 rc91f2d1b 313 313 /** Instantiate a block in memory and get a reference to it. 314 314 * 315 * @param block Pointer to where the function will store the 316 * block pointer on success. 315 317 * @param dev_handle Device handle of the block device. 316 318 * @param boff Block offset. … … 319 321 * device. 320 322 * 321 * @return Block structure.322 */ 323 block_t *block_get(dev_handle_t dev_handle, bn_t boff, int flags)323 * @return EOK on success or a negative error code. 324 */ 325 int block_get(block_t **block, dev_handle_t dev_handle, bn_t boff, int flags) 324 326 { 325 327 devcon_t *devcon; … … 450 452 fibril_mutex_unlock(&b->lock); 451 453 } 452 return b; 454 *block = b; 455 return EOK; 453 456 } 454 457 … … 458 461 * 459 462 * @param block Block of which a reference is to be released. 460 */ 461 void block_put(block_t *block) 463 * 464 * @return EOK on success or a negative error code. 465 */ 466 int block_put(block_t *block) 462 467 { 463 468 devcon_t *devcon = devcon_search(block->dev_handle); … … 546 551 fibril_mutex_unlock(&block->lock); 547 552 fibril_mutex_unlock(&cache->lock); 553 554 return EOK; 548 555 } 549 556 -
uspace/lib/libblock/libblock.h
r02ee6bf5 rc91f2d1b 101 101 extern int block_cache_init(dev_handle_t, size_t, unsigned, enum cache_mode); 102 102 103 extern block_t *block_get(dev_handle_t, bn_t, int);104 extern voidblock_put(block_t *);103 extern int block_get(block_t **, dev_handle_t, bn_t, int); 104 extern int block_put(block_t *); 105 105 106 106 extern int block_seqread(dev_handle_t, off_t *, size_t *, off_t *, void *, -
uspace/srv/fs/fat/fat_fat.c
r02ee6bf5 rc91f2d1b 75 75 uint16_t clusters = 0; 76 76 fat_cluster_t clst = firstc; 77 int rc; 77 78 78 79 bps = uint16_t_le2host(bs->bps); … … 96 97 fidx = clst % (bps / sizeof(fat_cluster_t)); 97 98 /* read FAT1 */ 98 b = block_get(dev_handle, rscnt + fsec, BLOCK_FLAGS_NONE); 99 rc = block_get(&b, dev_handle, rscnt + fsec, BLOCK_FLAGS_NONE); 100 assert(rc == EOK); 99 101 clst = uint16_t_le2host(((fat_cluster_t *)b->data)[fidx]); 100 102 assert(clst != FAT_CLST_BAD); 101 block_put(b); 103 rc = block_put(b); 104 assert(rc == EOK); 102 105 clusters++; 103 106 } … … 133 136 unsigned clusters, max_clusters; 134 137 fat_cluster_t lastc; 138 int rc; 135 139 136 140 bps = uint16_t_le2host(bs->bps); … … 146 150 /* root directory special case */ 147 151 assert(bn < rds); 148 b = block_get(dev_handle, rscnt + bs->fatcnt * sf + bn, flags); 152 rc = block_get(&b, dev_handle, rscnt + bs->fatcnt * sf + bn, 153 flags); 154 assert(rc == EOK); 149 155 return b; 150 156 } … … 155 161 assert(clusters == max_clusters); 156 162 157 b = block_get(dev_handle, ssa + (lastc - FAT_CLST_FIRST) * bs->spc + 158 bn % bs->spc, flags); 163 rc = block_get(&b, dev_handle, ssa + 164 (lastc - FAT_CLST_FIRST) * bs->spc + bn % bs->spc, flags); 165 assert(rc == EOK); 159 166 160 167 return b; … … 177 184 block_t *b; 178 185 off_t o, boundary; 186 int rc; 179 187 180 188 bps = uint16_t_le2host(bs->bps); … … 191 199 memset(b->data + o % bps, 0, bps - o % bps); 192 200 b->dirty = true; /* need to sync node */ 193 block_put(b); 201 rc = block_put(b); 202 assert(rc == EOK); 194 203 } 195 204 … … 203 212 memset(b->data, 0, min(bps, pos - o)); 204 213 b->dirty = true; /* need to sync node */ 205 block_put(b); 214 rc = block_put(b); 215 assert(rc == EOK); 206 216 } 207 217 } … … 222 232 uint16_t rscnt; 223 233 fat_cluster_t *cp, value; 234 int rc; 224 235 225 236 bps = uint16_t_le2host(bs->bps); 226 237 rscnt = uint16_t_le2host(bs->rscnt); 227 238 228 b = block_get(dev_handle, rscnt + (clst * sizeof(fat_cluster_t)) / bps, 229 BLOCK_FLAGS_NONE); 239 rc = block_get(&b, dev_handle, rscnt + 240 (clst * sizeof(fat_cluster_t)) / bps, BLOCK_FLAGS_NONE); 241 assert(rc == EOK); 230 242 cp = (fat_cluster_t *)b->data + clst % (bps / sizeof(fat_cluster_t)); 231 243 value = uint16_t_le2host(*cp); 232 block_put(b); 244 rc = block_put(b); 245 assert(rc == EOK); 233 246 234 247 return value; … … 252 265 uint16_t sf; 253 266 fat_cluster_t *cp; 267 int rc; 254 268 255 269 bps = uint16_t_le2host(bs->bps); … … 258 272 259 273 assert(fatno < bs->fatcnt); 260 b = block_get(dev_handle, rscnt + sf * fatno +274 rc = block_get(&b, dev_handle, rscnt + sf * fatno + 261 275 (clst * sizeof(fat_cluster_t)) / bps, BLOCK_FLAGS_NONE); 276 assert(rc == EOK); 262 277 cp = (fat_cluster_t *)b->data + clst % (bps / sizeof(fat_cluster_t)); 263 278 *cp = host2uint16_t_le(value); 264 279 b->dirty = true; /* need to sync block */ 265 block_put(b); 280 rc = block_put(b); 281 assert(rc == EOK); 266 282 } 267 283 … … 315 331 unsigned found = 0; /* top of the free cluster number stack */ 316 332 unsigned b, c, cl; 333 int rc; 317 334 318 335 lifo = (fat_cluster_t *) malloc(nclsts * sizeof(fat_cluster_t)); … … 329 346 fibril_mutex_lock(&fat_alloc_lock); 330 347 for (b = 0, cl = 0; b < sf; b++) { 331 blk = block_get(dev_handle, rscnt + b, BLOCK_FLAGS_NONE);348 rc = block_get(&blk, dev_handle, rscnt + b, BLOCK_FLAGS_NONE); 332 349 for (c = 0; c < bps / sizeof(fat_cluster_t); c++, cl++) { 333 350 fat_cluster_t *clst = (fat_cluster_t *)blk->data + c; … … 344 361 if (++found == nclsts) { 345 362 /* we are almost done */ 346 block_put(blk); 363 rc = block_put(blk); 364 assert(rc == EOK); 347 365 /* update the shadow copies of FAT */ 348 366 fat_alloc_shadow_clusters(bs, … … 356 374 } 357 375 } 358 block_put(blk); 376 rc = block_put(blk); 377 assert(rc == EOK); 359 378 } 360 379 fibril_mutex_unlock(&fat_alloc_lock); … … 457 476 block_t *b; 458 477 unsigned bps; 478 int rc; 459 479 460 480 bps = uint16_t_le2host(bs->bps); … … 464 484 memset(b->data, 0, bps); 465 485 b->dirty = true; 466 block_put(b); 486 rc = block_put(b); 487 assert(rc == EOK); 467 488 } 468 489 } -
uspace/srv/fs/fat/fat_ops.c
r02ee6bf5 rc91f2d1b 85 85 uint16_t bps; 86 86 unsigned dps; 87 int rc; 87 88 88 89 assert(node->dirty); … … 108 109 109 110 b->dirty = true; /* need to sync block */ 110 block_put(b); 111 rc = block_put(b); 112 assert(rc == EOK); 111 113 } 112 114 … … 170 172 unsigned spc; 171 173 unsigned dps; 174 int rc; 172 175 173 176 if (idxp->nodep) { … … 226 229 nodep->refcnt = 1; 227 230 228 block_put(b); 231 rc = block_put(b); 232 assert(rc == EOK); 229 233 230 234 /* Link the idx structure with the node structure. */ … … 443 447 } 444 448 } 445 block_put(b); 449 rc = block_put(b); 450 assert(rc == EOK); 446 451 } 447 452 j = 0; … … 477 482 fat_dentry_name_set(d, name); 478 483 b->dirty = true; /* need to sync block */ 479 block_put(b); 484 rc = block_put(b); 485 assert(rc == EOK); 480 486 fibril_mutex_unlock(&parentp->idx->lock); 481 487 … … 512 518 } 513 519 b->dirty = true; /* need to sync block */ 514 block_put(b); 520 rc = block_put(b); 521 assert(rc == EOK); 515 522 516 523 childp->idx->pfc = parentp->firstc; … … 539 546 uint16_t bps; 540 547 block_t *b; 548 int rc; 541 549 542 550 if (!parentp) … … 561 569 d->name[0] = FAT_DENTRY_ERASED; 562 570 b->dirty = true; /* need to sync block */ 563 block_put(b); 571 rc = block_put(b); 572 assert(rc == EOK); 564 573 565 574 /* remove the index structure from the position hash */ … … 588 597 fat_dentry_t *d; 589 598 block_t *b; 599 int rc; 590 600 591 601 fibril_mutex_lock(&parentp->idx->lock); … … 603 613 continue; 604 614 case FAT_DENTRY_LAST: 605 block_put(b); 615 rc = block_put(b); 616 assert(rc == EOK); 606 617 fibril_mutex_unlock(&parentp->idx->lock); 607 618 return NULL; … … 629 640 * run out of 32-bit indices. 630 641 */ 631 block_put(b); 642 rc = block_put(b); 643 assert(rc == EOK); 632 644 return NULL; 633 645 } 634 646 nodep = fat_node_get_core(idx); 635 647 fibril_mutex_unlock(&idx->lock); 636 block_put(b); 648 rc = block_put(b); 649 assert(rc == EOK); 637 650 return FS_NODE(nodep); 638 651 } 639 652 } 640 block_put(b); 653 rc = block_put(b); 654 assert(rc == EOK); 641 655 } 642 656 … … 669 683 block_t *b; 670 684 unsigned i, j; 685 int rc; 671 686 672 687 if (nodep->type != FAT_DIRECTORY) … … 691 706 continue; 692 707 case FAT_DENTRY_LAST: 693 block_put(b); 708 rc = block_put(b); 709 assert(rc == EOK); 694 710 fibril_mutex_unlock(&nodep->idx->lock); 695 711 return false; 696 712 default: 697 713 case FAT_DENTRY_VALID: 698 block_put(b); 714 rc = block_put(b); 715 assert(rc == EOK); 699 716 fibril_mutex_unlock(&nodep->idx->lock); 700 717 return true; 701 718 } 702 block_put(b); 719 rc = block_put(b); 720 assert(rc == EOK); 703 721 fibril_mutex_unlock(&nodep->idx->lock); 704 722 return true; 705 723 } 706 block_put(b); 724 rc = block_put(b); 725 assert(rc == EOK); 707 726 } 708 727 … … 901 920 size_t bytes; 902 921 block_t *b; 922 int rc; 903 923 904 924 if (!fn) { … … 937 957 (void) ipc_data_read_finalize(callid, b->data + pos % bps, 938 958 bytes); 939 block_put(b); 959 rc = block_put(b); 960 assert(rc == EOK); 940 961 } 941 962 } else { … … 969 990 continue; 970 991 case FAT_DENTRY_LAST: 971 block_put(b); 992 rc = block_put(b); 993 assert(rc == EOK); 972 994 goto miss; 973 995 default: 974 996 case FAT_DENTRY_VALID: 975 997 fat_dentry_name_get(d, name); 976 block_put(b); 998 rc == block_put(b); 999 assert(rc == EOK); 977 1000 goto hit; 978 1001 } 979 1002 } 980 block_put(b); 1003 rc = block_put(b); 1004 assert(rc == EOK); 981 1005 bnum++; 982 1006 } … … 1010 1034 off_t boundary; 1011 1035 int flags = BLOCK_FLAGS_NONE; 1036 int rc; 1012 1037 1013 1038 if (!fn) { … … 1055 1080 bytes); 1056 1081 b->dirty = true; /* need to sync block */ 1057 block_put(b); 1082 rc = block_put(b); 1083 assert(rc == EOK); 1058 1084 if (pos + bytes > nodep->size) { 1059 1085 nodep->size = pos + bytes; … … 1089 1115 bytes); 1090 1116 b->dirty = true; /* need to sync block */ 1091 block_put(b); 1117 rc = block_put(b); 1118 assert(rc == EOK); 1092 1119 /* 1093 1120 * Append the cluster chain starting in mcl to the end of the
Note:
See TracChangeset
for help on using the changeset viewer.