From 94e11a83bbeaaf3eeab2b45faaf60a46e42968fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Mon, 10 May 2004 14:35:11 +0000 Subject: [PATCH] Fixes POSIX and R5 compatibility of the stat structure; readded field st_rdev. Added an additional field st_type and changed functions to allow for this extension while maintaining R5 compatibility. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@7495 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/posix/sys/stat.h | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/headers/posix/sys/stat.h b/headers/posix/sys/stat.h index 1a6e9bbaa5..cccd06777f 100644 --- a/headers/posix/sys/stat.h +++ b/headers/posix/sys/stat.h @@ -15,15 +15,16 @@ struct stat { uid_t st_uid; /* user id of the owner of this file */ gid_t st_gid; /* group id of the owner of this file */ off_t st_size; /* size in bytes of this file */ - // ToDo: st_type is new for OpenBeOS - it replaces the unused st_rdev field - // we might also define special types for files and TTYs - unsigned int st_type; /* attribute/index type */ - //dev_t st_rdev; /* device type (not used) */ + dev_t st_rdev; /* device type (not used) */ size_t st_blksize; /* preferred block size for i/o */ time_t st_atime; /* last access time */ time_t st_mtime; /* last modification time */ time_t st_ctime; /* last change time, not creation time */ time_t st_crtime; /* creation time */ + + // OpenBeOS extensions: + // ToDo: we might also define special types for files and TTYs + unsigned int st_type; /* attribute/index type */ }; /* extended file types */ @@ -93,13 +94,18 @@ extern "C" { extern int chmod(const char *path, mode_t mode); extern int fchmod(int fd, mode_t mode); -extern int stat(const char *path, struct stat *buf); -extern int fstat(int fd, struct stat *buf); -extern int lstat(const char *path, struct stat *st); +extern int _stat(const char *path, struct stat *st, size_t statSize); +extern int _fstat(int fd, struct stat *st, size_t statSize); +extern int _lstat(const char *path, struct stat *st, size_t statSize); extern int mkdir(const char *path, mode_t mode); extern int mkfifo(const char *path, mode_t mode); extern mode_t umask(mode_t cmask); +// This achieves backwards compatibility with R5 +#define stat(fd, st) _stat(fd, st, sizeof(struct stat)) +#define fstat(fd, st) _fstat(fd, st, sizeof(struct stat)) +#define lstat(fd, st) _lstat(fd, st, sizeof(struct stat)) + #ifdef __cplusplus } #endif