Changeset 6c4eedf in mainline for uspace/lib/c/generic/cap.c


Ignore:
Timestamp:
2017-09-13T20:14:49Z (8 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
120d5bc
Parents:
1d40c93d
Message:

Move capacity specification to libc.

File:
1 moved

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/cap.c

    r1d40c93d r6c4eedf  
    2727 */
    2828
    29 /** @addtogroup libfdisk
     29/** @addtogroup libc
    3030 * @{
    3131 */
    3232/**
    33  * @file Disk management library.
    34  */
    35 
     33 * @file Storage capacity specification.
     34 */
     35
     36#include <cap.h>
    3637#include <errno.h>
    37 #include <fdisk.h>
    3838#include <imath.h>
    3939#include <stdio.h>
     
    6060};
    6161
    62 void fdisk_cap_from_blocks(uint64_t nblocks, size_t block_size,
    63     fdisk_cap_t *cap)
     62void cap_from_blocks(uint64_t nblocks, size_t block_size, cap_spec_t *cap)
    6463{
    6564        uint64_t tsize;
     
    7877 *
    7978 * 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 gives
    81  * the nominal (middle) value, @c fcv_min gives the minimum value
    82  * 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 */
     83int cap_spec_to_blocks(cap_spec_t *cap, cap_vsel_t cvsel, size_t block_size,
     84    uint64_t *rblocks)
    8685{
    8786        int exp;
     
    108107                adj = 0;
    109108                switch (cvsel) {
    110                 case fcv_nom:
     109                case cv_nom:
    111110                        adj = 0;
    112111                        break;
    113                 case fcv_min:
     112                case cv_min:
    114113                        adj = -(f / 2);
    115114                        break;
    116                 case fcv_max:
     115                case cv_max:
    117116                        adj = f / 2 - 1;
    118117                        break;
     
    139138 * digits and at most two fractional digits, e.g abc.xy <unit>.
    140139 */
    141 void fdisk_cap_simplify(fdisk_cap_t *cap)
     140void cap_simplify(cap_spec_t *cap)
    142141{
    143142        uint64_t div;
     
    176175}
    177176
    178 int fdisk_cap_format(fdisk_cap_t *cap, char **rstr)
     177int cap_format(cap_spec_t *cap, char **rstr)
    179178{
    180179        int rc;
     
    209208}
    210209
    211 static int fdisk_digit_val(char c, int *val)
     210static int cap_digit_val(char c, int *val)
    212211{
    213212        switch (c) {
     
    229228}
    230229
    231 int fdisk_cap_parse(const char *str, fdisk_cap_t *cap)
     230int cap_parse(const char *str, cap_spec_t *cap)
    232231{
    233232        const char *eptr;
     
    241240
    242241        eptr = str;
    243         while (fdisk_digit_val(*eptr, &d) == EOK) {
     242        while (cap_digit_val(*eptr, &d) == EOK) {
    244243                m = m * 10 + d;
    245244                ++eptr;
     
    249248                ++eptr;
    250249                dp = 0;
    251                 while (fdisk_digit_val(*eptr, &d) == EOK) {
     250                while (cap_digit_val(*eptr, &d) == EOK) {
    252251                        m = m * 10 + d;
    253252                        ++dp;
Note: See TracChangeset for help on using the changeset viewer.