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
This commit is contained in:
@@ -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 <OS.h>
|
||||||
|
#include <dirent.h>
|
||||||
|
|
||||||
|
|
||||||
|
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 */
|
||||||
@@ -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 <OS.h>
|
||||||
|
#include <dirent.h>
|
||||||
|
|
||||||
|
|
||||||
|
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 */
|
||||||
+11
-10
@@ -1,6 +1,7 @@
|
|||||||
/* fs_info.h
|
/* 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
|
#ifndef _FS_INFO_H
|
||||||
@@ -8,9 +9,6 @@
|
|||||||
|
|
||||||
#include <OS.h>
|
#include <OS.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* fs_info.flags */
|
/* fs_info.flags */
|
||||||
#define B_FS_IS_READONLY 0x00000001
|
#define B_FS_IS_READONLY 0x00000001
|
||||||
@@ -25,12 +23,12 @@ extern "C" {
|
|||||||
#define B_FS_HAS_ALIASES 0x00100000
|
#define B_FS_HAS_ALIASES 0x00100000
|
||||||
#define B_FS_SUPPORTS_NODE_MONITORING 0x00200000
|
#define B_FS_SUPPORTS_NODE_MONITORING 0x00200000
|
||||||
|
|
||||||
struct fs_info {
|
typedef struct fs_info {
|
||||||
dev_t dev; /* fs dev_t */
|
dev_t dev; /* volume dev_t */
|
||||||
ino_t root; /* root ino_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 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 total_blocks; /* total number of blocks */
|
||||||
off_t free_blocks; /* number of free blocks */
|
off_t free_blocks; /* number of free blocks */
|
||||||
off_t total_nodes; /* total number of nodes */
|
off_t total_nodes; /* total number of nodes */
|
||||||
@@ -38,9 +36,12 @@ struct fs_info {
|
|||||||
char device_name[128]; /* device holding fs */
|
char device_name[128]; /* device holding fs */
|
||||||
char volume_name[B_FILE_NAME_LENGTH]; /* volume name */
|
char volume_name[B_FILE_NAME_LENGTH]; /* volume name */
|
||||||
char fsh_name[B_OS_NAME_LENGTH]; /* name of fs handler */
|
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 dev_for_path(const char *path);
|
||||||
extern dev_t next_dev(int32 *pos);
|
extern dev_t next_dev(int32 *pos);
|
||||||
|
|||||||
@@ -12,8 +12,6 @@
|
|||||||
struct dirent;
|
struct dirent;
|
||||||
struct stat;
|
struct stat;
|
||||||
struct fs_info;
|
struct fs_info;
|
||||||
struct attr_info;
|
|
||||||
struct index_info;
|
|
||||||
|
|
||||||
|
|
||||||
/* the file system's private data structures */
|
/* 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_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_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);
|
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_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 *buf, 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 st);
|
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_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_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 */
|
/* index directory & index operations */
|
||||||
status_t (*fs_open_index_dir)(fs_volume fs, fs_vnode v, fs_cookie *cookie, int oflags);
|
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_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_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 */
|
/* query operations */
|
||||||
status_t (*fs_open_query)(fs_volume fs, fs_vnode v, fs_cookie *cookie, int oflags);
|
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);
|
status_t (*fs_close_query)(fs_volume fs, fs_vnode v, fs_cookie cookie);
|
||||||
|
|||||||
+16
-15
@@ -2,27 +2,28 @@
|
|||||||
#define _SYS_STAT_H_
|
#define _SYS_STAT_H_
|
||||||
|
|
||||||
#include <OS.h>
|
#include <OS.h>
|
||||||
//#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <ktypes.h>
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* stat structure
|
* stat structure
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct stat {
|
struct stat {
|
||||||
dev_t st_dev; /* "device" that this file resides on */
|
dev_t st_dev; /* "device" that this file resides on */
|
||||||
ino_t st_ino; /* this file's inode #, unique per device */
|
ino_t st_ino; /* this file's inode #, unique per device */
|
||||||
mode_t st_mode; /* mode bits (rwx for user, group, etc) */
|
mode_t st_mode; /* mode bits (rwx for user, group, etc) */
|
||||||
nlink_t st_nlink; /* number of hard links to this file */
|
nlink_t st_nlink; /* number of hard links to this file */
|
||||||
uid_t st_uid; /* user id of the owner of 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 */
|
gid_t st_gid; /* group id of the owner of this file */
|
||||||
off_t st_size; /* size in bytes of this file */
|
off_t st_size; /* size in bytes of this file */
|
||||||
dev_t st_rdev; /* device type (not used) */
|
// ToDo: st_type is new for OpenBeOS - it replaces the unused st_rdev field
|
||||||
size_t st_blksize; /* preferred block size for i/o */
|
unsigned int st_type; /* attribute/index type */
|
||||||
time_t st_atime; /* last access time */
|
//dev_t st_rdev; /* device type (not used) */
|
||||||
time_t st_mtime; /* last modification time */
|
size_t st_blksize; /* preferred block size for i/o */
|
||||||
time_t st_ctime; /* last change time, not creation time */
|
time_t st_atime; /* last access time */
|
||||||
time_t st_crtime; /* creation 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 */
|
/* extended file types */
|
||||||
|
|||||||
Reference in New Issue
Block a user