* Made our struct stat POSIX compliant again -- the time_t fields have been

replaced by timespec fields. Via macros the structure is still source
  compatible with the old one.
* Introduced header <compat/sys/stat.h> that defines the old stat structure
  (as stat_beos) and conversion functions
* Introduced versions for [l,f]stat().
* Added symbol versions for BDirectory::GetStatFor() for sake of binary
  compatibility.
* BStatable::GetStat(): Renamed the old method, changed its parameter to
  stat_beos*, and and made it private. Added a new version (using up a
  reserved vtable slot). It remains source and binary compatible.
* BRefFilter::Filter(): Changed the struct stat* parameter to struct stat_beos*
  for sake of binary compatibility. This breaks source compatibility, though,
  which we can't help, since the class doesn't have reserved vtable slots.
* Fixed several issues with the stat structure change, mostly adjusted uses of
  BRefFilter.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30830 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold
2009-05-22 15:15:16 +00:00
parent f15e418bab
commit bcfe344c53
18 changed files with 360 additions and 136 deletions
+48
View File
@@ -0,0 +1,48 @@
/*
* Copyright 2002-2009, Haiku Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _COMPAT_SYS_STAT_H_
#define _COMPAT_SYS_STAT_H_
#include <sys/stat.h>
/* helper struct allowing us to avoid problems with the st_*time macros */
typedef struct {
time_t tv_sec;
} stat_beos_time;
struct stat_beos {
dev_t st_dev; /* device ID that this file resides on */
ino_t st_ino; /* this file's serial inode ID */
mode_t st_mode; /* file mode (rwx for user, group, etc) */
nlink_t st_nlink; /* number of hard links to this file */
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 */
dev_t st_rdev; /* device type (not used) */
blksize_t st_blksize; /* preferred block size for I/O */
stat_beos_time st_atim; /* last access time */
stat_beos_time st_mtim; /* last modification time */
stat_beos_time st_ctim; /* last change time, not creation time */
stat_beos_time st_crtim; /* creation time */
};
#ifdef __cplusplus
extern "C" {
#endif
extern void convert_to_stat_beos(const struct stat* stat,
struct stat_beos* beosStat);
extern void convert_from_stat_beos(const struct stat_beos* beosStat,
struct stat* stat);
#ifdef __cplusplus
}
#endif
#endif /* _COMPAT_SYS_STAT_H_ */
+12 -4
View File
@@ -7,6 +7,7 @@
#include <sys/types.h>
#include <time.h>
struct stat {
@@ -19,14 +20,21 @@ struct stat {
off_t st_size; /* size in bytes of this file */
dev_t st_rdev; /* device type (not used) */
blksize_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 */
struct timespec st_atim; /* last access time */
struct timespec st_mtim; /* last modification time */
struct timespec st_ctim; /* last change time, not creation time */
struct timespec st_crtim; /* creation time */
unsigned int st_type; /* attribute/index type */
blkcnt_t st_blocks; /* number of blocks allocated for object */
};
/* source compatibility with old stat structure */
#define st_atime st_atim.tv_sec
#define st_mtime st_mtim.tv_sec
#define st_ctime st_ctim.tv_sec
#define st_crtime st_crtim.tv_sec
/* extended file types */
#define S_ATTR_DIR 01000000000 /* attribute directory */
#define S_ATTR 02000000000 /* attribute */