Changeset b209135 in mainline for uspace/lib/ext4/src/superblock.c


Ignore:
Timestamp:
2018-10-03T12:19:02Z (6 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
6ba36a0
Parents:
2175178
git-author:
Jiri Svoboda <jiri@…> (2018-10-02 22:18:01)
git-committer:
Jiri Svoboda <jiri@…> (2018-10-03 12:19:02)
Message:

Reading volume label from ext4 file system.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/ext4/src/superblock.c

    r2175178 rb209135  
    4444#include <mem.h>
    4545#include <stdlib.h>
     46#include <str.h>
    4647#include <time.h>
    4748#include "ext4/cfg.h"
     
    883884 *
    884885 */
    885 const char *ext4_superblock_get_volume_name(ext4_superblock_t *sb)
    886 {
    887         return sb->volume_name;
     886errno_t ext4_superblock_get_volume_name(ext4_superblock_t *sb, char *buf,
     887    size_t bufsz)
     888{
     889        size_t i;
     890        size_t wi;
     891        wchar_t ch;
     892        errno_t rc;
     893
     894        i = 0;
     895        wi = 0;
     896        while (sb->volume_name[i] != '\0' && i < sizeof(sb->volume_name)) {
     897                /* ISO 8859-1 codes map to identical Unicode code points */
     898                ch = (wchar_t)(uint8_t)sb->volume_name[i];
     899                rc = chr_encode(ch, buf, &wi, bufsz - 1);
     900                if (rc != EOK)
     901                        return rc;
     902
     903                i++;
     904        }
     905
     906        buf[wi] = '\0';
     907        return EOK;
    888908}
    889909
Note: See TracChangeset for help on using the changeset viewer.