PatchworkOS
3984a1d
A non-POSIX operating system.
Theme:
Default
Round
Robot
Loading...
Searching...
No Matches
main.c
Go to the documentation of this file.
1
#include <
errno.h
>
2
#include <
stdbool.h
>
3
#include <
stdio.h
>
4
#include <
stdlib.h
>
5
#include <
string.h
>
6
#include <
sys/io.h
>
7
#include <
time.h
>
8
9
static
const
char
*
type_to_string
(
itype_t
type)
10
{
11
switch
(type)
12
{
13
case
INODE_FILE
:
14
return
"file"
;
15
case
INODE_DIR
:
16
return
"directory"
;
17
case
INODE_SYMLINK
:
18
return
"symlink"
;
19
default
:
20
return
"unknown"
;
21
}
22
}
23
24
static
void
print_stat
(
const
char
* path)
25
{
26
stat_t
buffer
;
27
if
(
stat
(path, &
buffer
) ==
ERR
)
28
{
29
printf
(
"stat: failed to stat %s (%s)\n"
, path,
strerror
(
errno
));
30
return
;
31
}
32
33
printf
(
" File: %s\n"
, path);
34
printf
(
" Size: %llu\t\tBlocks: %llu\t IO Block: %llu %s\n"
,
buffer
.size,
buffer
.blocks,
buffer
.blockSize,
35
type_to_string
(
buffer
.type));
36
printf
(
"Superblock: %llu\tInode: %llu\tLinks: %llu\n"
,
buffer
.sbid,
buffer
.number,
buffer
.linkAmount);
37
printf
(
" Max: %llu\n"
,
buffer
.maxFileSize);
38
printf
(
" Name: %s\n"
,
buffer
.name);
39
printf
(
"Access: %s"
,
ctime
(&
buffer
.accessTime));
40
printf
(
"Modify: %s"
,
ctime
(&
buffer
.modifyTime));
41
printf
(
"Change: %s"
,
ctime
(&
buffer
.changeTime));
42
printf
(
" Birth: %s"
,
ctime
(&
buffer
.createTime));
43
}
44
45
int
main
(
int
argc,
char
** argv)
46
{
47
for
(
int
i
= 1;
i
< argc;
i
++)
48
{
49
print_stat
(argv[
i
]);
50
}
51
52
return
EXIT_SUCCESS
;
53
}
main
int main(void)
Definition
main.c:5
y
int64_t y
Definition
main.c:153
errno.h
errno
#define errno
Error number variable.
Definition
errno.h:27
stat
uint64_t stat(const char *path, stat_t *stat)
System call for retrieving info about a file or directory.
Definition
stat.c:8
itype_t
itype_t
Inode type enum.
Definition
io.h:341
INODE_FILE
@ INODE_FILE
Is a file.
Definition
io.h:342
INODE_DIR
@ INODE_DIR
Is a directory.
Definition
io.h:343
INODE_SYMLINK
@ INODE_SYMLINK
Is a symbolic link.
Definition
io.h:344
ERR
#define ERR
Integer error value.
Definition
ERR.h:17
io.h
buffer
EFI_PHYSICAL_ADDRESS buffer
Definition
mem.c:15
print_stat
static void print_stat(const char *path)
Definition
main.c:24
type_to_string
static const char * type_to_string(itype_t type)
Definition
main.c:9
stdbool.h
stdio.h
printf
_PUBLIC int printf(const char *_RESTRICT format,...)
Definition
printf.c:3
stdlib.h
EXIT_SUCCESS
#define EXIT_SUCCESS
Definition
stdlib.h:46
string.h
strerror
_PUBLIC char * strerror(int errnum)
Definition
strerror.c:6
stat_t
Stat type.
Definition
io.h:366
time.h
ctime
_PUBLIC char * ctime(const time_t *timer)
Definition
ctime.c:3
src
programs
utils
stat
main.c
Generated on Sat Jan 10 2026 00:03:15 for PatchworkOS by
1.9.8