2007-07-05 18:48:16 +04:00
|
|
|
/*
|
|
|
|
* Copyright 2004-2007, Haiku Inc. All Rights Reserved.
|
2004-11-12 20:02:55 +03:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
2003-01-17 20:52:33 +03:00
|
|
|
#ifndef _FS_INTERFACE_H
|
|
|
|
#define _FS_INTERFACE_H
|
|
|
|
|
2007-07-05 18:48:16 +04:00
|
|
|
/*! File System Interface Layer Definition */
|
|
|
|
|
2004-09-04 21:13:45 +04:00
|
|
|
|
2003-08-02 12:33:05 +04:00
|
|
|
#include <OS.h>
|
2004-10-01 04:28:57 +04:00
|
|
|
#include <Select.h>
|
2004-06-07 21:14:17 +04:00
|
|
|
#include <module.h>
|
2005-05-23 21:15:56 +04:00
|
|
|
#include <disk_device_manager.h>
|
2004-10-01 04:28:57 +04:00
|
|
|
|
|
|
|
#include <sys/uio.h>
|
2003-01-17 20:52:33 +03:00
|
|
|
|
2004-09-04 21:13:45 +04:00
|
|
|
|
2003-01-17 20:52:33 +03:00
|
|
|
struct dirent;
|
|
|
|
struct stat;
|
|
|
|
struct fs_info;
|
2005-03-18 00:04:25 +03:00
|
|
|
struct select_sync;
|
2003-01-17 20:52:33 +03:00
|
|
|
|
|
|
|
/* the file system's private data structures */
|
|
|
|
typedef void *fs_volume;
|
|
|
|
typedef void *fs_cookie;
|
|
|
|
typedef void *fs_vnode;
|
|
|
|
|
|
|
|
/* passed to write_stat() */
|
|
|
|
enum write_stat_mask {
|
|
|
|
FS_WRITE_STAT_MODE = 0x0001,
|
|
|
|
FS_WRITE_STAT_UID = 0x0002,
|
|
|
|
FS_WRITE_STAT_GID = 0x0004,
|
|
|
|
FS_WRITE_STAT_SIZE = 0x0008,
|
|
|
|
FS_WRITE_STAT_ATIME = 0x0010,
|
|
|
|
FS_WRITE_STAT_MTIME = 0x0020,
|
|
|
|
FS_WRITE_STAT_CRTIME = 0x0040
|
2004-10-02 20:14:38 +04:00
|
|
|
// NOTE: Changing these constants will break
|
|
|
|
// src/kits/storage/LibBeAdapter.cpp:_kern_write_stat().
|
2003-01-17 20:52:33 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
/* passed to write_fs_info() */
|
|
|
|
#define FS_WRITE_FSINFO_NAME 0x0001
|
|
|
|
|
2004-09-04 21:13:45 +04:00
|
|
|
struct file_io_vec {
|
|
|
|
off_t offset;
|
|
|
|
off_t length;
|
|
|
|
};
|
|
|
|
|
2004-06-07 21:14:17 +04:00
|
|
|
#define B_CURRENT_FS_API_VERSION "/v1"
|
2003-01-17 20:52:33 +03:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2005-05-23 21:15:56 +04:00
|
|
|
typedef struct file_system_module_info {
|
|
|
|
struct module_info info;
|
2007-08-23 01:21:30 +04:00
|
|
|
const char* pretty_name;
|
|
|
|
uint32 flags; // DDM flags
|
2005-05-23 21:15:56 +04:00
|
|
|
|
|
|
|
/* scanning (the device is write locked) */
|
|
|
|
float (*identify_partition)(int fd, partition_data *partition,
|
|
|
|
void **cookie);
|
|
|
|
status_t (*scan_partition)(int fd, partition_data *partition,
|
|
|
|
void *cookie);
|
|
|
|
void (*free_identify_partition_cookie)(partition_data *partition,
|
|
|
|
void *cookie);
|
|
|
|
void (*free_partition_content_cookie)(partition_data *partition);
|
2004-06-07 21:14:17 +04:00
|
|
|
|
2003-01-17 20:52:33 +03:00
|
|
|
/* general operations */
|
2007-07-05 18:48:16 +04:00
|
|
|
status_t (*mount)(dev_t id, const char *device, uint32 flags,
|
|
|
|
const char *args, fs_volume *_fs, ino_t *_rootVnodeID);
|
2003-01-17 20:52:33 +03:00
|
|
|
status_t (*unmount)(fs_volume fs);
|
|
|
|
|
|
|
|
status_t (*read_fs_info)(fs_volume fs, struct fs_info *info);
|
2007-02-25 02:05:18 +03:00
|
|
|
status_t (*write_fs_info)(fs_volume fs, const struct fs_info *info,
|
|
|
|
uint32 mask);
|
2003-01-17 20:52:33 +03:00
|
|
|
status_t (*sync)(fs_volume fs);
|
|
|
|
|
|
|
|
/* vnode operations */
|
2007-02-25 02:05:18 +03:00
|
|
|
status_t (*lookup)(fs_volume fs, fs_vnode dir, const char *name,
|
2007-07-05 18:48:16 +04:00
|
|
|
ino_t *_id, int *_type);
|
2007-02-25 02:05:18 +03:00
|
|
|
status_t (*get_vnode_name)(fs_volume fs, fs_vnode vnode, char *buffer,
|
|
|
|
size_t bufferSize);
|
2003-01-17 20:52:33 +03:00
|
|
|
|
2007-07-05 18:48:16 +04:00
|
|
|
status_t (*get_vnode)(fs_volume fs, ino_t id, fs_vnode *_vnode,
|
2007-02-25 02:05:18 +03:00
|
|
|
bool reenter);
|
2003-01-17 20:52:33 +03:00
|
|
|
status_t (*put_vnode)(fs_volume fs, fs_vnode vnode, bool reenter);
|
|
|
|
status_t (*remove_vnode)(fs_volume fs, fs_vnode vnode, bool reenter);
|
|
|
|
|
|
|
|
/* VM file access */
|
2004-09-07 01:54:57 +04:00
|
|
|
bool (*can_page)(fs_volume fs, fs_vnode vnode, fs_cookie cookie);
|
2007-02-25 02:05:18 +03:00
|
|
|
status_t (*read_pages)(fs_volume fs, fs_vnode vnode, fs_cookie cookie,
|
|
|
|
off_t pos, const iovec *vecs, size_t count, size_t *_numBytes,
|
|
|
|
bool reenter);
|
|
|
|
status_t (*write_pages)(fs_volume fs, fs_vnode vnode, fs_cookie cookie,
|
|
|
|
off_t pos, const iovec *vecs, size_t count, size_t *_numBytes,
|
|
|
|
bool reenter);
|
2004-09-04 21:13:45 +04:00
|
|
|
|
|
|
|
/* cache file access */
|
2007-02-25 02:05:18 +03:00
|
|
|
status_t (*get_file_map)(fs_volume fs, fs_vnode vnode, off_t offset,
|
|
|
|
size_t size, struct file_io_vec *vecs, size_t *_count);
|
2003-01-17 20:52:33 +03:00
|
|
|
|
|
|
|
/* common operations */
|
2007-02-25 02:05:18 +03:00
|
|
|
status_t (*ioctl)(fs_volume fs, fs_vnode vnode, fs_cookie cookie, ulong op,
|
|
|
|
void *buffer, size_t length);
|
|
|
|
status_t (*set_flags)(fs_volume fs, fs_vnode vnode, fs_cookie cookie,
|
|
|
|
int flags);
|
|
|
|
status_t (*select)(fs_volume fs, fs_vnode vnode, fs_cookie cookie,
|
|
|
|
uint8 event, uint32 ref, selectsync *sync);
|
|
|
|
status_t (*deselect)(fs_volume fs, fs_vnode vnode, fs_cookie cookie,
|
2005-03-18 00:04:25 +03:00
|
|
|
uint8 event, selectsync *sync);
|
2007-02-25 02:05:18 +03:00
|
|
|
status_t (*fsync)(fs_volume fs, fs_vnode vnode);
|
2003-01-17 20:52:33 +03:00
|
|
|
|
2007-03-05 06:52:57 +03:00
|
|
|
status_t (*read_symlink)(fs_volume fs, fs_vnode link, char *buffer,
|
2007-02-25 02:05:18 +03:00
|
|
|
size_t *_bufferSize);
|
|
|
|
status_t (*create_symlink)(fs_volume fs, fs_vnode dir, const char *name,
|
|
|
|
const char *path, int mode);
|
2003-01-17 20:52:33 +03:00
|
|
|
|
2007-02-25 02:05:18 +03:00
|
|
|
status_t (*link)(fs_volume fs, fs_vnode dir, const char *name,
|
|
|
|
fs_vnode vnode);
|
2003-01-17 20:52:33 +03:00
|
|
|
status_t (*unlink)(fs_volume fs, fs_vnode dir, const char *name);
|
2007-02-25 02:05:18 +03:00
|
|
|
status_t (*rename)(fs_volume fs, fs_vnode fromDir, const char *fromName,
|
|
|
|
fs_vnode toDir, const char *toName);
|
2003-01-17 20:52:33 +03:00
|
|
|
|
|
|
|
status_t (*access)(fs_volume fs, fs_vnode vnode, int mode);
|
|
|
|
status_t (*read_stat)(fs_volume fs, fs_vnode vnode, struct stat *stat);
|
2007-02-25 02:05:18 +03:00
|
|
|
status_t (*write_stat)(fs_volume fs, fs_vnode vnode,
|
|
|
|
const struct stat *stat, uint32 statMask);
|
2003-01-17 20:52:33 +03:00
|
|
|
|
|
|
|
/* file operations */
|
2007-02-25 02:05:18 +03:00
|
|
|
status_t (*create)(fs_volume fs, fs_vnode dir, const char *name,
|
|
|
|
int openMode, int perms, fs_cookie *_cookie,
|
2007-07-05 18:48:16 +04:00
|
|
|
ino_t *_newVnodeID);
|
2007-02-25 02:05:18 +03:00
|
|
|
status_t (*open)(fs_volume fs, fs_vnode vnode, int openMode,
|
|
|
|
fs_cookie *_cookie);
|
|
|
|
status_t (*close)(fs_volume fs, fs_vnode vnode, fs_cookie cookie);
|
|
|
|
status_t (*free_cookie)(fs_volume fs, fs_vnode vnode, fs_cookie cookie);
|
|
|
|
status_t (*read)(fs_volume fs, fs_vnode vnode, fs_cookie cookie, off_t pos,
|
|
|
|
void *buffer, size_t *length);
|
|
|
|
status_t (*write)(fs_volume fs, fs_vnode vnode, fs_cookie cookie, off_t pos,
|
|
|
|
const void *buffer, size_t *length);
|
2003-01-17 20:52:33 +03:00
|
|
|
|
|
|
|
/* directory operations */
|
2007-02-25 02:05:18 +03:00
|
|
|
status_t (*create_dir)(fs_volume fs, fs_vnode parent, const char *name,
|
2007-07-05 18:48:16 +04:00
|
|
|
int perms, ino_t *_newVnodeID);
|
2003-01-17 20:52:33 +03:00
|
|
|
status_t (*remove_dir)(fs_volume fs, fs_vnode parent, const char *name);
|
|
|
|
status_t (*open_dir)(fs_volume fs, fs_vnode vnode, fs_cookie *_cookie);
|
|
|
|
status_t (*close_dir)(fs_volume fs, fs_vnode vnode, fs_cookie cookie);
|
|
|
|
status_t (*free_dir_cookie)(fs_volume fs, fs_vnode vnode, fs_cookie cookie);
|
2007-02-25 02:05:18 +03:00
|
|
|
status_t (*read_dir)(fs_volume fs, fs_vnode vnode, fs_cookie cookie,
|
|
|
|
struct dirent *buffer, size_t bufferSize, uint32 *_num);
|
2003-01-17 20:52:33 +03:00
|
|
|
status_t (*rewind_dir)(fs_volume fs, fs_vnode vnode, fs_cookie cookie);
|
|
|
|
|
|
|
|
/* attribute directory operations */
|
|
|
|
status_t (*open_attr_dir)(fs_volume fs, fs_vnode vnode, fs_cookie *_cookie);
|
|
|
|
status_t (*close_attr_dir)(fs_volume fs, fs_vnode vnode, fs_cookie cookie);
|
2007-02-25 02:05:18 +03:00
|
|
|
status_t (*free_attr_dir_cookie)(fs_volume fs, fs_vnode vnode,
|
|
|
|
fs_cookie cookie);
|
|
|
|
status_t (*read_attr_dir)(fs_volume fs, fs_vnode vnode, fs_cookie cookie,
|
|
|
|
struct dirent *buffer, size_t bufferSize, uint32 *_num);
|
2003-01-17 20:52:33 +03:00
|
|
|
status_t (*rewind_attr_dir)(fs_volume fs, fs_vnode vnode, fs_cookie cookie);
|
|
|
|
|
|
|
|
/* attribute operations */
|
2007-02-25 02:05:18 +03:00
|
|
|
status_t (*create_attr)(fs_volume fs, fs_vnode vnode, const char *name,
|
|
|
|
uint32 type, int openMode, fs_cookie *_cookie);
|
|
|
|
status_t (*open_attr)(fs_volume fs, fs_vnode vnode, const char *name,
|
|
|
|
int openMode, fs_cookie *_cookie);
|
|
|
|
status_t (*close_attr)(fs_volume fs, fs_vnode vnode, fs_cookie cookie);
|
|
|
|
status_t (*free_attr_cookie)(fs_volume fs, fs_vnode vnode,
|
|
|
|
fs_cookie cookie);
|
|
|
|
status_t (*read_attr)(fs_volume fs, fs_vnode vnode, fs_cookie cookie,
|
|
|
|
off_t pos, void *buffer, size_t *length);
|
|
|
|
status_t (*write_attr)(fs_volume fs, fs_vnode vnode, fs_cookie cookie,
|
|
|
|
off_t pos, const void *buffer, size_t *length);
|
|
|
|
|
|
|
|
status_t (*read_attr_stat)(fs_volume fs, fs_vnode vnode, fs_cookie cookie,
|
|
|
|
struct stat *stat);
|
|
|
|
status_t (*write_attr_stat)(fs_volume fs, fs_vnode vnode, fs_cookie cookie,
|
|
|
|
const struct stat *stat, int statMask);
|
|
|
|
status_t (*rename_attr)(fs_volume fs, fs_vnode fromVnode,
|
|
|
|
const char *fromName, fs_vnode toVnode, const char *toName);
|
|
|
|
status_t (*remove_attr)(fs_volume fs, fs_vnode vnode, const char *name);
|
2003-01-17 20:52:33 +03:00
|
|
|
|
|
|
|
/* index directory & index operations */
|
|
|
|
status_t (*open_index_dir)(fs_volume fs, fs_cookie *cookie);
|
|
|
|
status_t (*close_index_dir)(fs_volume fs, fs_cookie cookie);
|
|
|
|
status_t (*free_index_dir_cookie)(fs_volume fs, fs_cookie cookie);
|
2007-02-25 02:05:18 +03:00
|
|
|
status_t (*read_index_dir)(fs_volume fs, fs_cookie cookie,
|
|
|
|
struct dirent *buffer, size_t bufferSize, uint32 *_num);
|
2003-01-17 20:52:33 +03:00
|
|
|
status_t (*rewind_index_dir)(fs_volume fs, fs_cookie cookie);
|
|
|
|
|
2007-02-25 02:05:18 +03:00
|
|
|
status_t (*create_index)(fs_volume fs, const char *name, uint32 type,
|
|
|
|
uint32 flags);
|
2003-01-17 20:52:33 +03:00
|
|
|
status_t (*remove_index)(fs_volume fs, const char *name);
|
2007-02-25 02:05:18 +03:00
|
|
|
status_t (*read_index_stat)(fs_volume fs, const char *name,
|
|
|
|
struct stat *stat);
|
2003-01-17 20:52:33 +03:00
|
|
|
|
|
|
|
/* query operations */
|
2007-02-25 02:05:18 +03:00
|
|
|
status_t (*open_query)(fs_volume fs, const char *query, uint32 flags,
|
|
|
|
port_id port, uint32 token, fs_cookie *_cookie);
|
2003-01-17 20:52:33 +03:00
|
|
|
status_t (*close_query)(fs_volume fs, fs_cookie cookie);
|
|
|
|
status_t (*free_query_cookie)(fs_volume fs, fs_cookie cookie);
|
2005-05-23 21:15:56 +04:00
|
|
|
status_t (*read_query)(fs_volume fs, fs_cookie cookie,
|
|
|
|
struct dirent *buffer, size_t bufferSize, uint32 *_num);
|
2003-01-17 20:52:33 +03:00
|
|
|
status_t (*rewind_query)(fs_volume fs, fs_cookie cookie);
|
2005-05-23 21:15:56 +04:00
|
|
|
|
|
|
|
/* capability querying (the device is read locked) */
|
2007-08-23 01:21:30 +04:00
|
|
|
uint32 (*get_supported_operations)(partition_data* partition, uint32 mask);
|
2005-05-23 21:15:56 +04:00
|
|
|
|
|
|
|
bool (*validate_resize)(partition_data *partition, off_t *size);
|
|
|
|
bool (*validate_move)(partition_data *partition, off_t *start);
|
|
|
|
bool (*validate_set_content_name)(partition_data *partition,
|
|
|
|
char *name);
|
|
|
|
bool (*validate_set_content_parameters)(partition_data *partition,
|
|
|
|
const char *parameters);
|
|
|
|
bool (*validate_initialize)(partition_data *partition, char *name,
|
|
|
|
const char *parameters);
|
|
|
|
|
|
|
|
/* shadow partition modification (device is write locked) */
|
|
|
|
status_t (*shadow_changed)(partition_data *partition,
|
|
|
|
uint32 operation);
|
|
|
|
|
|
|
|
/* writing (the device is NOT locked) */
|
|
|
|
status_t (*defragment)(int fd, partition_id partition,
|
|
|
|
disk_job_id job);
|
|
|
|
status_t (*repair)(int fd, partition_id partition, bool checkOnly,
|
|
|
|
disk_job_id job);
|
|
|
|
status_t (*resize)(int fd, partition_id partition, off_t size,
|
|
|
|
disk_job_id job);
|
|
|
|
status_t (*move)(int fd, partition_id partition, off_t offset,
|
|
|
|
disk_job_id job);
|
|
|
|
status_t (*set_content_name)(int fd, partition_id partition,
|
|
|
|
const char *name, disk_job_id job);
|
|
|
|
status_t (*set_content_parameters)(int fd, partition_id partition,
|
|
|
|
const char *parameters, disk_job_id job);
|
2007-08-02 16:43:49 +04:00
|
|
|
status_t (*initialize)(int fd, partition_id partition, const char *name,
|
2005-05-23 21:15:56 +04:00
|
|
|
const char *parameters, disk_job_id job);
|
|
|
|
} file_system_module_info;
|
2003-01-17 20:52:33 +03:00
|
|
|
|
|
|
|
|
2003-01-18 17:05:58 +03:00
|
|
|
/* file system add-ons only prototypes */
|
2007-07-05 18:48:16 +04:00
|
|
|
extern status_t new_vnode(dev_t mountID, ino_t vnodeID,
|
2007-02-25 02:05:18 +03:00
|
|
|
fs_vnode privateNode);
|
2007-07-05 18:48:16 +04:00
|
|
|
extern status_t publish_vnode(dev_t mountID, ino_t vnodeID,
|
2007-02-25 02:05:18 +03:00
|
|
|
fs_vnode privateNode);
|
2007-07-05 18:48:16 +04:00
|
|
|
extern status_t get_vnode(dev_t mountID, ino_t vnodeID,
|
2007-02-25 02:05:18 +03:00
|
|
|
fs_vnode *_privateNode);
|
2007-07-05 18:48:16 +04:00
|
|
|
extern status_t put_vnode(dev_t mountID, ino_t vnodeID);
|
|
|
|
extern status_t remove_vnode(dev_t mountID, ino_t vnodeID);
|
|
|
|
extern status_t unremove_vnode(dev_t mountID, ino_t vnodeID);
|
|
|
|
extern status_t get_vnode_removed(dev_t mountID, ino_t vnodeID,
|
2007-03-02 03:34:20 +03:00
|
|
|
bool* removed);
|
2004-06-07 18:23:48 +04:00
|
|
|
|
2007-03-05 03:46:57 +03:00
|
|
|
// Deprecated! Will disappear soon!
|
2007-07-05 18:48:16 +04:00
|
|
|
extern status_t notify_listener(int op, dev_t device, ino_t parentNode,
|
|
|
|
ino_t toParentNode, ino_t node, const char *name);
|
|
|
|
|
|
|
|
extern status_t notify_entry_created(dev_t device, ino_t directory,
|
|
|
|
const char *name, ino_t node);
|
|
|
|
extern status_t notify_entry_removed(dev_t device, ino_t directory,
|
|
|
|
const char *name, ino_t node);
|
|
|
|
extern status_t notify_entry_moved(dev_t device, ino_t fromDirectory,
|
|
|
|
const char *fromName, ino_t toDirectory,
|
|
|
|
const char *toName, ino_t node);
|
|
|
|
extern status_t notify_stat_changed(dev_t device, ino_t node,
|
2005-02-02 18:17:54 +03:00
|
|
|
uint32 statFields);
|
2007-07-05 18:48:16 +04:00
|
|
|
extern status_t notify_attribute_changed(dev_t device, ino_t node,
|
2005-02-02 18:17:54 +03:00
|
|
|
const char *attribute, int32 cause);
|
2005-01-30 04:53:37 +03:00
|
|
|
|
|
|
|
extern status_t notify_query_entry_created(port_id port, int32 token,
|
2007-07-05 18:48:16 +04:00
|
|
|
dev_t device, ino_t directory, const char *name,
|
|
|
|
ino_t node);
|
2005-01-30 04:53:37 +03:00
|
|
|
extern status_t notify_query_entry_removed(port_id port, int32 token,
|
2007-07-05 18:48:16 +04:00
|
|
|
dev_t device, ino_t directory, const char *name,
|
|
|
|
ino_t node);
|
2005-01-30 04:53:37 +03:00
|
|
|
|
2003-06-27 06:24:02 +04:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2003-01-17 20:52:33 +03:00
|
|
|
#endif /* _FS_INTERFACE_H */
|