mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 21:17:45 +00:00
Add an lstat() syscall and use it to make "ls" nicer.
This commit is contained in:
parent
bca4b71bfa
commit
5f36a5f22e
10 changed files with 118 additions and 2 deletions
23
LibC/types.h
23
LibC/types.h
|
@ -20,5 +20,28 @@ typedef signed_dword ssize_t;
|
|||
typedef dword ino_t;
|
||||
typedef signed_dword off_t;
|
||||
|
||||
typedef dword dev_t;
|
||||
typedef dword mode_t;
|
||||
typedef dword nlink_t;
|
||||
typedef dword blksize_t;
|
||||
typedef dword blkcnt_t;
|
||||
typedef dword time_t;
|
||||
|
||||
struct stat {
|
||||
dev_t st_dev; /* ID of device containing file */
|
||||
ino_t st_ino; /* inode number */
|
||||
mode_t st_mode; /* protection */
|
||||
nlink_t st_nlink; /* number of hard links */
|
||||
uid_t st_uid; /* user ID of owner */
|
||||
gid_t st_gid; /* group ID of owner */
|
||||
dev_t st_rdev; /* device ID (if special file) */
|
||||
off_t st_size; /* total size, in bytes */
|
||||
blksize_t st_blksize; /* blocksize for file system I/O */
|
||||
blkcnt_t st_blocks; /* number of 512B blocks allocated */
|
||||
time_t st_atime; /* time of last access */
|
||||
time_t st_mtime; /* time of last modification */
|
||||
time_t st_ctime; /* time of last status change */
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -40,5 +40,10 @@ pid_t waitpid(pid_t waitee)
|
|||
return Syscall::invoke(Syscall::PosixWaitpid, waitee);
|
||||
}
|
||||
|
||||
int lstat(const char* path, stat* statbuf)
|
||||
{
|
||||
return Syscall::invoke(Syscall::PosixLstat, (dword)path, (dword)statbuf);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -12,5 +12,37 @@ ssize_t read(int fd, void* buf, size_t count);
|
|||
int close(int fd);
|
||||
pid_t waitpid(pid_t);
|
||||
|
||||
int lstat(const char* path, stat* statbuf);
|
||||
|
||||
#define S_IFMT 0170000
|
||||
#define S_IFDIR 0040000
|
||||
#define S_IFCHR 0020000
|
||||
#define S_IFBLK 0060000
|
||||
#define S_IFREG 0100000
|
||||
#define S_IFIFO 0010000
|
||||
#define S_IFLNK 0120000
|
||||
#define S_IFSOCK 0140000
|
||||
|
||||
#define S_ISUID 04000
|
||||
#define S_ISGID 02000
|
||||
#define S_ISVTX 01000
|
||||
#define S_IRUSR 0400
|
||||
#define S_IWUSR 0200
|
||||
#define S_IXUSR 0100
|
||||
#define S_IRGRP 0040
|
||||
#define S_IWGRP 0020
|
||||
#define S_IXGRP 0010
|
||||
#define S_IROTH 0004
|
||||
#define S_IWOTH 0002
|
||||
#define S_IXOTH 0001
|
||||
|
||||
|
||||
#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
|
||||
#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
|
||||
#define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
|
||||
#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
|
||||
#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
|
||||
#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue