Changeset 6c4eedf in mainline for uspace/lib/c/generic/cap.c
- Timestamp:
- 2017-09-13T20:14:49Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 120d5bc
- Parents:
- 1d40c93d
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/cap.c
r1d40c93d r6c4eedf 27 27 */ 28 28 29 /** @addtogroup lib fdisk29 /** @addtogroup libc 30 30 * @{ 31 31 */ 32 32 /** 33 * @file Disk management library. 34 */ 35 33 * @file Storage capacity specification. 34 */ 35 36 #include <cap.h> 36 37 #include <errno.h> 37 #include <fdisk.h>38 38 #include <imath.h> 39 39 #include <stdio.h> … … 60 60 }; 61 61 62 void fdisk_cap_from_blocks(uint64_t nblocks, size_t block_size, 63 fdisk_cap_t *cap) 62 void cap_from_blocks(uint64_t nblocks, size_t block_size, cap_spec_t *cap) 64 63 { 65 64 uint64_t tsize; … … 78 77 * 79 78 * A capacity value entails precision, i.e. it corresponds to a range 80 * of values. @a cvsel selects the value to return. @c fcv_nom gives81 * the nominal (middle) value, @c fcv_min gives the minimum value82 * and @c fcv_max gives the maximum value.83 */ 84 int fdisk_cap_to_blocks(fdisk_cap_t *cap, fdisk_cvsel_t cvsel,85 size_t block_size,uint64_t *rblocks)79 * of values. @a cvsel selects the value to return. @c cv_nom gives 80 * the nominal (middle) value, @c cv_min gives the minimum value 81 * and @c cv_max gives the maximum value. 82 */ 83 int cap_spec_to_blocks(cap_spec_t *cap, cap_vsel_t cvsel, size_t block_size, 84 uint64_t *rblocks) 86 85 { 87 86 int exp; … … 108 107 adj = 0; 109 108 switch (cvsel) { 110 case fcv_nom:109 case cv_nom: 111 110 adj = 0; 112 111 break; 113 case fcv_min:112 case cv_min: 114 113 adj = -(f / 2); 115 114 break; 116 case fcv_max:115 case cv_max: 117 116 adj = f / 2 - 1; 118 117 break; … … 139 138 * digits and at most two fractional digits, e.g abc.xy <unit>. 140 139 */ 141 void fdisk_cap_simplify(fdisk_cap_t *cap)140 void cap_simplify(cap_spec_t *cap) 142 141 { 143 142 uint64_t div; … … 176 175 } 177 176 178 int fdisk_cap_format(fdisk_cap_t *cap, char **rstr)177 int cap_format(cap_spec_t *cap, char **rstr) 179 178 { 180 179 int rc; … … 209 208 } 210 209 211 static int fdisk_digit_val(char c, int *val)210 static int cap_digit_val(char c, int *val) 212 211 { 213 212 switch (c) { … … 229 228 } 230 229 231 int fdisk_cap_parse(const char *str, fdisk_cap_t *cap)230 int cap_parse(const char *str, cap_spec_t *cap) 232 231 { 233 232 const char *eptr; … … 241 240 242 241 eptr = str; 243 while ( fdisk_digit_val(*eptr, &d) == EOK) {242 while (cap_digit_val(*eptr, &d) == EOK) { 244 243 m = m * 10 + d; 245 244 ++eptr; … … 249 248 ++eptr; 250 249 dp = 0; 251 while ( fdisk_digit_val(*eptr, &d) == EOK) {250 while (cap_digit_val(*eptr, &d) == EOK) { 252 251 m = m * 10 + d; 253 252 ++dp;
Note:
See TracChangeset
for help on using the changeset viewer.