summaryrefslogtreecommitdiff
path: root/lib/ultralib/src/io/pfsgetlabel.c
blob: adb1dcc51dbe8feaabcfd5e359d28f9ef298e6c8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include "PRinternal/macros.h"
#include "PR/os_internal.h"
#include "PRinternal/controller.h"

s32 osPfsGetLabel(OSPfs* pfs, u8* label, int* len) {
    int i;

    if (label == NULL) {
        return PFS_ERR_INVALID;
    }

    if (__osCheckId(pfs) == PFS_ERR_NEW_PACK) {
        return PFS_ERR_NEW_PACK;
    }

    for (i = 0; i < ARRLEN(pfs->label); i++) {
        if (*(u8*)(u32)(i + pfs->label) == 0) {
            break;
        }

        *label++ = *(u8*)(u32)(i + pfs->label);
    }

    *len = i;
    return 0;
}