Changes in / [b53e6d9:40240b1] in mainline
- Location:
- uspace
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bdsh/cmds/modules/bdd/bdd.c
rb53e6d9 r40240b1 42 42 #include <assert.h> 43 43 44 enum { 45 /* Number of bytes per row */ 46 BPR = 16 47 }; 44 #define BLOCK_SIZE 512 45 #define BPR 16 48 46 49 47 static const char *cmdname = "bdd"; … … 69 67 unsigned int i, j; 70 68 dev_handle_t handle; 69 block_t *block; 71 70 uint8_t *blk; 72 71 size_t size, bytes, rows; 73 size_t block_size;74 72 int rc; 75 bn_t b a;73 bn_t boff; 76 74 uint8_t b; 77 75 … … 85 83 86 84 if (argc >= 3) 87 b a= strtol(argv[2], NULL, 0);85 boff = strtol(argv[2], NULL, 0); 88 86 else 89 b a= 0;87 boff = 0; 90 88 91 89 if (argc >= 4) … … 96 94 rc = devmap_device_get_handle(argv[1], &handle, 0); 97 95 if (rc != EOK) { 98 printf(" %s: Error resolving device `%s'.\n", cmdname, argv[1]);96 printf("Error: could not resolve device `%s'.\n", argv[1]); 99 97 return CMD_FAILURE; 100 98 } 101 99 102 rc = block_init(handle, 2048);100 rc = block_init(handle, BLOCK_SIZE); 103 101 if (rc != EOK) { 104 printf(" %s: Error initializing libblock.\n", cmdname);102 printf("Error: could not init libblock.\n"); 105 103 return CMD_FAILURE; 106 104 } 107 105 108 rc = block_ get_bsize(handle, &block_size);106 rc = block_cache_init(handle, BLOCK_SIZE, 2, CACHE_MODE_WB); 109 107 if (rc != EOK) { 110 printf("%s: Error determining device block size.\n", cmdname); 111 return CMD_FAILURE; 112 } 113 114 blk = malloc(block_size); 115 if (blk == NULL) { 116 printf("%s: Error allocating memory.\n", cmdname); 117 block_fini(handle); 108 printf("Error: could not init block cache.\n"); 118 109 return CMD_FAILURE; 119 110 } 120 111 121 112 while (size > 0) { 122 rc = block_ read_direct(handle, ba, 1, blk);113 rc = block_get(&block, handle, boff, 0); 123 114 if (rc != EOK) { 124 printf("%s: Error reading block %llu\n", cmdname, ba); 125 free(blk); 126 block_fini(handle); 115 printf("Error: could not get block %u, device %u.\n", 116 boff, handle); 127 117 return CMD_FAILURE; 128 118 } 119 blk = (uint8_t *) block->data; 129 120 130 bytes = (size < block_size) ? size : block_size;121 bytes = (size < BLOCK_SIZE) ? size : BLOCK_SIZE; 131 122 rows = (bytes + BPR - 1) / BPR; 132 123 … … 154 145 } 155 146 147 rc = block_put(block); 148 if (rc != EOK) { 149 printf("Error: could not put block %p.\n", 150 block); 151 return CMD_FAILURE; 152 } 153 156 154 if (size > rows * BPR) 157 155 size -= rows * BPR; … … 159 157 size = 0; 160 158 161 /* Next block */ 162 ba += 1; 159 boff += rows * BPR; 163 160 } 164 161 165 free(blk);166 162 block_fini(handle); 167 163 -
uspace/srv/part/mbr_part/mbr_part.c
rb53e6d9 r40240b1 39 39 * 40 40 * Limitations: 41 * 41 * 42 42 * Only works with boot records using LBA. CHS-only records are not 43 * supported. 44 * 45 * Referemces: 46 * 47 * The source of MBR structures for this driver have been the following 48 * Wikipedia articles: 49 * - http://en.wikipedia.org/wiki/Master_Boot_Record 50 * - http://en.wikipedia.org/wiki/Extended_boot_record 51 * 52 * The fact that the extended partition has type 0x05 is pure observation. 53 * (TODO: can it have any other type number?) 43 * supported. Maximum number of partitions is fixed. 54 44 */ 55 45 … … 80 70 81 71 /** Boot record signature */ 82 BR_SIGNATURE = 0xAA55 72 BR_SIGNATURE = 0xAA55, 83 73 }; 84 74 85 75 enum ptype { 86 /** Unused partition entry */87 PT_UNUSED = 0x00,88 76 /** Extended partition */ 89 PT_EXTENDED = 0x05 ,77 PT_EXTENDED = 0x05 90 78 }; 91 79 … … 377 365 part->length = len; 378 366 379 part->present = (pte->ptype != PT_UNUSED) ? true : false; 380 367 part->present = (sa != 0 || len != 0) ? true : false; 381 368 part->dev = 0; 382 369 part->next = NULL;
Note:
See TracChangeset
for help on using the changeset viewer.