openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/mtd-utils/2.1.0+AUTOINC+b5027be5f4-r0/git/ubifs-utils/mkfs.ubifs/devtable.c
int parse_devtable(const char* tbl_file)
{
    FILE* f;
    char* line = NULL;
    struct stat st;
    size_t len;

    dbg_msg(1, "parsing device table file '%s'", tbl_file);

    path_htbl = create_hashtable(128, &r5_hash, &is_equivalent);
    if (!path_htbl)
        return err_msg("cannot create path hash table");

    f = fopen(tbl_file, "r");
    if (!f)
        return sys_err_msg("cannot open '%s'", tbl_file);

    if (fstat(fileno(f), &st) < 0)
    {
        sys_err_msg("cannot stat '%s'", tbl_file);
        goto out_close;
    }

    if (st.st_size < 10)
    {
        sys_err_msg("'%s' is too short", tbl_file);
        goto out_close;
    }

    /*
     * The general plan now is to read in one line at a time, check for
     * leading comment delimiters ('#'), then try and parse the line as a
     * device table
     */
    while (getline(&line, &len, f) != -1)
    {
        /* First trim off any white-space */
        len = strlen(line);

        /* Trim trailing white-space */
        while (len > 0 && isspace(line[len - 1]))
            line[--len] = '\0';
        /* Trim leading white-space */
        memmove(line, &line[strspn(line, " \n\r\t\v")], len);

        /* How long are we after trimming? */
        len = strlen(line);

        /* If this is not a comment line, try to interpret it */
        if (len && *line != '#')
        {
            if (interpret_table_entry(line))
            {
                err_msg("cannot parse '%s'", line);
                goto out_close;
            }
        }

        free(line);
        line = NULL;
    }

    dbg_msg(1, "finished parsing");
    fclose(f);
    return 0;

out_close:
    fclose(f);
    free_devtable_info();
    return -1;
}
/**
 * parse_devtable - parse the device table.
 * @tbl_file: device table file name
 *
 * This function parses the device table and prepare the hash table which will
 * later be used by mkfs.ubifs to create the specified files/device nodes.
 * Returns zero in case of success and a negative error code in case of
 * failure.
 */
parse the device table.
@tbl_file: device table file name

This function parses the device table and prepare the hash table which will
later be used by mkfs.ubifs to create the specified files/device nodes.
Returns zero in case of success and a negative error code in case of
failure.
parse the device table . @tbl_file : device table file name This function parses the device table and prepare the hash table which will later be used by mkfs . ubifs to create the specified files / device nodes . Returns zero in case of success and a negative error code in case of failure .
int parse_devtable(const char* tbl_file)
{
    FILE* f;
    char* line = NULL;
    struct stat st;
    size_t len;
    dbg_msg(1, "parsing device table file '%s'", tbl_file);
    path_htbl = create_hashtable(128, &r5_hash, &is_equivalent);
    if (!path_htbl)
        return err_msg("cannot create path hash table");
    f = fopen(tbl_file, "r");
    if (!f)
        return sys_err_msg("cannot open '%s'", tbl_file);
    if (fstat(fileno(f), &st) < 0)
    {
        sys_err_msg("cannot stat '%s'", tbl_file);
        goto out_close;
    }
    if (st.st_size < 10)
    {
        sys_err_msg("'%s' is too short", tbl_file);
        goto out_close;
    }
    while (getline(&line, &len, f) != -1)
    {
        len = strlen(line);
        while (len > 0 && isspace(line[len - 1]))
            line[--len] = '\0';
        memmove(line, &line[strspn(line, " \n\r\t\v")], len);
        len = strlen(line);
        if (len && *line != '#')
        {
            if (interpret_table_entry(line))
            {
                err_msg("cannot parse '%s'", line);
                goto out_close;
            }
        }
        free(line);
        line = NULL;
    }
    dbg_msg(1, "finished parsing");
    fclose(f);
    return 0;
out_close:
    fclose(f);
    free_devtable_info();
    return -1;
}
int parse_devtable ( const char * tbl_file ) { FILE * f ; char * line = NULL ; struct stat st ; size_t len ; dbg_msg ( 1 , " " , tbl_file ) ; path_htbl = create_hashtable ( 128 , & r5_hash , & is_equivalent ) ; if ( ! path_htbl ) return err_msg ( " " ) ; f = fopen ( tbl_file , " " ) ; if ( ! f ) return sys_err_msg ( " " , tbl_file ) ; if ( fstat ( fileno ( f ) , & st ) < 0 ) { sys_err_msg ( " " , tbl_file ) ; goto out_close ; } if ( st . st_size < 10 ) { sys_err_msg ( " " , tbl_file ) ; goto out_close ; } while ( getline ( & line , & len , f ) != -1 ) { len = strlen ( line ) ; while ( len > 0 && isspace ( line [ len - 1 ] ) ) line [ -- len ] = ' \0 ' ; memmove ( line , & line [ strspn ( line , " \n \r \t \v " ) ] , len ) ; len = strlen ( line ) ; if ( len && * line != ' ' ) { if ( interpret_table_entry ( line ) ) { err_msg ( " " , line ) ; goto out_close ; } } free ( line ) ; line = NULL ; } dbg_msg ( 1 , " " ) ; fclose ( f ) ; return 0 ; out_close : fclose ( f ) ; free_devtable_info ( ) ; return -1 ; }
parse_devtable - parse the device table.
parse_devtable - parse the device table .
/*
     * The general plan now is to read in one line at a time, check for
     * leading comment delimiters ('#'), then try and parse the line as a
     * device table
     */ /* First trim off any white-space */ /* Trim trailing white-space */ /* Trim leading white-space */ /* How long are we after trimming? */ /* If this is not a comment line, try to interpret it */