disk_scanner module API.

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2273 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold 2002-12-21 19:07:30 +00:00
parent 45b15a27e1
commit bc0ffa26e0
4 changed files with 324 additions and 0 deletions

View File

@ -0,0 +1,158 @@
// disk_scanner.h
#ifndef _DISKSCANNER_H
#define _DISKSCANNER_H
#include <Drivers.h>
#include <module.h>
struct extended_partition_info;
struct partition_module_info;
struct session_info;
struct session_module_info;
#define PARTSCAN_MODULE_NAME "disk_scanner/disk_scanner/v1"
typedef status_t (*disk_scanner_get_session_module_hook)(int deviceFD,
off_t deviceSize, int32 blockSize,
struct session_module_info **sessionModule);
typedef status_t (*disk_scanner_get_partition_module_hook)(int deviceFD,
off_t sessionOffset, off_t sessionSize, int32 blockSize,
struct partition_module_info **partitionModule);
typedef status_t (*disk_scanner_get_nth_session_info_hook)(int deviceFD,
int32 index, struct session_info *sessionInfo);
typedef status_t (*disk_scanner_get_nth_partition_info_hook)(int deviceFD,
off_t sessionOffset, off_t sessionSize,
struct extended_partition_info *partitionInfo);
typedef status_t (*disk_scanner_get_partition_fs_info_hook)(int deviceFD,
struct extended_partition_info *partitionInfo);
typedef struct disk_scanner_module_info {
module_info module;
disk_scanner_get_session_module_hook get_session_module;
disk_scanner_get_partition_module_hook get_partition_module;
disk_scanner_get_nth_session_info_hook get_nth_session_info;
disk_scanner_get_nth_partition_info_hook get_nth_partition_info;
disk_scanner_get_partition_fs_info_hook get_partition_fs_info;
} disk_scanner_module_info;
/*
get_session_module:
------------------
Searches for a module that can deal with the sessions on the specified
device and returns a module_info for it. put_module() must be called, when
done with the module.
params:
deviceFD: a device FD
deviceSize: size of the device in bytes
blockSize: the logical block size
sessionModule: buffer the pointer to the found module_info shall be
written into
Returns B_OK, if a module could be found, B_ENTRY_NOT_FOUND, if no
module was suitable for the job.
get_partition_module:
--------------------
Searches for a module that can deal with the partitions on the specified
session and returns a module_info for it. put_module() must be called, when
done with the module.
params:
deviceFD: a device FD
sessionOffset: start of the session in bytes from the beginning of the
device
sessionSize: size of the session in bytes
blockSize: the logical block size
partitionModule: buffer the pointer to the found module_info shall be
written into
Returns B_OK, if a module could be found, B_ENTRY_NOT_FOUND, if no
module was suitable for the job.
get_nth_session_info():
----------------------
Fills in all fields of sessionInfo with information about
the indexth session on the specified device.
params:
deviceFD: a device FD
index: the session index
sessionInfo: the session info
The function first checks, whether the device is one that usually has
sessions (a CD). If so, it tries to find a suitable module and delegates
the work to that module. Otherwise, it is assumed, that the device does
not have sessions and for index == 0 the info is filled out with data
for a "virtual" session, i.e. one that spans the whole device.
Returns B_OK, if successful, B_ENTRY_NOT_FOUND, if no suitable session
module could be found or if the session index is out of range.
get_nth_partition_info():
------------------------
Fills in the following fields of partitionInfo with information about
the indexth partition on the specified session:
* offset
* size
* flags
* partition_name
* partition_type
* partition_code
params:
deviceFD: a device FD
sessionOffset: start of the session in bytes from the beginning of the
device
sessionSize: size of the session in bytes
partitionInfo: the partition info
The following fields of partitionInfo are required to be set when the
functions is invoked:
* logical_block_size
* session
* partition
The function first tries to find a suitable partition module and to
delagate the work to that module. If no module could be found, for
partition index == 0 the info is filled out with data for a "virtual"
partition, i.e. one that spans the whole session.
Returns B_OK, if successful, B_ENTRY_NOT_FOUND, if the index is out of
range.
get_partition_fs_info():
-----------------------
Expects partitionInfo to be partially initialized and, if a module could
be found, that recognizes the FS on the partition, fills in
the fields:
* file_system_short_name
* file_system_long_name
* volume_name
The minimally required fields are:
* offset
* size
* logical_block_size
params:
deviceFD: a device FD
partitionInfo: the partition info
Returns B_OK, if successful (i.e. the FS was recognized),
B_ENTRY_NOT_FOUND, if no suitable module could be found.
*/
#endif // _DISKSCANNER_H

View File

@ -0,0 +1,42 @@
// fs.h
#ifndef _PARTSCAN_FS_H
#define _PARTSCAN_FS_H
#include <module.h>
struct extended_partition_info;
typedef bool (*fs_identify_hook)(int deviceFD,
struct extended_partition_info *partitionInfo);
typedef struct fs_module_info {
module_info module;
fs_identify_hook identify;
} fs_module_info;
/*
identify():
----------
Expects partitionInfo to be partially initialized and, if
the module is able to recognize the FS on the partition, fills in
the fields:
* file_system_short_name
* file_system_long_name
* volume_name
The minimally required fields are:
* offset
* size
* logical_block_size
params:
deviceFD: a device FD
partitionInfo: the partition info
Returns true, if successful (i.e. the FS was recognized), false otherwise.
*/
#endif // _PARTSCAN_FS_H

View File

@ -0,0 +1,69 @@
// partition.h
#ifndef _PARTSCAN_PARTITION_H
#define _PARTSCAN_PARTITION_H
#include <module.h>
struct extended_partition_info;
typedef bool (*partition_identify_hook)(int deviceFD, off_t sessionOffset,
off_t sessionSize, const uchar *block, int32 blockSize);
typedef status_t (*partition_get_nth_info_hook)(int deviceFD,
off_t sessionOffset, off_t sessionSize, const uchar *block,
int32 blockSize, int32 index,
struct extended_partition_info *partitionInfo);
typedef struct partition_module_info {
module_info module;
partition_identify_hook identify;
partition_get_nth_info_hook get_nth_info;
} partition_module_info;
/*
identify():
----------
Checks whether the partition map of the given session can be recognized
by the module. Returns true, if it can, false otherwise.
params:
deviceFD: a device FD
sessionOffset: start of the session in bytes from the beginning of the
device
sessionSize: size of the session in bytes
block: the first block of the session
blockSize: the logical block size
get_nth_info():
--------------
Fills in the following fields of partitionInfo with information about
the indexth partition on the specified session:
* offset
* size
* flags
* partition_name
* partition_type
* partition_code
params:
deviceFD: a device FD
sessionOffset: start of the session in bytes from the beginning of the
device
sessionSize: size of the session in bytes
block: the first block of the session
blockSize: the logical block size
index: the partition index
partitionInfo: the partition info
The functions is only called, when a call to identify() returned
true.
Returns B_OK, if successful, B_ENTRY_NOT_FOUND, if the index is out of
range.
*/
#endif _PARTSCAN_PARTITION_H

View File

@ -0,0 +1,55 @@
// session.h
#ifndef _PARTSCAN_SESSION_H
#define _PARTSCAN_SESSION_H
#include <module.h>
struct session_info;
typedef bool (*session_identify_hook)(int deviceFD, off_t deviceSize,
int32 blockSize);
typedef status_t (*session_get_nth_info_hook)(int deviceFD, int32 index,
off_t deviceSize, int32 blockSize, struct session_info *sessionInfo);
typedef struct session_module_info {
module_info module;
session_identify_hook identify;
session_get_nth_info_hook get_nth_info;
} session_module_info;
/*
identify():
----------
Checks whether the module knows about sessions on the given device.
Returns true, if it does, false otherwise.
params:
deviceFD: a device FD
deviceSize: size of the device in bytes
blockSize: the logical block size
get_nth_info():
--------------
Fills in all fields of sessionInfo with information about
the indexth session on the specified device.
params:
deviceFD: a device FD
index: the session index
deviceSize: size of the device in bytes
blockSize: the logical block size
sessionInfo: the session info
The functions is only called, when a call to identify() returned
true.
Returns B_OK, if successful, B_ENTRY_NOT_FOUND, if the index is out of
range.
*/
#endif // _PARTSCAN_SESSION_H