sdk-core
v2026.11.05
PS2 SDK - core tier (build-critical EE/IOP modules)
Toggle main menu visibility
Loading...
Searching...
No Matches
fs.c
1
/*
2
# _____ ___ ____ ___ ____
3
# ____| | ____| | | |____|
4
# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
5
#-----------------------------------------------------------------------
6
# Copyright 2001-2004, ps2dev - http://www.ps2dev.org
7
# Licenced under Academic Free License version 2.0
8
# Review ps2sdk README & LICENSE files for further details.
9
*/
10
11
#include <errno.h>
12
#include <limits.h>
13
#include <
stdlib.h
>
14
#include <
string.h
>
15
#include <sys/stat.h>
16
17
#if __has_include(<sys/statvfs.h>)
18
#include <sys/statvfs.h>
19
#else
20
// Toolchains older than newlib-llvm's sys/statvfs.h; remove once every supported toolchain ships it.
21
struct
statvfs
{
22
unsigned
long
f_bsize;
23
unsigned
long
f_frsize;
24
fsblkcnt_t f_blocks;
25
fsblkcnt_t f_bfree;
26
fsblkcnt_t f_bavail;
27
fsfilcnt_t f_files;
28
fsfilcnt_t f_ffree;
29
fsfilcnt_t f_favail;
30
unsigned
long
f_fsid;
31
unsigned
long
f_flag;
32
unsigned
long
f_namemax;
33
};
34
35
int
statvfs
(
const
char
*path,
struct
statvfs
*buf);
36
int
fstatvfs(
int
fd,
struct
statvfs
*buf);
37
#endif
38
39
extern
int
__path_absolute(
const
char
*in,
char
*out,
int
len);
40
41
char
*realpath(
const
char
*path,
char
*resolved)
42
{
43
char
absolute[PATH_MAX];
44
struct
stat st;
45
46
if
(path == NULL || *path ==
'\0'
) {
47
errno = path == NULL ?
EINVAL
:
ENOENT
;
48
return
NULL;
49
}
50
if
(__path_absolute(path, absolute,
sizeof
(absolute)) < 0) {
51
errno =
ENAMETOOLONG
;
52
return
NULL;
53
}
54
if
(stat(absolute, &st) < 0)
55
return
NULL;
56
57
if
(resolved == NULL)
58
return
strdup(absolute);
59
return
strcpy(resolved, absolute);
60
}
61
62
int
statvfs
(
const
char
*path,
struct
statvfs
*buf)
63
{
64
(void)path;
65
(void)buf;
66
errno =
ENOSYS
;
67
return
-1;
68
}
69
70
int
fstatvfs(
int
fd,
struct
statvfs
*buf)
71
{
72
(void)fd;
73
(void)buf;
74
errno =
ENOSYS
;
75
return
-1;
76
}
ENOENT
#define ENOENT
Definition
errno.h:32
EINVAL
#define EINVAL
Definition
errno.h:72
ENAMETOOLONG
#define ENAMETOOLONG
Definition
errno.h:200
ENOSYS
#define ENOSYS
Definition
errno.h:194
stdlib.h
string.h
statvfs
Definition
fs.c:21
core
libcglue
src
fs.c
Generated by
1.18.0