2018-02-25 08:13:54 +03:00
|
|
|
#include <errno.h>
|
|
|
|
#include <syscall.h>
|
2018-12-10 04:09:27 +03:00
|
|
|
#include <syscall_nums.h>
|
2018-02-25 08:13:54 +03:00
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2018-12-10 04:09:27 +03:00
|
|
|
DEFN_SYSCALL2(stat, SYS_STATF, char *, void *);
|
|
|
|
DEFN_SYSCALL2(lstat, SYS_LSTAT, char *, void *);
|
2018-02-25 08:13:54 +03:00
|
|
|
|
|
|
|
int stat(const char *file, struct stat *st){
|
|
|
|
int ret = syscall_stat((char *)file, (void *)st);
|
|
|
|
if (ret >= 0) {
|
|
|
|
return ret;
|
|
|
|
} else {
|
2018-11-25 06:50:42 +03:00
|
|
|
errno = -ret;
|
2018-02-25 08:13:54 +03:00
|
|
|
memset(st, 0x00, sizeof(struct stat));
|
2018-11-25 06:50:42 +03:00
|
|
|
return -1;
|
2018-02-25 08:13:54 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int lstat(const char *path, struct stat *st) {
|
|
|
|
int ret = syscall_lstat((char *)path, (void *)st);
|
|
|
|
if (ret >= 0) {
|
|
|
|
return ret;
|
|
|
|
} else {
|
|
|
|
errno = -ret;
|
|
|
|
memset(st, 0x00, sizeof(struct stat));
|
2018-11-25 06:50:42 +03:00
|
|
|
return -1;
|
2018-02-25 08:13:54 +03:00
|
|
|
}
|
|
|
|
}
|