2 * Acess2 POSIX Emulation Lib
3 * - By John Hodge (thePowersGang)
12 int stat(const char *path, struct stat *buf)
14 int fd = _SysOpen(path, 0);
16 // errno is set by _SysOpen
20 int rv = fstat(fd, buf);
25 int lstat(const char *path, struct stat *buf)
27 int fd = _SysOpen(path, OPENFLAG_NOLINK);
29 // errno is set by _SysOpen
33 int rv = fstat(fd, buf);
38 int fstat(int fd, struct stat *buf)
42 int rv = _SysFInfo(fd, &info, 0);
47 _SysDebug("fstat(fd=%i,buf=%p)", fd, buf);
50 buf->st_dev = info.mount;
51 buf->st_ino = info.inode;
52 if( info.flags & FILEFLAG_SYMLINK )
53 buf->st_mode = S_IFLNK;
54 else if( info.flags & FILEFLAG_DIRECTORY )
55 buf->st_mode = S_IFDIR;
57 buf->st_mode = S_IFREG;
58 // TODO: User modes (assume 660)
61 buf->st_uid = info.uid;
62 buf->st_gid = info.gid;
64 buf->st_size = info.size;
65 buf->st_blksize = 512;
66 buf->st_blocks = (info.size+511)/512;
67 buf->st_atime = info.atime;
68 buf->st_mtime = info.mtime;
69 buf->st_ctime = info.ctime;