From 10567eeb6e5e09919ed169cd92cd66c03c91f4db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Tue, 24 Sep 2002 16:02:53 +0000 Subject: [PATCH] Changed an unused field of struct stat (st_rdev) to st_type, so that we can use this structure to call fstat() on attributes and indices. Added more functions to the file system interface (attributes, and indices). Added header fs_attr.h, and fs_index.h. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1158 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/os/kernel/fs_attr.h | 45 ++++++++++++++++++++++++++++++++ headers/os/kernel/fs_index.h | 41 +++++++++++++++++++++++++++++ headers/os/kernel/fs_info.h | 21 ++++++++------- headers/os/kernel/fs_interface.h | 15 +++++++---- headers/posix/sys/stat.h | 31 +++++++++++----------- 5 files changed, 123 insertions(+), 30 deletions(-) create mode 100644 headers/os/kernel/fs_attr.h create mode 100644 headers/os/kernel/fs_index.h diff --git a/headers/os/kernel/fs_attr.h b/headers/os/kernel/fs_attr.h new file mode 100644 index 0000000000..546593a4b4 --- /dev/null +++ b/headers/os/kernel/fs_attr.h @@ -0,0 +1,45 @@ +/* fs_attr.h +** +** functions/definitions for retrieving and setting attribute information. +** Distributed under the terms of the OpenBeOS License. +*/ + +#ifndef _FS_ATTR_H +#define _FS_ATTR_H + +#include +#include + + +typedef struct attr_info { + uint32 type; + off_t size; +} attr_info; + + +#ifdef __cplusplus +extern "C" { +#endif + +extern ssize_t fs_read_attr(int fd, const char *attribute, uint32 type, off_t pos, void *buffer, size_t readBytes); +extern ssize_t fs_write_attr(int fd, const char *attribute, uint32 type, off_t pos, const void *buffer, size_t readBytes); +extern int fs_remove_attr(int fd, const char *attribute); +extern int fs_stat_attr(int fd, const char *name, struct attr_info *attrInfo); + +// ToDo: the following three functions are not part of the R5 API, and +// are only preliminary - they may change or be removed at any point +extern int fs_open_attr(const char *path, const char *attribute); +extern int fs_fopen_attr(int fd, const char *attribute); +extern int fs_close_attr(int fd); + +extern DIR *fs_open_attr_dir(const char *path); +extern DIR *fs_fopen_attr_dir(int fd); +extern int fs_close_attr_dir(DIR *dirp); +extern struct dirent *fs_read_attr_dir(DIR *dirp); +extern void fs_rewind_attr_dir(DIR *dirp); + +#ifdef __cplusplus +} +#endif + +#endif /* _FS_ATTR_H */ diff --git a/headers/os/kernel/fs_index.h b/headers/os/kernel/fs_index.h new file mode 100644 index 0000000000..5f889a5819 --- /dev/null +++ b/headers/os/kernel/fs_index.h @@ -0,0 +1,41 @@ +/* fs_index.h +** +** functions/definitions for file system indices. +** Distributed under the terms of the OpenBeOS License. +*/ + +#ifndef _FS_INDEX_H +#define _FS_INDEX_H + +#include +#include + + +typedef struct index_info { + uint32 type; + off_t size; + time_t modification_time; + time_t creation_time; + uid_t uid; + gid_t gid; +} index_info; + + +#ifdef __cplusplus +extern "C" { +#endif + +extern int fs_create_index(dev_t device, const char *name, uint32 type, uint32 flags); +extern int fs_remove_index(dev_t device, const char *name); +extern int fs_stat_index(dev_t device, const char *name, struct index_info *indexInfo); + +extern DIR *fs_open_index_dir(dev_t device); +extern int fs_close_index_dir(DIR *indexDirectory); +extern struct dirent *fs_read_index_dir(DIR *indexDirectory); +extern void fs_rewind_attr_dir(DIR *indexDirectory); + +#ifdef __cplusplus +} +#endif + +#endif /* _FS_INDEX_H */ diff --git a/headers/os/kernel/fs_info.h b/headers/os/kernel/fs_info.h index d9710a2202..60e11ebbc8 100644 --- a/headers/os/kernel/fs_info.h +++ b/headers/os/kernel/fs_info.h @@ -1,6 +1,7 @@ /* fs_info.h ** -** functions/definitions for general file system information +** functions/definitions for general file system information. +** Distributed under the terms of the OpenBeOS License. */ #ifndef _FS_INFO_H @@ -8,9 +9,6 @@ #include -#ifdef __cplusplus -extern "C" { -#endif /* fs_info.flags */ #define B_FS_IS_READONLY 0x00000001 @@ -25,12 +23,12 @@ extern "C" { #define B_FS_HAS_ALIASES 0x00100000 #define B_FS_SUPPORTS_NODE_MONITORING 0x00200000 -struct fs_info { - dev_t dev; /* fs dev_t */ +typedef struct fs_info { + dev_t dev; /* volume dev_t */ ino_t root; /* root ino_t */ - uint32 flags; /* file system flags */ + uint32 flags; /* flags (see above) */ off_t block_size; /* fundamental block size */ - off_t io_size; /* optimal io size */ + off_t io_size; /* optimal i/o size */ off_t total_blocks; /* total number of blocks */ off_t free_blocks; /* number of free blocks */ off_t total_nodes; /* total number of nodes */ @@ -38,9 +36,12 @@ struct fs_info { char device_name[128]; /* device holding fs */ char volume_name[B_FILE_NAME_LENGTH]; /* volume name */ char fsh_name[B_OS_NAME_LENGTH]; /* name of fs handler */ -}; +} fs_info; -typedef struct fs_info fs_info; + +#ifdef __cplusplus +extern "C" { +#endif extern dev_t dev_for_path(const char *path); extern dev_t next_dev(int32 *pos); diff --git a/headers/os/kernel/fs_interface.h b/headers/os/kernel/fs_interface.h index d8ad61784d..61e3597ace 100644 --- a/headers/os/kernel/fs_interface.h +++ b/headers/os/kernel/fs_interface.h @@ -12,8 +12,6 @@ struct dirent; struct stat; struct fs_info; -struct attr_info; -struct index_info; /* the file system's private data structures */ @@ -108,11 +106,14 @@ struct fs_calls { status_t (*fs_open_attr)(fs_volume fs, fs_vnode file, const char *name, int oflags, fs_cookie *_cookie, vnode_id *_attrID); status_t (*fs_close_attr)(fs_volume fs, fs_vnode attr, fs_cookie cookie); status_t (*fs_free_attr_cookie)(fs_volume fs, fs_vnode attr, fs_cookie cookie); - ssize_t (*fs_read_attr)(fs_volume fs, fs_vnode attr, fs_cookie cookie, void *buf, off_t pos, size_t *len); - ssize_t (*fs_write_attr)(fs_volume fs, fs_vnode attr, fs_cookie cookie, const void *buf, off_t pos, size_t *len); - status_t (*fs_seek_attr)(fs_volume fs, fs_vnode attr, fs_cookie cookie, off_t pos, int st); + ssize_t (*fs_read_attr)(fs_volume fs, fs_vnode attr, fs_cookie cookie, void *buffer, off_t pos, size_t *len); + ssize_t (*fs_write_attr)(fs_volume fs, fs_vnode attr, fs_cookie cookie, const void *buffer, off_t pos, size_t *len); + status_t (*fs_seek_attr)(fs_volume fs, fs_vnode attr, fs_cookie cookie, off_t pos, int seekType); + status_t (*fs_rename_attr)(fs_volume fs, fs_vnode file, const char *oldName, const char *newName); status_t (*fs_remove_attr)(fs_volume fs, fs_vnode file, const char *name); + status_t (*fs_read_attr_stat)(fs_volume fs, fs_vnode attr, fs_cookie cookie, struct stat *stat); + status_t (*fs_write_attr_stat)(fs_volume fs, fs_vnode attr, fs_cookie cookie, struct stat *stat, int statMask); /* index directory & index operations */ status_t (*fs_open_index_dir)(fs_volume fs, fs_vnode v, fs_cookie *cookie, int oflags); @@ -121,6 +122,10 @@ struct fs_calls { status_t (*fs_read_index_dir)(fs_volume fs, fs_vnode v, fs_cookie cookie, struct dirent *buffer, size_t bufferSize, uint32 *_num); status_t (*fs_rewind_index_dir)(fs_volume fs, fs_vnode v, fs_cookie cookie); + status_t (*fs_create_index)(fs_volume fs, const char *name, uint32 type, int flags); + status_t (*fs_remove_index)(fs_volume fs, const char *name); + status_t (*fs_read_index_stat)(fs_volume fs, const char *name, struct stat *stat); + /* query operations */ status_t (*fs_open_query)(fs_volume fs, fs_vnode v, fs_cookie *cookie, int oflags); status_t (*fs_close_query)(fs_volume fs, fs_vnode v, fs_cookie cookie); diff --git a/headers/posix/sys/stat.h b/headers/posix/sys/stat.h index 888fa116f8..53d5bcedde 100644 --- a/headers/posix/sys/stat.h +++ b/headers/posix/sys/stat.h @@ -2,27 +2,28 @@ #define _SYS_STAT_H_ #include -//#include -#include +#include /* * stat structure */ struct stat { - dev_t st_dev; /* "device" that this file resides on */ - ino_t st_ino; /* this file's inode #, unique per device */ - mode_t st_mode; /* mode bits (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) */ - 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 */ + dev_t st_dev; /* "device" that this file resides on */ + ino_t st_ino; /* this file's inode #, unique per device */ + mode_t st_mode; /* mode bits (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 */ + // ToDo: st_type is new for OpenBeOS - it replaces the unused st_rdev field + unsigned int st_type; /* attribute/index type */ + //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 */ }; /* extended file types */