xref: /haiku/docs/user/drivers/fs_interface.dox (revision bb6b48a9c3013e72ad79788692aba2ecb0423c1e)
150c9917fSIngo Weinhold/*
250c9917fSIngo Weinhold * Copyright 2007-2008 Haiku Inc. All rights reserved.
350c9917fSIngo Weinhold * Distributed under the terms of the MIT License.
450c9917fSIngo Weinhold *
550c9917fSIngo Weinhold * Authors:
650c9917fSIngo Weinhold *		Ingo Weinhold <ingo_weinhold@gmx.de>
750c9917fSIngo Weinhold *		Niels Sascha Reedijk <niels.reedijk@gmail.com>
850c9917fSIngo Weinhold *		Axel Dörfler <axeld@pinc-software.de>
950c9917fSIngo Weinhold *
1050c9917fSIngo Weinhold * Corresponds to:
110551e706SIngo Weinhold *		/trunk/headers/os/drivers/fs_interface.h rev 29781
1250c9917fSIngo Weinhold */
1350c9917fSIngo Weinhold
1450c9917fSIngo Weinhold/*!
1550c9917fSIngo Weinhold	\file fs_interface.h
1650c9917fSIngo Weinhold	\ingroup drivers
17820dca4dSJohn Scipione	\ingroup libbe
1850c9917fSIngo Weinhold	\brief Provides an interface for file system modules.
1950c9917fSIngo Weinhold
2050c9917fSIngo Weinhold	See the \ref fs_modules "introduction to file system modules" for a guide on
2150c9917fSIngo Weinhold	how to get started with writing file system modules.
2250c9917fSIngo Weinhold*/
2350c9917fSIngo Weinhold
2450c9917fSIngo Weinhold///// write_stat_mask //////
250551e706SIngo Weinhold// TODO: These have been superseded by the B_STAT_* flags in <NodeMonitor.h>.
260551e706SIngo Weinhold// Move the documentation there!
2750c9917fSIngo Weinhold
2850c9917fSIngo Weinhold/*!
290551e706SIngo Weinhold	\def B_STAT_SIZE_INSECURE
300551e706SIngo Weinhold	\brief Flag for the fs_vnode_ops::write_stat hook indicating that the FS
310551e706SIngo Weinhold		is allowed not to clear the additional space when enlarging a file.
320551e706SIngo Weinhold
330551e706SIngo Weinhold	This flag was added because BFS doesn't support sparse files. It will be
340551e706SIngo Weinhold	phased out, when it does.
359d5b0fdaSAugustin Cavalier*/
360551e706SIngo Weinhold
370551e706SIngo Weinhold
3850c9917fSIngo Weinhold///// FS_WRITE_FSINFO_NAME /////
3950c9917fSIngo Weinhold
4050c9917fSIngo Weinhold/*!
4150c9917fSIngo Weinhold	\def FS_WRITE_FSINFO_NAME
420551e706SIngo Weinhold	\brief Passed to fs_volume_ops::write_fs_info() to indicate that the name
430551e706SIngo Weinhold		of the volume shall be changed.
4450c9917fSIngo Weinhold*/
4550c9917fSIngo Weinhold
4650c9917fSIngo Weinhold///// file_io_vec /////
4750c9917fSIngo Weinhold
4850c9917fSIngo Weinhold/*!
4950c9917fSIngo Weinhold	\struct file_io_vec
5050c9917fSIngo Weinhold	\brief Structure that describes the io vector of a file.
5150c9917fSIngo Weinhold*/
5250c9917fSIngo Weinhold
5350c9917fSIngo Weinhold/*!
5450c9917fSIngo Weinhold	\var off_t file_io_vec::offset
5550c9917fSIngo Weinhold	\brief The offset within the file.
5650c9917fSIngo Weinhold*/
5750c9917fSIngo Weinhold
5850c9917fSIngo Weinhold/*!
5950c9917fSIngo Weinhold	\var off_t file_io_vec::length
6050c9917fSIngo Weinhold	\brief The length of the vector.
6150c9917fSIngo Weinhold*/
6250c9917fSIngo Weinhold
6350c9917fSIngo Weinhold///// B_CURRENT_FS_API_VERSION /////
6450c9917fSIngo Weinhold
6550c9917fSIngo Weinhold/*!
6650c9917fSIngo Weinhold	\def B_CURRENT_FS_API_VERSION
6750c9917fSIngo Weinhold	\brief Constant that defines the version of the file system API that your
6850c9917fSIngo Weinhold		filesystem conforms to.
6950c9917fSIngo Weinhold
7050c9917fSIngo Weinhold	The module name that exports the interface to your file system has to
7150c9917fSIngo Weinhold	end with this constant as in:
7250c9917fSIngo Weinhold	\code "file_systems/myfs" B_CURRENT_FS_API_VERSION \endcode
7350c9917fSIngo Weinhold*/
7450c9917fSIngo Weinhold
750551e706SIngo Weinhold
760551e706SIngo Weinhold///// B_VNODE_PUBLISH_REMOVED /////
770551e706SIngo Weinhold
780551e706SIngo Weinhold/*!
790551e706SIngo Weinhold	\def B_VNODE_PUBLISH_REMOVED
800551e706SIngo Weinhold	\brief Flag for publish_vnode() and fs_vnode_ops::create_special_node()
810551e706SIngo Weinhold		indicating that the node shall be published in removed state (i.e. no
820551e706SIngo Weinhold		entry refers to it).
830551e706SIngo Weinhold*/
840551e706SIngo Weinhold
850551e706SIngo Weinhold///// B_VNODE_DONT_CREATE_SPECIAL_SUB_NODE /////
860551e706SIngo Weinhold
870551e706SIngo Weinhold/*!
880551e706SIngo Weinhold	\def B_VNODE_DONT_CREATE_SPECIAL_SUB_NODE
890551e706SIngo Weinhold	\brief Flag for publish_vnode() and fs_volume_ops::get_vnode()
900551e706SIngo Weinhold		indicating that no subnodes shall be created for the node to publish
910551e706SIngo Weinhold		the node shall be published.
920551e706SIngo Weinhold*/
930551e706SIngo Weinhold
940551e706SIngo Weinhold
9550c9917fSIngo Weinhold///// file_system_module_info /////
9650c9917fSIngo Weinhold
9750c9917fSIngo Weinhold
9850c9917fSIngo Weinhold/*!
9950c9917fSIngo Weinhold	\struct file_system_module_info
10050c9917fSIngo Weinhold	\brief Kernel module interface for file systems.
10150c9917fSIngo Weinhold
10250c9917fSIngo Weinhold	See the \ref fs_modules "introduction to file system modules" for an
10350c9917fSIngo Weinhold	introduction to writing file systems.
10450c9917fSIngo Weinhold*/
10550c9917fSIngo Weinhold
10650c9917fSIngo Weinhold/*!
10750c9917fSIngo Weinhold	\name Data members
10850c9917fSIngo Weinhold*/
10950c9917fSIngo Weinhold
11050c9917fSIngo Weinhold//! @{
11150c9917fSIngo Weinhold
11250c9917fSIngo Weinhold/*!
11350c9917fSIngo Weinhold	\var module_info file_system_module_info::info
11450c9917fSIngo Weinhold	\brief Your module_info object which is required for all modules.
11550c9917fSIngo Weinhold*/
11650c9917fSIngo Weinhold
11750c9917fSIngo Weinhold/*!
11850c9917fSIngo Weinhold	\var const char *file_system_module_info::pretty_name
11950c9917fSIngo Weinhold	\brief A NULL-terminated string with a 'pretty' name for you file system.
12050c9917fSIngo Weinhold
1210551e706SIngo Weinhold	Note, if a system wide disk device type constant exists for your file
1220551e706SIngo Weinhold	system, it should equal this identifier.
12350c9917fSIngo Weinhold*/
12450c9917fSIngo Weinhold
12550c9917fSIngo Weinhold//! @}
12650c9917fSIngo Weinhold
12750c9917fSIngo Weinhold/*!
12850c9917fSIngo Weinhold	\name Scanning
12950c9917fSIngo Weinhold*/
13050c9917fSIngo Weinhold
13150c9917fSIngo Weinhold//! @{
13250c9917fSIngo Weinhold
13350c9917fSIngo Weinhold/*!
13450c9917fSIngo Weinhold	\fn float (*file_system_module_info::identify_partition)(int fd,
13550c9917fSIngo Weinhold			partition_data *partition, void **cookie)
13650c9917fSIngo Weinhold	\brief Undocumented. TODO.
13750c9917fSIngo Weinhold*/
13850c9917fSIngo Weinhold
13950c9917fSIngo Weinhold/*!
14050c9917fSIngo Weinhold	\fn status_t (*file_system_module_info::scan_partition)(int fd,
14150c9917fSIngo Weinhold			partition_data *partition, void *cookie)
14250c9917fSIngo Weinhold	\brief Undocumented. TODO.
14350c9917fSIngo Weinhold*/
14450c9917fSIngo Weinhold
14550c9917fSIngo Weinhold/*!
14650c9917fSIngo Weinhold	\fn void (*file_system_module_info::free_identify_partition_cookie)(
14750c9917fSIngo Weinhold			partition_data *partition, void *cookie)
14850c9917fSIngo Weinhold	\brief Undocumented. TODO.
14950c9917fSIngo Weinhold*/
15050c9917fSIngo Weinhold
15150c9917fSIngo Weinhold/*!
15250c9917fSIngo Weinhold	\fn void (*file_system_module_info::free_partition_content_cookie)(
15350c9917fSIngo Weinhold			partition_data *partition)
15450c9917fSIngo Weinhold	\brief Undocumented. TODO.
15550c9917fSIngo Weinhold*/
15650c9917fSIngo Weinhold
15750c9917fSIngo Weinhold//! @}
15850c9917fSIngo Weinhold
15950c9917fSIngo Weinhold/*!
16050c9917fSIngo Weinhold	\name General Operations
16150c9917fSIngo Weinhold*/
16250c9917fSIngo Weinhold
16350c9917fSIngo Weinhold//! @{
16450c9917fSIngo Weinhold
16550c9917fSIngo Weinhold/*!
1660551e706SIngo Weinhold	\fn status_t (*file_system_module_info::mount)(fs_volume *volume,
1670551e706SIngo Weinhold			const char *device, uint32 flags, const char *args,
1680551e706SIngo Weinhold			ino_t *_rootVnodeID)
1690551e706SIngo Weinhold
17050c9917fSIngo Weinhold	\brief Mount a volume according to the specified parameters.
17150c9917fSIngo Weinhold
17250c9917fSIngo Weinhold	Invoked by the VFS when it has been requested to mount the volume. The FS is
17350c9917fSIngo Weinhold	supposed to perform whatever one-time initialization is necessary for the
17450c9917fSIngo Weinhold	volume. It is required to create a volume handle for the volume and pass it
1750551e706SIngo Weinhold	back in \a volume->private_volume and set \a volume->ops to the operation
1760551e706SIngo Weinhold	vector for the volume. Moreover it must invoke publish_vnode() for the root
1770551e706SIngo Weinhold	node of the volume and pass the ID of the volume back in \a _rootVnodeID.
17850c9917fSIngo Weinhold
17950c9917fSIngo Weinhold	A disk-based FS will need to check whether \a device is not \c NULL, open
1800551e706SIngo Weinhold	it, and analyze whether the device or image file actually represents a
1810551e706SIngo Weinhold	volume of that FS type.
18250c9917fSIngo Weinhold
18350c9917fSIngo Weinhold	If mounting the volume fails for whatever reason, the hook must return an
18450c9917fSIngo Weinhold	error code other than \c B_OK. In this case all resources allocated by the
18550c9917fSIngo Weinhold	hook must be freed before returning. If and only if \c B_OK is returned, the
18650c9917fSIngo Weinhold	unmount() hook will be invoked at a later point when unmounting the volume.
18750c9917fSIngo Weinhold
1880551e706SIngo Weinhold	\param volume Object created by the VFS to represent the volume. Its
1890551e706SIngo Weinhold		\c private_volume and \c ops members must be set by the hooks. All other
1900551e706SIngo Weinhold		members are read-only for the FS.
19150c9917fSIngo Weinhold	\param device The path to the device (or image file) representing the volume
19250c9917fSIngo Weinhold		to be mounted. Can be \c NULL.
19350c9917fSIngo Weinhold	\param flags Flags:
19450c9917fSIngo Weinhold		- \c B_MOUNT_READ_ONLY: Mount the volume read-only.
19550c9917fSIngo Weinhold	\param args Null-terminated string in driver settings format, containing FS
19650c9917fSIngo Weinhold		specific parameters.
19750c9917fSIngo Weinhold	\param _rootVnodeID Pointer to a pre-allocated variable the ID of the
19850c9917fSIngo Weinhold		volume's root directory shall be written to.
19950c9917fSIngo Weinhold	\return \c B_OK if everything went fine, another error code otherwise.
20050c9917fSIngo Weinhold*/
20150c9917fSIngo Weinhold
20250c9917fSIngo Weinhold//! @}
20350c9917fSIngo Weinhold
20450c9917fSIngo Weinhold/*!
20550c9917fSIngo Weinhold	\name Capability Querying
20650c9917fSIngo Weinhold*/
20750c9917fSIngo Weinhold
20850c9917fSIngo Weinhold//! @{
20950c9917fSIngo Weinhold
21050c9917fSIngo Weinhold/*!
21150c9917fSIngo Weinhold	\fn bool (*file_system_module_info::validate_resize)(partition_data *partition, off_t *size)
21250c9917fSIngo Weinhold	\brief Undocumented. TODO.
21350c9917fSIngo Weinhold*/
21450c9917fSIngo Weinhold
21550c9917fSIngo Weinhold/*!
21650c9917fSIngo Weinhold	\fn bool (*file_system_module_info::validate_move)(partition_data *partition, off_t *start)
21750c9917fSIngo Weinhold	\brief Undocumented. TODO.
21850c9917fSIngo Weinhold*/
21950c9917fSIngo Weinhold
22050c9917fSIngo Weinhold/*!
22150c9917fSIngo Weinhold	\fn bool (*file_system_module_info::validate_set_content_name)(partition_data *partition,
22250c9917fSIngo Weinhold			char *name)
22350c9917fSIngo Weinhold	\brief Undocumented. TODO.
22450c9917fSIngo Weinhold*/
22550c9917fSIngo Weinhold
22650c9917fSIngo Weinhold/*!
22750c9917fSIngo Weinhold	\fn bool (*file_system_module_info::validate_set_content_parameters)(partition_data *partition,
22850c9917fSIngo Weinhold			const char *parameters)
22950c9917fSIngo Weinhold	\brief Undocumented. TODO.
23050c9917fSIngo Weinhold*/
23150c9917fSIngo Weinhold
23250c9917fSIngo Weinhold/*!
23350c9917fSIngo Weinhold	\fn bool (*file_system_module_info::validate_initialize)(partition_data *partition, char *name,
23450c9917fSIngo Weinhold			const char *parameters)
23550c9917fSIngo Weinhold	\brief Undocumented. TODO.
23650c9917fSIngo Weinhold*/
23750c9917fSIngo Weinhold
23850c9917fSIngo Weinhold//! @}
23950c9917fSIngo Weinhold
24050c9917fSIngo Weinhold/*!
24150c9917fSIngo Weinhold	\name Shadow Partition Modification
24250c9917fSIngo Weinhold*/
24350c9917fSIngo Weinhold
24450c9917fSIngo Weinhold//! @{
24550c9917fSIngo Weinhold
24650c9917fSIngo Weinhold/*!
24750c9917fSIngo Weinhold	\fn status_t (*file_system_module_info::shadow_changed)(partition_data *partition,
24850c9917fSIngo Weinhold			uint32 operation)
24950c9917fSIngo Weinhold	\brief Undocumented. TODO.
25050c9917fSIngo Weinhold*/
25150c9917fSIngo Weinhold
25250c9917fSIngo Weinhold//! @}
25350c9917fSIngo Weinhold
25450c9917fSIngo Weinhold/*!
25550c9917fSIngo Weinhold	\name Special Operations
25650c9917fSIngo Weinhold*/
25750c9917fSIngo Weinhold
25850c9917fSIngo Weinhold//! @{
25950c9917fSIngo Weinhold
26050c9917fSIngo Weinhold/*!
26150c9917fSIngo Weinhold	\fn status_t (*file_system_module_info::defragment)(int fd, partition_id partition,
26250c9917fSIngo Weinhold			disk_job_id job)
26350c9917fSIngo Weinhold	\brief Undocumented. TODO.
26450c9917fSIngo Weinhold*/
26550c9917fSIngo Weinhold
26650c9917fSIngo Weinhold/*!
26750c9917fSIngo Weinhold	\fn status_t (*file_system_module_info::repair)(int fd, partition_id partition, bool checkOnly,
26850c9917fSIngo Weinhold			disk_job_id job)
26950c9917fSIngo Weinhold	\brief Undocumented. TODO.
27050c9917fSIngo Weinhold*/
27150c9917fSIngo Weinhold
27250c9917fSIngo Weinhold/*!
27350c9917fSIngo Weinhold	\fn status_t (*file_system_module_info::resize)(int fd, partition_id partition, off_t size,
27450c9917fSIngo Weinhold			disk_job_id job)
27550c9917fSIngo Weinhold	\brief Undocumented. TODO.
27650c9917fSIngo Weinhold*/
27750c9917fSIngo Weinhold
27850c9917fSIngo Weinhold/*!
27950c9917fSIngo Weinhold	\fn status_t (*file_system_module_info::move)(int fd, partition_id partition, off_t offset,
28050c9917fSIngo Weinhold			disk_job_id job)
28150c9917fSIngo Weinhold	\brief Undocumented. TODO.
28250c9917fSIngo Weinhold*/
28350c9917fSIngo Weinhold
28450c9917fSIngo Weinhold/*!
28550c9917fSIngo Weinhold	\fn status_t (*file_system_module_info::set_content_name)(int fd, partition_id partition,
28650c9917fSIngo Weinhold			const char *name, disk_job_id job)
28750c9917fSIngo Weinhold	\brief Undocumented. TODO.
28850c9917fSIngo Weinhold*/
28950c9917fSIngo Weinhold
29050c9917fSIngo Weinhold/*!
29150c9917fSIngo Weinhold	\fn status_t (*file_system_module_info::set_content_parameters)(int fd, partition_id partition,
29250c9917fSIngo Weinhold			const char *parameters, disk_job_id job)
29350c9917fSIngo Weinhold	\brief Undocumented. TODO.
29450c9917fSIngo Weinhold*/
29550c9917fSIngo Weinhold
29650c9917fSIngo Weinhold/*!
29750c9917fSIngo Weinhold	\fn status_t (*file_system_module_info::initialize)(const char *partition, const char *name,
29850c9917fSIngo Weinhold			const char *parameters, disk_job_id job)
29950c9917fSIngo Weinhold	\brief Undocumented. TODO.
30050c9917fSIngo Weinhold*/
30150c9917fSIngo Weinhold
30250c9917fSIngo Weinhold//! @}
30350c9917fSIngo Weinhold
3040551e706SIngo Weinhold
3050551e706SIngo Weinhold///// fs_volume_ops /////
3060551e706SIngo Weinhold
3070551e706SIngo Weinhold
3080551e706SIngo Weinhold/*!
3090551e706SIngo Weinhold	\struct fs_volume_ops
3100551e706SIngo Weinhold	\brief Operations vector for a volume.
3110551e706SIngo Weinhold
3120551e706SIngo Weinhold	See the \ref fs_modules "introduction to file system modules" for an
3130551e706SIngo Weinhold	introduction to writing file systems.
3140551e706SIngo Weinhold*/
3150551e706SIngo Weinhold
3160551e706SIngo Weinhold/*!
3170551e706SIngo Weinhold	\name General Operations
3180551e706SIngo Weinhold*/
3190551e706SIngo Weinhold
3200551e706SIngo Weinhold//! @{
3210551e706SIngo Weinhold
3220551e706SIngo Weinhold/*!
3230551e706SIngo Weinhold	\fn status_t (*fs_volume_ops::unmount)(fs_volume *volume)
3240551e706SIngo Weinhold	\brief Unmounts the given volume.
3250551e706SIngo Weinhold
3260551e706SIngo Weinhold	Invoked by the VFS when it is asked to unmount the volume. The function must
3270551e706SIngo Weinhold	free all resources associated with the mounted volume, including the volume
328a37c845eSIngo Weinhold	handle. Before unmount() is called, the VFS calls
329a37c845eSIngo Weinhold	file_system_module_info::put_vnode() respectively
330a37c845eSIngo Weinhold	file_system_module_info::remove_vnode() for each of the volume's nodes. That
331a37c845eSIngo Weinhold	is although the mount() hook called publish_vnode() for the volume's root
332a37c845eSIngo Weinhold	node, unmount() must not invoke put_vnode().
3330551e706SIngo Weinhold
3340551e706SIngo Weinhold	\param volume The volume object.
3350551e706SIngo Weinhold	\return \c B_OK if everything went fine, another error code otherwise. The
3360551e706SIngo Weinhold		error code will be ignored, though.
3370551e706SIngo Weinhold*/
3380551e706SIngo Weinhold
3390551e706SIngo Weinhold/*!
3400551e706SIngo Weinhold	\fn status_t (*fs_volume_ops::read_fs_info)(fs_volume *volume,
3410551e706SIngo Weinhold			struct fs_info *info)
3420551e706SIngo Weinhold	\brief Retrieves general information about the volume.
3430551e706SIngo Weinhold
3440551e706SIngo Weinhold	The following fields of the \c fs_info structure need to be filled in:
3450551e706SIngo Weinhold	- \c flags: Flags applying to the volume, e.g. \c B_FS_IS_READONLY,
3460551e706SIngo Weinhold	  \c B_FS_HAS_ATTR, etc.
3470551e706SIngo Weinhold	- \c block_size: The size of blocks the volume data are organized in.
3480551e706SIngo Weinhold	  Meaningful mainly for disk-based FSs, other FSs should use some reasonable
3490551e706SIngo Weinhold	  value for computing \c total_blocks and \c free_blocks.
3500551e706SIngo Weinhold	- \c io_size: Preferred size of the buffers passed to read() and write().
3510551e706SIngo Weinhold	- \c total_blocks: Total number of blocks the volume contains.
3520551e706SIngo Weinhold	- \c free_blocks: Number of free blocks on the volume.
3530551e706SIngo Weinhold	- \c total_nodes: Maximal number of nodes the volume can contain. If there
3540551e706SIngo Weinhold	  is no such limitation use \c LONGLONG_MAX.
3550551e706SIngo Weinhold	- \c free_nodes: Number of additional nodes the volume could contain. If
3560551e706SIngo Weinhold	  there is no such limitation use \c LONGLONG_MAX.
3570551e706SIngo Weinhold	- \c volume_name: The name of the volume.
3580551e706SIngo Weinhold
3590551e706SIngo Weinhold	The other values are filled in by the VFS.
3600551e706SIngo Weinhold
3610551e706SIngo Weinhold	\param volume The volume object.
3620551e706SIngo Weinhold	\param info Pointer to a pre-allocated variable the FS info shall be written
3630551e706SIngo Weinhold		to.
3640551e706SIngo Weinhold	\return \c B_OK if everything went fine, another error code otherwise. The
3650551e706SIngo Weinhold		error code will be ignored, though.
3660551e706SIngo Weinhold*/
3670551e706SIngo Weinhold
3680551e706SIngo Weinhold/*!
3690551e706SIngo Weinhold	\fn status_t (*fs_volume_ops::write_fs_info)(fs_volume *volume,
3700551e706SIngo Weinhold			const struct fs_info *info, uint32 mask)
3710551e706SIngo Weinhold	\brief Update filesystem information on the volume.
3720551e706SIngo Weinhold
3730551e706SIngo Weinhold	You are requested to update certain information on the given volume. The
3740551e706SIngo Weinhold	supplied \a info contains the new values filled in for the \a mask.
3750551e706SIngo Weinhold	Currently, the only possible mask is solely the \c FS_WRITE_FSINFO_NAME,
3760551e706SIngo Weinhold	which asks you to update the volume name represented by the value
3770551e706SIngo Weinhold	\c volume_name in the \c fs_info struct.
3780551e706SIngo Weinhold
3790551e706SIngo Weinhold	\param volume The volume object.
3800551e706SIngo Weinhold	\param info The structure that contains the new data.
3810551e706SIngo Weinhold	\param mask The values of the \a info that need to be updated.
3820551e706SIngo Weinhold	\return \c B_OK if everything went fine, if not, one of the error codes.
3830551e706SIngo Weinhold*/
3840551e706SIngo Weinhold
3850551e706SIngo Weinhold/*!
3860551e706SIngo Weinhold	\fn status_t (*fs_volume_ops::sync)(fs_volume *volume)
3870551e706SIngo Weinhold	\brief Synchronize the cached data with the contents of the disk.
3880551e706SIngo Weinhold
3890551e706SIngo Weinhold	The VFS layer sometimes wants you to synchronize any cached values with the
3900551e706SIngo Weinhold	data on the device.
3910551e706SIngo Weinhold
3920551e706SIngo Weinhold	This currently only happens when the POSIX sync() function is invoked, for
3930551e706SIngo Weinhold	example via the "sync" command line tool.
3940551e706SIngo Weinhold
3950551e706SIngo Weinhold	\param volume The volume object.
3960551e706SIngo Weinhold*/
3970551e706SIngo Weinhold
3980551e706SIngo Weinhold/*!
3990551e706SIngo Weinhold	\fn status_t (*fs_volume_ops::get_vnode)(fs_volume *volume, ino_t id,
4000551e706SIngo Weinhold			fs_vnode *vnode, int *_type, uint32 *_flags, bool reenter)
4010551e706SIngo Weinhold	\brief Creates the private data handle to be associated with the node
4020551e706SIngo Weinhold		referred to by \a id.
4030551e706SIngo Weinhold
4040551e706SIngo Weinhold	Invoked by the VFS when it creates the vnode for the respective node.
4050551e706SIngo Weinhold	When the VFS no longer needs the vnode in memory (for example when
4060551e706SIngo Weinhold	memory is becoming tight), it will your file_system_module_info::put_vnode(),
4070551e706SIngo Weinhold	or file_system_module_info::remove_vnode() in case the vnode has been
4080551e706SIngo Weinhold	marked removed.
4090551e706SIngo Weinhold
4100551e706SIngo Weinhold	The hook has to initialize \a vnode->private_node with its handle created
4111f23605dSIngo Weinhold	for the node and \a vnode->ops with the operation vector for the node. It
4121f23605dSIngo Weinhold	also has to set \c *_type to the type of the node -- as in \c stat::st_mode
4131f23605dSIngo Weinhold	(the non-type bits can, but do not need to be cleared) -- and \c *_flags to
4141f23605dSIngo Weinhold	a bitwise OR of vnode flags to apply (cf. publish_vnode() for what flags
4151f23605dSIngo Weinhold	bits are possible).
4160551e706SIngo Weinhold
4170551e706SIngo Weinhold	\param volume The volume object.
4180551e706SIngo Weinhold	\param id The ID of the node.
4190551e706SIngo Weinhold	\param vnode Pointer to a node object to be initialized.
4201f23605dSIngo Weinhold	\param _type Pointer to a variable to be set to the node's type.
4211f23605dSIngo Weinhold	\param _flags Pointer to a variable to be set to flags to apply to the
4221f23605dSIngo Weinhold		vnode.
4230551e706SIngo Weinhold	\param reenter \c true if the hook invocation has been caused by the FS
4240551e706SIngo Weinhold		itself, e.g. by invoking ::get_vnode().
4250551e706SIngo Weinhold	\return \c B_OK if everything went fine, another error code otherwise.
4260551e706SIngo Weinhold*/
4270551e706SIngo Weinhold
4280551e706SIngo Weinhold//! @}
4290551e706SIngo Weinhold
4300551e706SIngo Weinhold/*!
4310551e706SIngo Weinhold	\name Index Directory and Operation
4320551e706SIngo Weinhold*/
4330551e706SIngo Weinhold
4340551e706SIngo Weinhold//! @{
4350551e706SIngo Weinhold
4360551e706SIngo Weinhold/*!
4370551e706SIngo Weinhold	\fn status_t (*fs_volume_ops::open_index_dir)(fs_volume *volume,
4380551e706SIngo Weinhold			void **_cookie)
4390551e706SIngo Weinhold	\brief Open the list of an indices as a directory.
4400551e706SIngo Weinhold
4410551e706SIngo Weinhold	See \ref concepts "Generic Concepts" on directories and iterators.
4420551e706SIngo Weinhold	Basically, the VFS uses the same way of traversing through indeces as it
4430551e706SIngo Weinhold	traverses through a directory.
4440551e706SIngo Weinhold
4450551e706SIngo Weinhold	\param volume The volume object.
4460551e706SIngo Weinhold	\param[out] _cookie Pointer where the file system can store a directory
4470551e706SIngo Weinhold		cookie if the index directory is succesfully opened.
4480551e706SIngo Weinhold	\return \c B_OK if everything went fine, another error code otherwise.
4490551e706SIngo Weinhold*/
4500551e706SIngo Weinhold
4510551e706SIngo Weinhold/*!
4520551e706SIngo Weinhold	\fn status_t (*fs_volume_ops::close_index_dir)(fs_volume *volume,
4530551e706SIngo Weinhold			void *cookie)
4540551e706SIngo Weinhold	\brief Close a 'directory' of indices.
4550551e706SIngo Weinhold
4560551e706SIngo Weinhold	Note that you should free the cookie in the free_index_dir_cookie() call.
4570551e706SIngo Weinhold
4580551e706SIngo Weinhold	\param volume The volume object.
4590551e706SIngo Weinhold 	\param cookie The cookie associated with this 'directory'.
4600551e706SIngo Weinhold	\return B_OK if everything went fine, another error code otherwise.
4610551e706SIngo Weinhold*/
4620551e706SIngo Weinhold
4630551e706SIngo Weinhold/*!
4640551e706SIngo Weinhold	\fn status_t (*fs_volume_ops::free_index_dir_cookie)(fs_volume *volume,
4650551e706SIngo Weinhold			void *cookie)
4660551e706SIngo Weinhold	\brief Free the \a cookie to the index 'directory'.
4670551e706SIngo Weinhold
4680551e706SIngo Weinhold	\param volume The volume object.
4690551e706SIngo Weinhold	\param cookie The cookie that should be freed.
4700551e706SIngo Weinhold	\return B_OK if everything went fine, another error code otherwise.
4710551e706SIngo Weinhold*/
4720551e706SIngo Weinhold
4730551e706SIngo Weinhold/*!
4740551e706SIngo Weinhold	\fn status_t (*fs_volume_ops::read_index_dir)(fs_volume *volume,
4750551e706SIngo Weinhold			void *cookie, struct dirent *buffer, size_t bufferSize,
4760551e706SIngo Weinhold			uint32 *_num)
4770551e706SIngo Weinhold	\brief Read the next one or more index entries.
4780551e706SIngo Weinhold
4790551e706SIngo Weinhold	This method should perform the same task as fs_vnode_ops::read_dir(),
4800551e706SIngo Weinhold	except that the '.' and the '..' entries don't have to be present.
4810551e706SIngo Weinhold*/
4820551e706SIngo Weinhold
4830551e706SIngo Weinhold/*!
4840551e706SIngo Weinhold	\fn status_t (*fs_volume_ops::rewind_index_dir)(fs_volume *volume,
4850551e706SIngo Weinhold			void *cookie)
4860551e706SIngo Weinhold	\brief Reset the index directory cookie to the first entry of the directory.
4870551e706SIngo Weinhold
4880551e706SIngo Weinhold	\param volume The volume object.
4890551e706SIngo Weinhold	\param cookie The directory cookie as returned by open_index_dir().
4900551e706SIngo Weinhold	\return \c B_OK if everything went fine, another error code otherwise.
4910551e706SIngo Weinhold*/
4920551e706SIngo Weinhold
4930551e706SIngo Weinhold/*!
4940551e706SIngo Weinhold	\fn status_t (*fs_volume_ops::create_index)(fs_volume *volume,
4950551e706SIngo Weinhold			const char *name, uint32 type, uint32 flags)
4960551e706SIngo Weinhold	\brief Create a new index.
4970551e706SIngo Weinhold
4980551e706SIngo Weinhold	\param volume The volume object.
4990551e706SIngo Weinhold	\param name The name of the new index.
5000551e706SIngo Weinhold	\param type The type of index. BFS implements the following types:
5010551e706SIngo Weinhold		- \c B_INT32_TYPE
5020551e706SIngo Weinhold		- \c B_UINT32_TYPE
5030551e706SIngo Weinhold		- \c B_INT64_TYPE
5040551e706SIngo Weinhold		- \c B_UINT64_TYPE
5050551e706SIngo Weinhold		- \c B_FLOAT_TYPE
5060551e706SIngo Weinhold		- \c B_DOUBLE_TYPE
5070551e706SIngo Weinhold		- \c B_STRING_TYPE
5080551e706SIngo Weinhold		- \c B_MIME_STRING_TYPE
5090551e706SIngo Weinhold	\param flags There are currently no extra flags specified. This parameter
5100551e706SIngo Weinhold		can be ignored.
5110551e706SIngo Weinhold	\return You should return \c B_OK if the creation succeeded, or return an
5120551e706SIngo Weinhold		error otherwise.
5130551e706SIngo Weinhold*/
5140551e706SIngo Weinhold
5150551e706SIngo Weinhold/*!
5160551e706SIngo Weinhold	\fn status_t (*fs_volume_ops::remove_index)(fs_volume *volume,
5170551e706SIngo Weinhold			const char *name)
5180551e706SIngo Weinhold	\brief Remove the index with \a name.
5190551e706SIngo Weinhold
5200551e706SIngo Weinhold	\param volume The volume object.
5210551e706SIngo Weinhold	\param name The name of the index to be removed.
5220551e706SIngo Weinhold	\return You should return \c B_OK if the creation succeeded, or return an
5230551e706SIngo Weinhold		error otherwise.
5240551e706SIngo Weinhold*/
5250551e706SIngo Weinhold
5260551e706SIngo Weinhold/*!
5270551e706SIngo Weinhold	\fn status_t (*fs_volume_ops::read_index_stat)(fs_volume *volume,
5280551e706SIngo Weinhold			const char *name, struct stat *stat)
5290551e706SIngo Weinhold	\brief Read the \a stat of the index with a name.
5300551e706SIngo Weinhold
5310551e706SIngo Weinhold	\param volume The volume object.
5320551e706SIngo Weinhold	\param name The name of the index to be queried.
5330551e706SIngo Weinhold	\param stat A pointer to a structure where you should store the values.
5340551e706SIngo Weinhold	\return You should return \c B_OK if the creation succeeded, or return an
5350551e706SIngo Weinhold		error otherwise.
5360551e706SIngo Weinhold*/
5370551e706SIngo Weinhold
5380551e706SIngo Weinhold//! @}
5390551e706SIngo Weinhold
5400551e706SIngo Weinhold/*!
5410551e706SIngo Weinhold	\name Query Operations
5420551e706SIngo Weinhold*/
5430551e706SIngo Weinhold
5440551e706SIngo Weinhold//! @{
5450551e706SIngo Weinhold
5460551e706SIngo Weinhold/*!
5470551e706SIngo Weinhold	\fn status_t (*fs_volume_ops::open_query)(fs_volume *volume,
5480551e706SIngo Weinhold			const char *query, uint32 flags, port_id port, uint32 token,
5490551e706SIngo Weinhold			void **_cookie)
5500551e706SIngo Weinhold	\brief Open a query as a 'directory'.
5510551e706SIngo Weinhold
5520551e706SIngo Weinhold	TODO: query expressions should be documented and also the format for sending
5530551e706SIngo Weinhold	query updates over the port should be updated.
5540551e706SIngo Weinhold
5550551e706SIngo Weinhold	See \ref concepts "Generic Concepts" on directories and iterators.
5560551e706SIngo Weinhold	Basically, the VFS uses the same way of traversing through indices as it
5570551e706SIngo Weinhold	traverses through a directory.
5580551e706SIngo Weinhold
5590551e706SIngo Weinhold	\param volume The volume object.
5600551e706SIngo Weinhold	\param query The string that represents a query.
5610551e706SIngo Weinhold	\param flags Any combination of none or more of these flags:
562a33f8fbdSAdrien Destugues		- \c B_LIVE_QUERY The query is live. When a query is live, it is
5630551e706SIngo Weinhold		  constantly updated using the \a port. The FS must invoke the functions
5640551e706SIngo Weinhold		  notify_query_entry_created() and notify_query_entry_removed() whenever
5650551e706SIngo Weinhold		  an entry starts respectively stops to match the query predicate.
566a33f8fbdSAdrien Destugues		- \c B_QUERY_NON_INDEXED Normally at least one of the attributes used
5670551e706SIngo Weinhold		  in the query string should be indexed. If none is, this hook is
5680551e706SIngo Weinhold		  allowed to fail, unless this flag is specified. Usually an
5690551e706SIngo Weinhold		  implementation will simply add a wildcard match for any complete
5700551e706SIngo Weinhold		  index ("name", "last_modified", or "size") to the query expression.
5710551e706SIngo Weinhold	\param port The id of the port where updates need to be sent to in case the
5720551e706SIngo Weinhold		query is live.
5730551e706SIngo Weinhold	\param token A token that should be attached to the messages sent over the
5740551e706SIngo Weinhold		\a port.
5750551e706SIngo Weinhold	\param[out] _cookie The cookie that will be used as 'directory' to traverse
5760551e706SIngo Weinhold		through the results of the query.
5770551e706SIngo Weinhold	\return You should return \c B_OK if the creation succeeded, or return an
5780551e706SIngo Weinhold		error otherwise.
5790551e706SIngo Weinhold*/
5800551e706SIngo Weinhold
5810551e706SIngo Weinhold/*!
5820551e706SIngo Weinhold	\fn status_t (*fs_volume_ops::close_query)(fs_volume *volume, void *cookie)
5830551e706SIngo Weinhold	\brief Close a 'directory' of a query.
5840551e706SIngo Weinhold
5850551e706SIngo Weinhold	Note that you should free the cookie in the free_query_cookie() call.
5860551e706SIngo Weinhold
5870551e706SIngo Weinhold	\param volume The volume object.
5880551e706SIngo Weinhold	\param cookie The cookie that refers to this query.
5890551e706SIngo Weinhold	\return You should return \c B_OK if the creation succeeded, or return an
5900551e706SIngo Weinhold		error otherwise.
5910551e706SIngo Weinhold*/
5920551e706SIngo Weinhold
5930551e706SIngo Weinhold/*!
5940551e706SIngo Weinhold	\fn status_t (*fs_volume_ops::free_query_cookie)(fs_volume *volume,
5950551e706SIngo Weinhold			void *cookie)
5960551e706SIngo Weinhold	\brief Free a cookie of a query.
5970551e706SIngo Weinhold
5980551e706SIngo Weinhold	\param volume The volume object.
5990551e706SIngo Weinhold	\param cookie The cookie that should be freed.
6000551e706SIngo Weinhold	\return You should return \c B_OK if the creation succeeded, or return an
6010551e706SIngo Weinhold		error otherwise.
6020551e706SIngo Weinhold*/
6030551e706SIngo Weinhold
6040551e706SIngo Weinhold/*!
6050551e706SIngo Weinhold	\fn status_t (*fs_volume_ops::read_query)(fs_volume *volume, void *cookie,
6060551e706SIngo Weinhold			struct dirent *buffer, size_t bufferSize, uint32 *_num)
6070551e706SIngo Weinhold	\brief Read the next one or more entries matching the query.
6080551e706SIngo Weinhold
6090551e706SIngo Weinhold	This hook function works pretty much the same way as
6100551e706SIngo Weinhold	fs_vnode_ops::read_dir(), with the difference that it doesn't read the
6110551e706SIngo Weinhold	entries of a directory, but the entries matching the given query. Unlike the
6120551e706SIngo Weinhold	fs_vnode_ops::read_dir() hook, this hook also has to fill in the
6130551e706SIngo Weinhold	dirent::d_pino field.
6140551e706SIngo Weinhold
6150551e706SIngo Weinhold	\param volume The volume object.
6160551e706SIngo Weinhold	\param cookie The query cookie as returned by open_query().
6170551e706SIngo Weinhold	\param buffer Pointer to a pre-allocated buffer the directory entries shall
6180551e706SIngo Weinhold		be written to.
6190551e706SIngo Weinhold	\param bufferSize The size of \a buffer in bytes.
6200551e706SIngo Weinhold	\param _num Pointer to a pre-allocated variable, when invoked, containing
6210551e706SIngo Weinhold		the number of entries to be read, and into which the number of entries
6220551e706SIngo Weinhold		actually read shall be written.
6230551e706SIngo Weinhold	\return \c B_OK if everything went fine, another error code otherwise.
6240551e706SIngo Weinhold*/
6250551e706SIngo Weinhold
6260551e706SIngo Weinhold/*!
6270551e706SIngo Weinhold	\fn status_t (*fs_volume_ops::rewind_query)(fs_volume *volume, void *cookie)
6280551e706SIngo Weinhold	\brief Reset the query cookie to the first entry of the results.
6290551e706SIngo Weinhold
6300551e706SIngo Weinhold	\param volume The volume object.
6310551e706SIngo Weinhold	\param cookie The query cookie as returned by open_query().
6320551e706SIngo Weinhold	\return \c B_OK if everything went fine, another error code otherwise.
6330551e706SIngo Weinhold*/
6340551e706SIngo Weinhold
6350551e706SIngo Weinhold//! @}
6360551e706SIngo Weinhold
6370551e706SIngo Weinhold/*!
6380551e706SIngo Weinhold	\name FS Layer Operations
6390551e706SIngo Weinhold*/
6400551e706SIngo Weinhold
6410551e706SIngo Weinhold//! @{
6420551e706SIngo Weinhold
6430551e706SIngo Weinhold/*!
6440551e706SIngo Weinhold	\fn status_t (*fs_volume_ops::all_layers_mounted)(fs_volume *volume)
6450551e706SIngo Weinhold	\brief TODO: Document!
6460551e706SIngo Weinhold*/
6470551e706SIngo Weinhold
6480551e706SIngo Weinhold/*!
6490551e706SIngo Weinhold	\fn status_t (*fs_volume_ops::create_sub_vnode)(fs_volume *volume, ino_t id,
6500551e706SIngo Weinhold			fs_vnode *vnode)
6510551e706SIngo Weinhold	\brief TODO: Document!
6520551e706SIngo Weinhold*/
6530551e706SIngo Weinhold
6540551e706SIngo Weinhold/*!
6550551e706SIngo Weinhold	\fn status_t (*fs_volume_ops::delete_sub_vnode)(fs_volume *volume,
6560551e706SIngo Weinhold			fs_vnode *vnode)
6570551e706SIngo Weinhold	\brief TODO: Document!
6580551e706SIngo Weinhold*/
6590551e706SIngo Weinhold
6600551e706SIngo Weinhold//! @}
6610551e706SIngo Weinhold
6620551e706SIngo Weinhold
6630551e706SIngo Weinhold///// fs_vnode_ops /////
6640551e706SIngo Weinhold
6650551e706SIngo Weinhold
6660551e706SIngo Weinhold/*!
6670551e706SIngo Weinhold	\struct fs_vnode_ops
6680551e706SIngo Weinhold	\brief Operations vector for a node.
6690551e706SIngo Weinhold
6700551e706SIngo Weinhold	See the \ref fs_modules "introduction to file system modules" for an
6710551e706SIngo Weinhold	introduction to writing file systems.
6720551e706SIngo Weinhold*/
6730551e706SIngo Weinhold
6740551e706SIngo Weinhold/*!
6750551e706SIngo Weinhold	\name VNode Operations
6760551e706SIngo Weinhold*/
6770551e706SIngo Weinhold
6780551e706SIngo Weinhold//! @{
6790551e706SIngo Weinhold
6800551e706SIngo Weinhold/*!
6810551e706SIngo Weinhold	\fn status_t (*fs_vnode_ops::lookup)(fs_volume *volume, fs_vnode *dir,
6820551e706SIngo Weinhold			const char *name, ino_t *_id)
6830551e706SIngo Weinhold	\brief Looks up the node a directory entry refers to.
6840551e706SIngo Weinhold
6850551e706SIngo Weinhold	The VFS uses this hook to resolve path names to vnodes. It is used quite
6860551e706SIngo Weinhold	often and should be implemented efficiently.
6870551e706SIngo Weinhold
6880551e706SIngo Weinhold	If the parameter \a dir does not specify a directory, the function shall
6890551e706SIngo Weinhold	fail. It shall also fail, if it is a directory, but does not contain an
6900551e706SIngo Weinhold	entry with the given name \a name. Otherwise the function shall invoke
6910551e706SIngo Weinhold	get_vnode() for the node the entry refers to and pass back the ID of the
6920551e706SIngo Weinhold	node in \a _id.
6930551e706SIngo Weinhold
6940551e706SIngo Weinhold	Note that a directory must contain the special entries \c "." and \c "..",
6950551e706SIngo Weinhold	referring to the same directory and the parent directory respectively.
6960551e706SIngo Weinhold	lookup() must resolve the nodes accordingly. \c ".." for the root directory
6970551e706SIngo Weinhold	of the volume shall be resolved to the root directory itself.
6980551e706SIngo Weinhold
6990551e706SIngo Weinhold	\param volume The volume object.
7000551e706SIngo Weinhold	\param dir The node object for the directory.
7010551e706SIngo Weinhold	\param name The name of the directory entry.
7020551e706SIngo Weinhold	\param _id Pointer to a pre-allocated variable the ID of the found node
7030551e706SIngo Weinhold		shall be written to.
7040551e706SIngo Weinhold	\retval B_OK Everything went fine.
7050551e706SIngo Weinhold	\retval B_NOT_A_DIRECTORY The given node is not a directory.
7060551e706SIngo Weinhold	\retval B_ENTRY_NOT_FOUND The given directory does not contain an entry with
7070551e706SIngo Weinhold		the given name.
7080551e706SIngo Weinhold*/
7090551e706SIngo Weinhold
7100551e706SIngo Weinhold/*!
7110551e706SIngo Weinhold	\fn status_t (*fs_vnode_ops::get_vnode_name)(fs_volume *volume,
7120551e706SIngo Weinhold			fs_vnode *vnode, char *buffer, size_t bufferSize)
7130551e706SIngo Weinhold	\brief Return the file name of a directory vnode.
7140551e706SIngo Weinhold
7150551e706SIngo Weinhold	Normally file systems don't support hard links for directories, which means
7160551e706SIngo Weinhold	that a directory can be addressed by a unique path. This hook returns the
7170551e706SIngo Weinhold	name of the directory's entry in its parent directory.
7180551e706SIngo Weinhold
7190551e706SIngo Weinhold	Note that you don't have to implement this call if it can't be easily done;
7200551e706SIngo Weinhold	it's completely optional.
7210551e706SIngo Weinhold	If you don't implement it, you'll have to export a NULL pointer for this
7220551e706SIngo Weinhold	function in the module definition. In this case, the VFS will find the name
7230551e706SIngo Weinhold	by iterating over its parent directory.
7240551e706SIngo Weinhold
7250551e706SIngo Weinhold	If invoked for a non-directory node the hook is allowed to fail.
7260551e706SIngo Weinhold
7270551e706SIngo Weinhold	\param volume The volume object.
7280551e706SIngo Weinhold	\param vnode The node object.
7290551e706SIngo Weinhold	\param buffer The buffer that the name can be copied into.
7300551e706SIngo Weinhold	\param bufferSize The size of the buffer.
7310551e706SIngo Weinhold	\retval B_OK You successfully copied the file name into the \a buffer.
7320551e706SIngo Weinhold	\retval "other errors" There was some error looking up or copying the name.
7330551e706SIngo Weinhold*/
7340551e706SIngo Weinhold
7350551e706SIngo Weinhold/*!
7360551e706SIngo Weinhold	\fn \fn status_t (*fs_vnode_ops::put_vnode)(fs_volume *volume,
7370551e706SIngo Weinhold			fs_vnode *vnode, bool reenter)
7380551e706SIngo Weinhold	\brief Deletes the private data handle associated with the specified node.
7390551e706SIngo Weinhold
7400551e706SIngo Weinhold	Invoked by the VFS when it deletes the vnode for the respective node and the
7410551e706SIngo Weinhold	node is not marked removed.
7420551e706SIngo Weinhold
7430551e706SIngo Weinhold	\param volume The volume object.
7440551e706SIngo Weinhold	\param vnode The node object.
7450551e706SIngo Weinhold	\param reenter \c true if the hook invocation has been caused by the FS
7460551e706SIngo Weinhold		itself, e.g. by invoking ::put_vnode().
7470551e706SIngo Weinhold	\return \c B_OK if everything went fine, another error code otherwise.
7480551e706SIngo Weinhold*/
7490551e706SIngo Weinhold
7500551e706SIngo Weinhold/*!
7510551e706SIngo Weinhold	\fn status_t (*fs_vnode_ops::remove_vnode)(fs_volume *volume,
7520551e706SIngo Weinhold			fs_vnode *vnode, bool reenter)
7530551e706SIngo Weinhold	\brief Deletes the private data handle associated with the specified node.
7540551e706SIngo Weinhold
7550551e706SIngo Weinhold	Invoked by the VFS when it deletes the vnode for the respective node and the
7560551e706SIngo Weinhold	node has been marked removed by a call to remove_vnode().
7570551e706SIngo Weinhold
7580551e706SIngo Weinhold	\param volume The volume object.
7590551e706SIngo Weinhold	\param vnode The node object.
7600551e706SIngo Weinhold	\param reenter \c true if the hook invocation has been caused by the FS
7610551e706SIngo Weinhold		itself, e.g. by invoking ::put_vnode().
7620551e706SIngo Weinhold	\return \c B_OK if everything went fine, another error code otherwise.
7630551e706SIngo Weinhold*/
7640551e706SIngo Weinhold
7650551e706SIngo Weinhold//! @}
7660551e706SIngo Weinhold
7670551e706SIngo Weinhold/*!
7680551e706SIngo Weinhold	\name VM file access
7690551e706SIngo Weinhold*/
7700551e706SIngo Weinhold
7710551e706SIngo Weinhold//! @{
7720551e706SIngo Weinhold
7730551e706SIngo Weinhold/*!
7740551e706SIngo Weinhold	\fn bool (*fs_vnode_ops::can_page)(fs_volume *volume, fs_vnode *vnode,
7750551e706SIngo Weinhold		void *cookie)
7760551e706SIngo Weinhold	\brief Deprecated.
7770551e706SIngo Weinhold	\deprecated This is an obsolete hook that is never invoked.
7780551e706SIngo Weinhold*/
7790551e706SIngo Weinhold
7800551e706SIngo Weinhold/*!
7810551e706SIngo Weinhold	\fn status_t (*fs_vnode_ops::read_pages)(fs_volume *volume, fs_vnode *vnode,
7820551e706SIngo Weinhold			void *cookie, off_t pos, const iovec *vecs, size_t count,
7830551e706SIngo Weinhold			size_t *_numBytes)
7840551e706SIngo Weinhold	\brief Deprecated.
7850551e706SIngo Weinhold	\deprecated This is an obsolete hook that is never invoked.
7860551e706SIngo Weinhold*/
7870551e706SIngo Weinhold
7880551e706SIngo Weinhold/*!
7890551e706SIngo Weinhold	\fn status_t (*fs_vnode_ops::write_pages)(fs_volume *volume,
7900551e706SIngo Weinhold			fs_vnode *vnode, void *cookie, off_t pos, const iovec *vecs,
7910551e706SIngo Weinhold			size_t count, size_t *_numBytes)
7920551e706SIngo Weinhold	\brief Deprecated.
7930551e706SIngo Weinhold	\deprecated This is an obsolete hook that is never invoked.
7940551e706SIngo Weinhold*/
7950551e706SIngo Weinhold
7960551e706SIngo Weinhold//! @}
7970551e706SIngo Weinhold
7980551e706SIngo Weinhold/*!
7990551e706SIngo Weinhold	\name Asynchronous I/O
8000551e706SIngo Weinhold*/
8010551e706SIngo Weinhold
8020551e706SIngo Weinhold//! @{
8030551e706SIngo Weinhold
8040551e706SIngo Weinhold/*!
8050551e706SIngo Weinhold	\fn status_t (*fs_vnode_ops::io)(fs_volume *volume, fs_vnode *vnode,
8060551e706SIngo Weinhold			void *cookie, io_request *request)
8070551e706SIngo Weinhold	\brief TODO: Document!
8080551e706SIngo Weinhold*/
8090551e706SIngo Weinhold
8100551e706SIngo Weinhold/*!
8110551e706SIngo Weinhold	\fn status_t (*fs_vnode_ops::cancel_io)(fs_volume *volume, fs_vnode *vnode,
8120551e706SIngo Weinhold			void *cookie, io_request *request)
8130551e706SIngo Weinhold	\brief TODO: Document!
8140551e706SIngo Weinhold*/
8150551e706SIngo Weinhold
8160551e706SIngo Weinhold//! @}
8170551e706SIngo Weinhold
8180551e706SIngo Weinhold/*!
8190551e706SIngo Weinhold	\name Cache File Access
8200551e706SIngo Weinhold*/
8210551e706SIngo Weinhold
8220551e706SIngo Weinhold//! @{
8230551e706SIngo Weinhold
8240551e706SIngo Weinhold/*!
8250551e706SIngo Weinhold	\fn status_t (*fs_vnode_ops::get_file_map)(fs_volume *volume,
8260551e706SIngo Weinhold			fs_vnode *vnode, off_t offset, size_t size,
8270551e706SIngo Weinhold			struct file_io_vec *vecs, size_t *_count)
8280551e706SIngo Weinhold	\brief Fills the \a vecs with the extents of the file data stream.
8290551e706SIngo Weinhold
8300551e706SIngo Weinhold	This function is called only when you are using the file cache, but if you
8310551e706SIngo Weinhold	use it, its implementation is mandatory.
8320551e706SIngo Weinhold
8330551e706SIngo Weinhold	TODO: complete me
8340551e706SIngo Weinhold*/
8350551e706SIngo Weinhold
8360551e706SIngo Weinhold//! @}
8370551e706SIngo Weinhold
8380551e706SIngo Weinhold/*!
8390551e706SIngo Weinhold	\name Standard Operations
8400551e706SIngo Weinhold*/
8410551e706SIngo Weinhold
8420551e706SIngo Weinhold//! @{
8430551e706SIngo Weinhold
8440551e706SIngo Weinhold/*!
8450551e706SIngo Weinhold	\fn status_t (*fs_vnode_ops::ioctl)(fs_volume *volume, fs_vnode *vnode,
8460551e706SIngo Weinhold			void *cookie, ulong op, void *buffer, size_t length)
8470551e706SIngo Weinhold	\brief Perform file system specific operations.
8480551e706SIngo Weinhold
8490551e706SIngo Weinhold	You can implement a customized API using this call. This can be extremely
8500551e706SIngo Weinhold	handy for debugging purposes. There are no obligatory operations for you to
8510551e706SIngo Weinhold	implement.
8520551e706SIngo Weinhold
8530551e706SIngo Weinhold	If you don't want to use this feature, you don't have to implement it.
8540551e706SIngo Weinhold
8550551e706SIngo Weinhold	\param volume The volume object.
8560551e706SIngo Weinhold	\param vnode The node object.
8570551e706SIngo Weinhold	\param cookie The file system provided cookie associated with, for example,
8580551e706SIngo Weinhold		an open file (if applicable).
8590551e706SIngo Weinhold	\param op The operation code. You will have to define them yourself.
8600551e706SIngo Weinhold	\param buffer A buffer (if applicable).
8610551e706SIngo Weinhold	\param length The size of the buffer.
8620551e706SIngo Weinhold	\return You should return any of your status codes.
8630551e706SIngo Weinhold*/
8640551e706SIngo Weinhold
8650551e706SIngo Weinhold/*!
8660551e706SIngo Weinhold	\fn status_t (*fs_vnode_ops::set_flags)(fs_volume *volume, fs_vnode *vnode,
8670551e706SIngo Weinhold			void *cookie, int flags)
8680551e706SIngo Weinhold	\brief Set the open mode flags for an opened file.
8690551e706SIngo Weinhold
8700551e706SIngo Weinhold	This function should change the open flags for an opened file.
8710551e706SIngo Weinhold
8720551e706SIngo Weinhold	\param volume The volume object.
8730551e706SIngo Weinhold	\param vnode The node object.
8740551e706SIngo Weinhold	\param cookie The file system provided cookie associated with the opened
8750551e706SIngo Weinhold		file.
8760551e706SIngo Weinhold	\param flags The new flags.
8770551e706SIngo Weinhold	\return \c B_OK if the operation succeeded, or else an error code.
8780551e706SIngo Weinhold*/
8790551e706SIngo Weinhold
8800551e706SIngo Weinhold/*!
8810551e706SIngo Weinhold	\fn status_t (*fs_vnode_ops::select)(fs_volume *volume, fs_vnode *vnode,
8820551e706SIngo Weinhold			void *cookie, uint8 event, selectsync *sync)
8830551e706SIngo Weinhold	\brief Selects the specified \a vnode with the specified \a events.
8840551e706SIngo Weinhold
8850551e706SIngo Weinhold	This function is called by the VFS whenever select() or poll() is called on
8860551e706SIngo Weinhold	a file descriptor that points to your file system.
8870551e706SIngo Weinhold
8880551e706SIngo Weinhold	You have to check if the condition of the select() (ie. if there is data
8890551e706SIngo Weinhold	available if event is B_SELECT_READ) is already satisfied, and call
8900551e706SIngo Weinhold	notify_select_event() with the \a sync and \a ref arguments you retrieve
8910551e706SIngo Weinhold	here.
8920551e706SIngo Weinhold
8930551e706SIngo Weinhold	Additionally, when a vnode is selected this way, you have to call
8940551e706SIngo Weinhold	notify_select_event() whenever the condition becomes true until the
8950551e706SIngo Weinhold	vnode is deselected again via file_system_module_info::deselect().
8960551e706SIngo Weinhold
8970551e706SIngo Weinhold	This function is optional. If you don't export it, the default
8980551e706SIngo Weinhold	implementation in the VFS will call notify_select_event() directly which
8990551e706SIngo Weinhold	will be sufficient for most file systems.
9000551e706SIngo Weinhold
9010551e706SIngo Weinhold	Note that while select() and the corresponding deselect() are invoked by the
9020551e706SIngo Weinhold	same thread, notifications are usually generated by other threads. It is
9030551e706SIngo Weinhold	your responsibility to make sure that notify_select_event() is never called
9040551e706SIngo Weinhold	for a selectsync object for which deselect() has already returned. This is
9050551e706SIngo Weinhold	commonly done by holding the same lock when invoking notify_select_event()
9060551e706SIngo Weinhold	and when removing the selectsync object from the cookie in deselect().
9070551e706SIngo Weinhold	Such a lock can be any lock, usually one that is associated with the node or
9080551e706SIngo Weinhold	the volume.
9090551e706SIngo Weinhold
9100551e706SIngo Weinhold	\param volume The volume object.
9110551e706SIngo Weinhold	\param vnode The node object.
9120551e706SIngo Weinhold	\param cookie The file system provided cookie associated with the opened
9130551e706SIngo Weinhold		file.
9140551e706SIngo Weinhold	\param event The event to be selected. One of:
9150551e706SIngo Weinhold		- \c B_SELECT_READ: File ready for reading.
9160551e706SIngo Weinhold    	- \c B_SELECT_WRITE: File ready for writing.
9170551e706SIngo Weinhold    	- \c B_SELECT_ERROR: I/O error condition.
9180551e706SIngo Weinhold    	- \c B_SELECT_PRI_READ: File ready for priority read.
9190551e706SIngo Weinhold    	- \c B_SELECT_PRI_WRITE: File ready for priority write.
9200551e706SIngo Weinhold    	- \c B_SELECT_HIGH_PRI_READ: File ready for high priority read.
9210551e706SIngo Weinhold    	- \c B_SELECT_HIGH_PRI_WRITE: File ready for high priority write.
9220551e706SIngo Weinhold    	- \c B_SELECT_DISCONNECTED: Socket/FIFO/... has been disconnected.
9230551e706SIngo Weinhold	\param sync Opaque pointer to be passed to notify_select_event().
9240551e706SIngo Weinhold	\return \c B_OK if the operation succeeded, or else an error code.
9250551e706SIngo Weinhold*/
9260551e706SIngo Weinhold
9270551e706SIngo Weinhold/*!
9280551e706SIngo Weinhold	\fn status_t (*fs_vnode_ops::deselect)(fs_volume *volume, fs_vnode *vnode,
9290551e706SIngo Weinhold			void *cookie, uint8 event, selectsync *sync)
9300551e706SIngo Weinhold	\brief Deselects the specified \a vnode from a previous select() call.
9310551e706SIngo Weinhold
9320551e706SIngo Weinhold	This function is called by the VFS whenever a select() or poll() function
9330551e706SIngo Weinhold	exits that previously called file_system_module_info::select() on that
9340551e706SIngo Weinhold	\a vnode.
9350551e706SIngo Weinhold
9360551e706SIngo Weinhold	\param volume The volume object.
9370551e706SIngo Weinhold	\param vnode The node object.
9380551e706SIngo Weinhold	\param cookie The file system provided cookie associated with the opened
9390551e706SIngo Weinhold		file.
9400551e706SIngo Weinhold	\param event The event to be deselected.
9410551e706SIngo Weinhold	\param sync Opaque pointer to be passed to notify_select_event().
9420551e706SIngo Weinhold	\return \c B_OK if the operation succeeded, or else an error code.
9430551e706SIngo Weinhold*/
9440551e706SIngo Weinhold
9450551e706SIngo Weinhold/*!
9460551e706SIngo Weinhold	\fn status_t (*fs_vnode_ops::fsync)(fs_volume *volume, fs_vnode *vnode)
9470551e706SIngo Weinhold	\brief Synchronize the buffers with the on disk data.
9480551e706SIngo Weinhold
9490551e706SIngo Weinhold	\param volume The volume object.
9500551e706SIngo Weinhold	\param vnode The node object.
9510551e706SIngo Weinhold	\return \c B_OK if the operation succeeded, or else an error code.
9520551e706SIngo Weinhold*/
9530551e706SIngo Weinhold
9540551e706SIngo Weinhold/*!
9550551e706SIngo Weinhold	\fn status_t (*fs_vnode_ops::read_symlink)(fs_volume *volume,
9560551e706SIngo Weinhold			fs_vnode *link, char *buffer, size_t *_bufferSize)
9570551e706SIngo Weinhold	\brief Read the value of a symbolic link.
9580551e706SIngo Weinhold
9590551e706SIngo Weinhold	If the function is successful, the symlink string shall be written to the
9600551e706SIngo Weinhold	buffer. It does not need to be null-terminated. If the buffer is too small
9610551e706SIngo Weinhold	to hold the complete string, only the first \c *_bufferSize bytes of the
9620551e706SIngo Weinhold	string shall be written to the buffer; the buffer shall not be
9630551e706SIngo Weinhold	null-terminated in this case. Furthermore the variable \a _bufferSize
964e1b7c1c7SKyle Ambroff-Kao	shall be set to the length of the symlink contents, even if the entire
965e1b7c1c7SKyle Ambroff-Kao	contents did not fit in the provided \a buffer.
9660551e706SIngo Weinhold
9670551e706SIngo Weinhold	\param volume The volume object.
9680551e706SIngo Weinhold	\param link The node object.
9690551e706SIngo Weinhold	\param buffer Pointer to a pre-allocated buffer the link value shall be
9700551e706SIngo Weinhold		written to.
9710551e706SIngo Weinhold	\param _bufferSize Pointer to a pre-allocated variable containing the size
9720551e706SIngo Weinhold		of the buffer supplied to the function. Upon successful completion the
973e1b7c1c7SKyle Ambroff-Kao		hook shall store the length of the symlink contents.
9740551e706SIngo Weinhold	\retval B_OK Everything went fine.
9750551e706SIngo Weinhold	\retval B_BAD_VALUE \a link does not identify a symbolic link.
9760551e706SIngo Weinhold*/
9770551e706SIngo Weinhold
9780551e706SIngo Weinhold/*!
9790551e706SIngo Weinhold	\fn status_t (*fs_vnode_ops::create_symlink)(fs_volume *volume,
9800551e706SIngo Weinhold			fs_vnode *dir, const char *name, const char *path, int mode)
9810551e706SIngo Weinhold	\brief Create a new symbolic link.
9820551e706SIngo Weinhold
9830551e706SIngo Weinhold	\param volume The volume object.
9840551e706SIngo Weinhold	\param dir The node object for the directory the symbolic link should be
9850551e706SIngo Weinhold		created in.
9860551e706SIngo Weinhold	\param name The name of the new symbolic link.
9870551e706SIngo Weinhold	\param path The path the symbolic link should refer to.
9880551e706SIngo Weinhold	\param mode The permissions for the newly created symbolic link.
9890551e706SIngo Weinhold	\return \c B_OK if you succeeded, or an error code if you failed.
9900551e706SIngo Weinhold*/
9910551e706SIngo Weinhold
9920551e706SIngo Weinhold/*!
9930551e706SIngo Weinhold	\fn status_t (*fs_vnode_ops::link)(fs_volume *volume, fs_vnode *dir,
9940551e706SIngo Weinhold			const char *name, fs_vnode *vnode)
9950551e706SIngo Weinhold	\brief Create a new hard link.
9960551e706SIngo Weinhold
9970551e706SIngo Weinhold	The virtual file system will request the creation of symbolic links with
9980551e706SIngo Weinhold	create_symlink().
9990551e706SIngo Weinhold
10000551e706SIngo Weinhold	If you don't implement this function, the VFS will return \c EROFS
10010551e706SIngo Weinhold	when a hard link is requested. So, if you don't support hard links implement
10020551e706SIngo Weinhold	this hook and return an appropriate error code.
10030551e706SIngo Weinhold
10040551e706SIngo Weinhold	\param volume The volume object.
10050551e706SIngo Weinhold	\param dir The node object for the directory where the link should be
10060551e706SIngo Weinhold		created.
10070551e706SIngo Weinhold	\param name The name the link should have.
10080551e706SIngo Weinhold	\param vnode The vnode the new link should resolve to.
10090551e706SIngo Weinhold	\retval B_OK The hard link is properly created.
10100551e706SIngo Weinhold	\retval B_NOT_ALLOWED The user does not have the proper permissions.
10110551e706SIngo Weinhold	\retval "other errors" Another error occured.
10120551e706SIngo Weinhold*/
10130551e706SIngo Weinhold
10140551e706SIngo Weinhold/*!
10150551e706SIngo Weinhold	\fn status_t (*fs_vnode_ops::unlink)(fs_volume *volume, fs_vnode *dir,
10160551e706SIngo Weinhold			const char *name)
10170551e706SIngo Weinhold	\brief Remove a non-directory entry.
10180551e706SIngo Weinhold
10190551e706SIngo Weinhold	Remove an entry that does refer to a non-directory node. For removing
10200551e706SIngo Weinhold	directories the remove_dir() hook is used. If invoked on a directory, this
10210551e706SIngo Weinhold	hook shall fail.
10220551e706SIngo Weinhold
10230551e706SIngo Weinhold	\param volume The volume object.
10240551e706SIngo Weinhold	\param dir The node object for the directory containing the entry to be
10250551e706SIngo Weinhold		removed.
10260551e706SIngo Weinhold	\param name The name of the entry that should be removed.
10270551e706SIngo Weinhold	\retval B_OK Removal succeeded.
10280551e706SIngo Weinhold	\retval B_ENTRY_NOT_FOUND The entry does not exist.
10290551e706SIngo Weinhold	\retval B_NOT_ALLOWED The user does not have the proper permissions.
10300551e706SIngo Weinhold	\retval B_IS_A_DIRECTORY The entry refers to a directory.
10310551e706SIngo Weinhold	\retval "other errors" Another error occured.
10320551e706SIngo Weinhold*/
10330551e706SIngo Weinhold
10340551e706SIngo Weinhold/*!
10350551e706SIngo Weinhold	\fn status_t (*fs_vnode_ops::rename)(fs_volume *volume, fs_vnode *fromDir,
10360551e706SIngo Weinhold			const char *fromName, fs_vnode *toDir, const char *toName)
10370551e706SIngo Weinhold	\brief Rename and/or relocate an entry.
10380551e706SIngo Weinhold
10390551e706SIngo Weinhold	The virtual file system merely relays the request, so make sure the user is
10400551e706SIngo Weinhold	not changing the file name to something like '.', '..' or anything starting
10410551e706SIngo Weinhold	with '/'.
10420551e706SIngo Weinhold
10430551e706SIngo Weinhold	This also means that it if the entry refers to a directory, that it should
10440551e706SIngo Weinhold	not be moved into one of its own children.
10450551e706SIngo Weinhold
10460551e706SIngo Weinhold	\param volume The volume object.
10470551e706SIngo Weinhold	\param fromDir The node object for the parent directory the entry should be
10480551e706SIngo Weinhold		moved from.
10490551e706SIngo Weinhold	\param fromName The old entry name.
10500551e706SIngo Weinhold	\param toDir The node object for the parent directory the entry should be
10510551e706SIngo Weinhold		moved to.
10520551e706SIngo Weinhold	\param toName The new entry name.
10530551e706SIngo Weinhold	\retval B_OK The renaming and relocating succeeded.
10540551e706SIngo Weinhold	\retval B_BAD_VALUE One of the supplied parameters were invalid.
10550551e706SIngo Weinhold	\retval B_NOT_ALLOWED The user does not have the proper permissions.
10560551e706SIngo Weinhold	\retval "other errors" Another error condition was encountered.
10570551e706SIngo Weinhold*/
10580551e706SIngo Weinhold
10590551e706SIngo Weinhold/*!
10600551e706SIngo Weinhold	\fn status_t (*fs_vnode_ops::access)(fs_volume *volume, fs_vnode *vnode,
10610551e706SIngo Weinhold			int mode)
10620551e706SIngo Weinhold	\brief Checks whether the current user is allowed to access the node in the
10630551e706SIngo Weinhold		specified way.
10640551e706SIngo Weinhold
10650551e706SIngo Weinhold	\a mode is a bitwise combination of:
10660551e706SIngo Weinhold	- \c R_OK: Read access.
10670551e706SIngo Weinhold	- \c W_OK: Write access.
10680551e706SIngo Weinhold	- \c X_OK: Execution.
10690551e706SIngo Weinhold
10700551e706SIngo Weinhold	If the current user does not have any of the access permissions represented
10710551e706SIngo Weinhold	by the set bits, the function shall return \c B_NOT_ALLOWED. As a special
10720551e706SIngo Weinhold	case, if the volume is read-only and write access is requested,
10730551e706SIngo Weinhold	\c B_READ_ONLY_DEVICE shall be returned. If the requested access mode
10740551e706SIngo Weinhold	complies with the user's access permissions, the function shall return
10750551e706SIngo Weinhold	\c B_OK.
10760551e706SIngo Weinhold
10770551e706SIngo Weinhold	For most FSs the permissions a user has are defined by the \c st_mode,
10780551e706SIngo Weinhold	\c st_uid, and \c st_gid fields of the node's stat data. As a special
10790551e706SIngo Weinhold	exception, the root user (<tt>geteuid() == 0</tt>) does always have
10800551e706SIngo Weinhold	read and write permissions, execution permission only when at least one of
10810551e706SIngo Weinhold	the execution permission bits are set.
10820551e706SIngo Weinhold
10830551e706SIngo Weinhold	\param volume The volume object.
10840551e706SIngo Weinhold	\param vnode The node object.
10850551e706SIngo Weinhold	\param mode The access mode mask.
10860551e706SIngo Weinhold	\retval B_OK The user has the permissions to access the node in the
10870551e706SIngo Weinhold		requested way.
10880551e706SIngo Weinhold	\retval B_READ_ONLY_DEVICE The volume is read-only, but the write access has
10890551e706SIngo Weinhold		been requested.
10900551e706SIngo Weinhold	\retval B_NOT_ALLOWED The user does not have all permissions to access the
10910551e706SIngo Weinhold		node in the requested way.
10920551e706SIngo Weinhold*/
10930551e706SIngo Weinhold
10940551e706SIngo Weinhold/*!
10950551e706SIngo Weinhold	\fn status_t (*fs_vnode_ops::read_stat)(fs_volume *volume, fs_vnode *vnode,
10960551e706SIngo Weinhold			struct stat *stat)
10970551e706SIngo Weinhold	\brief Retrieves the stat data for a given node.
10980551e706SIngo Weinhold
10990551e706SIngo Weinhold	All values of the <tt>struct stat</tt> save \c st_dev, \c st_ino,
11000551e706SIngo Weinhold	\c st_rdev, and \c st_type need to be filled in.
11010551e706SIngo Weinhold
11020551e706SIngo Weinhold	\param volume The volume object.
11030551e706SIngo Weinhold	\param vnode The node object.
11040551e706SIngo Weinhold	\param stat Pointer to a pre-allocated variable the stat data shall be
11050551e706SIngo Weinhold		written to.
11060551e706SIngo Weinhold	\return \c B_OK if everything went fine, another error code otherwise.
11070551e706SIngo Weinhold*/
11080551e706SIngo Weinhold
11090551e706SIngo Weinhold/*!
11100551e706SIngo Weinhold	\fn status_t (*fs_vnode_ops::write_stat)(fs_volume *volume, fs_vnode *vnode,
11110551e706SIngo Weinhold			const struct stat *stat, uint32 statMask)
11120551e706SIngo Weinhold	\brief Update the stats for a vnode.
11130551e706SIngo Weinhold
11140551e706SIngo Weinhold	You should make sure that the new values are valid.
11150551e706SIngo Weinhold
11160551e706SIngo Weinhold	\param volume The volume object.
11170551e706SIngo Weinhold	\param vnode The node object.
11180551e706SIngo Weinhold	\param stat The structure with the updated values.
11190551e706SIngo Weinhold	\param statMask A bitwise combination of one or more of the following,
11200551e706SIngo Weinhold		specifying which stat field shall be set:
11210551e706SIngo Weinhold		- B_STAT_MODE: Set the node permissions.
11220551e706SIngo Weinhold		- B_STAT_UID: Set the owning user.
11230551e706SIngo Weinhold		- B_STAT_GID: Set the owner group.
11240551e706SIngo Weinhold		- B_STAT_SIZE: Set the size of the file. If enlarged, the file is
11250551e706SIngo Weinhold			padded. Normally with zero bytes, but with unspecified data, if
11260551e706SIngo Weinhold			B_STAT_SIZE_INSECURE is specified, too.
11270551e706SIngo Weinhold		- B_STAT_SIZE_INSECURE: Modifier for B_STAT_SIZE: When enlarging the
11280551e706SIngo Weinhold			file padding can be done with arbitrary data.
11290551e706SIngo Weinhold		- B_STAT_ACCESS_TIME: Set the access time.
11300551e706SIngo Weinhold		- B_STAT_MODIFICATION_TIME: Set the modification time.
11310551e706SIngo Weinhold		- B_STAT_CREATION_TIME: Set the creation time.
11320551e706SIngo Weinhold		- B_STAT_CHANGE_TIME: Set the change time.
11330551e706SIngo Weinhold	\retval B_OK The update succeeded.
11340551e706SIngo Weinhold	\retval B_NOT_ALLOWED The user does not have the proper permissions.
11350551e706SIngo Weinhold	\retval "other errors" Another error condition occured.
11360551e706SIngo Weinhold*/
11370551e706SIngo Weinhold
11380551e706SIngo Weinhold//! @}
11390551e706SIngo Weinhold
11400551e706SIngo Weinhold/*!
11410551e706SIngo Weinhold \name File Operations
11420551e706SIngo Weinhold*/
11430551e706SIngo Weinhold
11440551e706SIngo Weinhold//! @{
11450551e706SIngo Weinhold
11460551e706SIngo Weinhold/*!
11470551e706SIngo Weinhold	\fn status_t (*fs_vnode_ops::create)(fs_volume *volume, fs_vnode *dir,
11480551e706SIngo Weinhold			const char *name, int openMode, int perms, void **_cookie,
11490551e706SIngo Weinhold			ino_t *_newVnodeID)
11501a38616fSIngo Weinhold	\brief Creates and opens a new file.
11510551e706SIngo Weinhold
11521a38616fSIngo Weinhold	The hook is similar to \link fs_vnode_ops::open() open() \endlink, with the
11531a38616fSIngo Weinhold	difference that, if an entry with the name \a name does not already exist
11541a38616fSIngo Weinhold	in the given directory, a new file with that name is created first.
11551a38616fSIngo Weinhold	If the entry does already exist and \a openMode specifies the \c O_EXCL
11561a38616fSIngo Weinhold	flag, the function shall fail with \c B_FILE_EXISTS (aka \c EEXIST).
11570551e706SIngo Weinhold
11580551e706SIngo Weinhold	\param volume The volume object.
11590551e706SIngo Weinhold	\param dir The node object for the directory where the file should appear.
11600551e706SIngo Weinhold	\param name The name of the new file.
11610551e706SIngo Weinhold	\param openMode The mode associated to the file.
11620551e706SIngo Weinhold	\param perms The permissions the new file should have.
11630551e706SIngo Weinhold	\param[out] _cookie In case of success, the storage where you can put your
11640551e706SIngo Weinhold		FS specific cookie for the open node.
11650551e706SIngo Weinhold	\param[out] _newVnodeID In case of success, you can store the new vnode id
11660551e706SIngo Weinhold		in this variable.
11671a38616fSIngo Weinhold	\return If opening the node succeeded (after creating it first, if
11681a38616fSIngo Weinhold		necessary), \c B_OK shall be returned and \a _cookie and \a _newVnodeID
11691a38616fSIngo Weinhold		shall be set. Otherwise an error code shall be returned.
11700551e706SIngo Weinhold*/
11710551e706SIngo Weinhold
11720551e706SIngo Weinhold/*!
11730551e706SIngo Weinhold	\fn status_t (*fs_vnode_ops::open)(fs_volume *volume, fs_vnode *vnode,
11740551e706SIngo Weinhold			int openMode, void **_cookie)
11750551e706SIngo Weinhold	\brief Opens the given node.
11760551e706SIngo Weinhold
11770551e706SIngo Weinhold	The hook is invoked whenever a file is opened (e.g. via the open() POSIX
11780551e706SIngo Weinhold	function).
11790551e706SIngo Weinhold
11800551e706SIngo Weinhold	The hook can create a node cookie, and store it in the variable
11810551e706SIngo Weinhold	\a _cookie points to. The cookie will be passed to all hooks that operate
11820551e706SIngo Weinhold	on open files.
11830551e706SIngo Weinhold
11840551e706SIngo Weinhold	The open mode \a openMode is encoded in the same way as the parameter of the
11850551e706SIngo Weinhold	POSIX function \c open(), i.e. it is either \c O_RDONLY, \c O_WRONLY, or
11860551e706SIngo Weinhold	\c O_RDWR, bitwise or'ed with flags. The only relevant flags for this hook
11870551e706SIngo Weinhold	are \c O_TRUNC and \c O_NONBLOCK. You will normally want to store the open
11880551e706SIngo Weinhold	mode in the file cookie, since you'll have to check in read() and write()
11890551e706SIngo Weinhold	whether the the respective operation is allowed by the open mode.
11900551e706SIngo Weinhold
11910551e706SIngo Weinhold	\param volume The volume object.
11920551e706SIngo Weinhold	\param vnode The node object.
11930551e706SIngo Weinhold	\param openMode The open mode.
11940551e706SIngo Weinhold	\param _cookie Pointer to a pre-allocated variable the node cookie shall be
11950551e706SIngo Weinhold		written to.
11960551e706SIngo Weinhold	\return \c B_OK if everything went fine, another error code otherwise.
11970551e706SIngo Weinhold*/
11980551e706SIngo Weinhold
11990551e706SIngo Weinhold/*!
12000551e706SIngo Weinhold	\fn status_t (*fs_vnode_ops::close)(fs_volume *volume, fs_vnode *vnode,
12010551e706SIngo Weinhold		void *cookie)
12020551e706SIngo Weinhold	\brief Closes the given node cookie.
12030551e706SIngo Weinhold
12040551e706SIngo Weinhold	The hook is invoked, when closing the node has been requested. At this point
12050551e706SIngo Weinhold	other threads might still use the cookie, i.e. still execute hooks to which
12060551e706SIngo Weinhold	the cookie has been passed. If the FS supports blocking I/O operations, this
12070551e706SIngo Weinhold	hook should make sure to unblock all currently blocking threads performing
12080551e706SIngo Weinhold	an operation using the cookie, and mark the cookie such that no further
12090551e706SIngo Weinhold	threads will block using it.
12100551e706SIngo Weinhold
12110551e706SIngo Weinhold	For many FSs this hook is a no-op -- it's mandatory to be exported, though.
12120551e706SIngo Weinhold
12130551e706SIngo Weinhold	\param volume The volume object.
12140551e706SIngo Weinhold	\param vnode The node object.
12150551e706SIngo Weinhold	\param cookie The node cookie as returned by open().
12160551e706SIngo Weinhold	\return \c B_OK if everything went fine, another error code otherwise.
12170551e706SIngo Weinhold*/
12180551e706SIngo Weinhold
12190551e706SIngo Weinhold/*!
12200551e706SIngo Weinhold	\fn status_t (*fs_vnode_ops::free_cookie)(fs_volume *volume,
12210551e706SIngo Weinhold		fs_vnode *vnode, void *cookie)
12220551e706SIngo Weinhold	\brief Frees the given node cookie.
12230551e706SIngo Weinhold
12240551e706SIngo Weinhold	The hook is invoked after close(), when no other thread uses or is going to
12250551e706SIngo Weinhold	use the cookie. All resources associated with the cookie must be freed.
12260551e706SIngo Weinhold
12270551e706SIngo Weinhold	\param volume The volume object.
12280551e706SIngo Weinhold	\param vnode The node object.
12290551e706SIngo Weinhold	\param cookie The node cookie as returned by open().
12300551e706SIngo Weinhold	\return \c B_OK if everything went fine, another error code otherwise.
12310551e706SIngo Weinhold*/
12320551e706SIngo Weinhold
12330551e706SIngo Weinhold/*!
12340551e706SIngo Weinhold	\fn status_t (*fs_vnode_ops::read)(fs_volume *volume, fs_vnode *vnode,
12350551e706SIngo Weinhold			void *cookie, off_t pos, void *buffer, size_t *length)
12360551e706SIngo Weinhold	\brief Reads data from a file.
12370551e706SIngo Weinhold
12380551e706SIngo Weinhold	This function should fail if
12390551e706SIngo Weinhold	- the node is not a file,
12400551e706SIngo Weinhold	- the cookie has not been opened for reading,
12410551e706SIngo Weinhold	- \a pos is negative, or
12420551e706SIngo Weinhold	- some other error occurs while trying to read the data, and no data have
12430551e706SIngo Weinhold		been read at all.
12440551e706SIngo Weinhold
12450551e706SIngo Weinhold	The number of bytes to be read is stored in the variable pointed to by
12460551e706SIngo Weinhold	\a length. If less data is available at file position \a pos, or if \a pos
12470551e706SIngo Weinhold	if greater than the size of the file, only as many data as available shall
12480551e706SIngo Weinhold	be read, the function shall store the number of bytes actually read into the
12490551e706SIngo Weinhold	variable pointed to by \a length, and return \c B_OK.
12500551e706SIngo Weinhold
12510551e706SIngo Weinhold	\param volume The volume object.
12520551e706SIngo Weinhold	\param vnode The node object.
12530551e706SIngo Weinhold	\param cookie The node cookie as returned by open().
12540551e706SIngo Weinhold	\param pos The file position where to start reading data.
12550551e706SIngo Weinhold	\param buffer Pointer to a pre-allocated buffer the read data shall be
12560551e706SIngo Weinhold		written to.
12570551e706SIngo Weinhold	\param length Pointer to a pre-allocated variable containing the size of the
12580551e706SIngo Weinhold		buffer when invoked, and into which the size of the data actually read
12590551e706SIngo Weinhold		shall be written.
12600551e706SIngo Weinhold	\return \c B_OK if everything went fine, another error code otherwise.
12610551e706SIngo Weinhold*/
12620551e706SIngo Weinhold
12630551e706SIngo Weinhold/*!
12640551e706SIngo Weinhold	\fn status_t (*fs_vnode_ops::write)(fs_volume *volume, fs_vnode *vnode,
12650551e706SIngo Weinhold			void *cookie, off_t pos, const void *buffer, size_t *length)
12660551e706SIngo Weinhold	\brief Write data to a file.
12670551e706SIngo Weinhold
12680551e706SIngo Weinhold	This function should fail if
12690551e706SIngo Weinhold	- the node is not a file,
12700551e706SIngo Weinhold	- the cookie has not been opened for writing,
12710551e706SIngo Weinhold	- \a pos is negative, or
12720551e706SIngo Weinhold	- some other error occurs while trying to write the data, and no data have
12730551e706SIngo Weinhold		been written at all.
12740551e706SIngo Weinhold
12750551e706SIngo Weinhold	The number of bytes to be written is stored in the variable pointed to by
12760551e706SIngo Weinhold	\a length. If not all bytes could be written, that variable must be updated
12770551e706SIngo Weinhold	to reflect the amount of actually written bytes. If any bytes have been
12780551e706SIngo Weinhold	written, the function shall not fail, if an error prevents you from
12790551e706SIngo Weinhold	writing the full amount. Only when the error prevented you from writing
12800551e706SIngo Weinhold	any data at all an error shall be returned.
12810551e706SIngo Weinhold
12820551e706SIngo Weinhold	\param volume The volume object.
12830551e706SIngo Weinhold	\param vnode The node object.
12840551e706SIngo Weinhold	\param cookie The file system provided cookie associated with the file.
12850551e706SIngo Weinhold	\param pos The position to start writing.
12860551e706SIngo Weinhold	\param buffer The buffer that contains the data that will need to be
12870551e706SIngo Weinhold		written.
12880551e706SIngo Weinhold	\param length The length of the data that needs to be written.
12890551e706SIngo Weinhold	\return \c B_OK if everything went fine, another error code otherwise.
12900551e706SIngo Weinhold*/
12910551e706SIngo Weinhold
12920551e706SIngo Weinhold//! @}
12930551e706SIngo Weinhold
12940551e706SIngo Weinhold/*!
12950551e706SIngo Weinhold	\name Directory Operations
12960551e706SIngo Weinhold*/
12970551e706SIngo Weinhold
1298ff1ee776SNiels Sascha Reedijk//! @{
1299ff1ee776SNiels Sascha Reedijk
13000551e706SIngo Weinhold/*!
13010551e706SIngo Weinhold	\fn status_t (*fs_vnode_ops::create_dir)(fs_volume *volume,
13020551e706SIngo Weinhold			fs_vnode *parent, const char *name, int perms)
13030551e706SIngo Weinhold	\brief Create a new directory.
13040551e706SIngo Weinhold
13050551e706SIngo Weinhold	\param volume The volume object.
13060551e706SIngo Weinhold	\param parent The node object for the directory in which to create the new
13070551e706SIngo Weinhold		directory.
13080551e706SIngo Weinhold	\param name The name the new directory should have.
13090551e706SIngo Weinhold	\param perms The permissions the new directory should have.
13100551e706SIngo Weinhold	\return \c B_OK if the directory was created successfully, an error code
13110551e706SIngo Weinhold		otherwise.
13120551e706SIngo Weinhold*/
13130551e706SIngo Weinhold
13140551e706SIngo Weinhold/*!
13150551e706SIngo Weinhold	\fn status_t (*fs_vnode_ops::remove_dir)(fs_volume *volume,
13160551e706SIngo Weinhold			fs_vnode *parent, const char *name)
13170551e706SIngo Weinhold	\brief Remove a directory.
13180551e706SIngo Weinhold
13190551e706SIngo Weinhold	The function shall fail, if the entry does not refer to a directory, or if
13200551e706SIngo Weinhold	it refers to a directory that is not empty.
13210551e706SIngo Weinhold
13220551e706SIngo Weinhold	\param volume The volume object.
13230551e706SIngo Weinhold	\param parent The node object for the parent directory containing the
13240551e706SIngo Weinhold		directory to be removed.
13250551e706SIngo Weinhold	\param name The \a name of the directory that needs to be removed.
13260551e706SIngo Weinhold	\retval B_OK Operation succeeded.
13270551e706SIngo Weinhold	\retval B_ENTRY_NOT_FOUND There is no entry with this \a name.
13280551e706SIngo Weinhold	\retval B_NOT_A_DIRECTORY The entry is not a directory.
13290551e706SIngo Weinhold	\retval B_DIRECTORY_NOT_EMPTY The directory is not empty. The virtual
13300551e706SIngo Weinhold		file system expects directories to be emptied before they can be
13310551e706SIngo Weinhold		removed.
13320551e706SIngo Weinhold	\retval "other errors" Other errors occured.
13330551e706SIngo Weinhold*/
13340551e706SIngo Weinhold
13350551e706SIngo Weinhold/*!
13360551e706SIngo Weinhold	\fn status_t (*fs_vnode_ops::open_dir)(fs_volume *volume, fs_vnode *vnode,
13370551e706SIngo Weinhold				void **_cookie)
13380551e706SIngo Weinhold	\brief Opens the given directory node.
13390551e706SIngo Weinhold
13400551e706SIngo Weinhold	If the specified node is not a directory, the function shall fail.
13410551e706SIngo Weinhold	Otherwise it shall allocate a directory cookie and store it in the variable
13420551e706SIngo Weinhold	\a _cookie points to. A subsequent read_dir() using the cookie shall start
13430551e706SIngo Weinhold	reading the first entry of the directory.
13440551e706SIngo Weinhold
13450551e706SIngo Weinhold	\param volume The volume object.
13460551e706SIngo Weinhold	\param vnode The node object.
13470551e706SIngo Weinhold	\param _cookie Pointer to a pre-allocated variable the directory cookie
13480551e706SIngo Weinhold		shall be written to.
13490551e706SIngo Weinhold	\return \c B_OK if everything went fine, another error code otherwise.
13500551e706SIngo Weinhold*/
13510551e706SIngo Weinhold
13520551e706SIngo Weinhold/*!
13530551e706SIngo Weinhold	\fn status_t (*fs_vnode_ops::close_dir)(fs_volume *volume, fs_vnode *vnode,
13540551e706SIngo Weinhold			void *cookie)
13550551e706SIngo Weinhold	\brief Closes the given directory cookie.
13560551e706SIngo Weinhold
13570551e706SIngo Weinhold	Generally the situation is similar to the one described for close(). In
13580551e706SIngo Weinhold	practice it is a bit different, though, since directory cookies are
13590551e706SIngo Weinhold	exclusively used for directory iteration, and it normally doesn't make sense
13600551e706SIngo Weinhold	to have multiple threads read the same directory concurrently. Furthermore
13610551e706SIngo Weinhold	usually reading a directory will not block. Therefore for most FSs this hook
13620551e706SIngo Weinhold	is a no-op.
13630551e706SIngo Weinhold
13640551e706SIngo Weinhold	\param volume The volume object.
13650551e706SIngo Weinhold	\param vnode The node object.
13660551e706SIngo Weinhold	\param cookie The directory cookie as returned by open_dir().
13670551e706SIngo Weinhold	\return \c B_OK if everything went fine, another error code otherwise.
13680551e706SIngo Weinhold*/
13690551e706SIngo Weinhold
13700551e706SIngo Weinhold/*!
13710551e706SIngo Weinhold	\fn status_t (*fs_vnode_ops::free_dir_cookie)(fs_volume *volume,
13720551e706SIngo Weinhold			fs_vnode *vnode, void *cookie)
13730551e706SIngo Weinhold	\brief Frees the given directory cookie.
13740551e706SIngo Weinhold
13750551e706SIngo Weinhold	The hook is invoked after close_dir(), when no other thread uses or is going
13760551e706SIngo Weinhold	to use the cookie. All resources associated with the cookie must be freed.
13770551e706SIngo Weinhold
13780551e706SIngo Weinhold	\param volume The volume object.
13790551e706SIngo Weinhold	\param vnode The node object.
13800551e706SIngo Weinhold	\param cookie The directory cookie as returned by open_dir().
13810551e706SIngo Weinhold	\return \c B_OK if everything went fine, another error code otherwise.
13820551e706SIngo Weinhold*/
13830551e706SIngo Weinhold
13840551e706SIngo Weinhold/*!
13850551e706SIngo Weinhold	\fn status_t (*fs_vnode_ops::read_dir)(fs_volume *volume, fs_vnode *vnode,
13860551e706SIngo Weinhold			void *cookie, struct dirent *buffer, size_t bufferSize,
13870551e706SIngo Weinhold			uint32 *_num)
13880551e706SIngo Weinhold	\brief Reads the next one or more directory entries.
13890551e706SIngo Weinhold
13900551e706SIngo Weinhold	The number of entries to be read at maximum is stored in the variable
13910551e706SIngo Weinhold	\a _num points to.
13920551e706SIngo Weinhold
13930551e706SIngo Weinhold	Per read \c dirent the following fields have to be filled in:
13940551e706SIngo Weinhold	- \c d_dev: The volume ID.
13950551e706SIngo Weinhold	- \c d_ino: The ID of the node the entry refers to.
13960551e706SIngo Weinhold	- \c d_name: The null-terminated name of the entry.
13970551e706SIngo Weinhold	- \c d_reclen: The size of the \c dirent structure in bytes, starting from
13980551e706SIngo Weinhold	  the beginning of the structure, counting all bytes up to and including
13990551e706SIngo Weinhold	  the null-termination char of the name stored in \c d_name.
14000551e706SIngo Weinhold
14010551e706SIngo Weinhold	If more than one entry is read, the corresponding \c dirent structures are
14020551e706SIngo Weinhold	tightly packed, i.e. the second entry can begin directly after the end of
14030551e706SIngo Weinhold	the first one (i.e. \c d_reclen bytes after the beginning of the first one).
14040551e706SIngo Weinhold	The file system should make sure that the dirents are 8-byte aligned, i.e.
14050551e706SIngo Weinhold	when another entry follows, \c d_reclen of the previous one should be
14060551e706SIngo Weinhold	aligned. A FS doesn't have to read more than one entry at a time, but it is
14070551e706SIngo Weinhold	recommended to support that for performance reasons.
14080551e706SIngo Weinhold
1409*bb6b48a9SCruxBox	If the provided buffer is too small to contain even the single next
14100551e706SIngo Weinhold	entry, \c B_BUFFER_OVERFLOW shall be returned. It shall not fail, if at
14110551e706SIngo Weinhold	least one entry has been read, and the buffer is just too small to hold as
1412*bb6b48a9SCruxBox	many entries as requested. When the function is invoked after the end of
1413*bb6b48a9SCruxBox	the directory has been reached, it shall set the variable \a _num points to
1414*bb6b48a9SCruxBox	\c 0 and return \c B_OK. Usually the function is invoked repeatedly until
1415*bb6b48a9SCruxBox	then to get more entries. The \c cookie parameter must be used to track the
1416*bb6b48a9SCruxBox	position in the directory.
14170551e706SIngo Weinhold
14180551e706SIngo Weinhold	Note that a directory is expected to contain the special entries \c "." and
14190551e706SIngo Weinhold	\c "..", referring to the same directory and the parent directory
14200551e706SIngo Weinhold	respectively. The \c dirent structure returned for the \c ".." entry of the
14210551e706SIngo Weinhold	volume's root directory shall refer to the root node itself.
14220551e706SIngo Weinhold
14230551e706SIngo Weinhold	\param volume The volume object.
14240551e706SIngo Weinhold	\param vnode The node object.
14250551e706SIngo Weinhold	\param cookie The directory cookie as returned by open_dir().
14260551e706SIngo Weinhold	\param buffer Pointer to a pre-allocated buffer the directory entries shall
14270551e706SIngo Weinhold		be written to.
14280551e706SIngo Weinhold	\param bufferSize The size of \a buffer in bytes.
14290551e706SIngo Weinhold	\param _num Pointer to a pre-allocated variable, when invoked, containing
14300551e706SIngo Weinhold		the number of directory entries to be read, and into which the number of
14310551e706SIngo Weinhold		entries actually read shall be written.
14320551e706SIngo Weinhold	\return \c B_OK if everything went fine, another error code otherwise.
14330551e706SIngo Weinhold*/
14340551e706SIngo Weinhold
14350551e706SIngo Weinhold/*!
14360551e706SIngo Weinhold	\fn status_t (*fs_vnode_ops::rewind_dir)(fs_volume *volume, fs_vnode *vnode,
14370551e706SIngo Weinhold			void *cookie)
14380551e706SIngo Weinhold	\brief Resets the directory cookie to the first entry of the directory.
14390551e706SIngo Weinhold	\param volume The volume object.
14400551e706SIngo Weinhold	\param vnode The node object.
14410551e706SIngo Weinhold	\param cookie The directory cookie as returned by open_dir().
14420551e706SIngo Weinhold	\return \c B_OK if everything went fine, another error code otherwise.
14430551e706SIngo Weinhold*/
14440551e706SIngo Weinhold
14450551e706SIngo Weinhold//! @}
14460551e706SIngo Weinhold
14470551e706SIngo Weinhold/*!
14480551e706SIngo Weinhold	\name Attribute Directory Operations
14490551e706SIngo Weinhold*/
14500551e706SIngo Weinhold
14510551e706SIngo Weinhold//! @{
14520551e706SIngo Weinhold
14530551e706SIngo Weinhold/*!
14540551e706SIngo Weinhold	\fn status_t (*fs_vnode_ops::open_attr_dir)(fs_volume *volume,
14550551e706SIngo Weinhold			fs_vnode *vnode, void **_cookie)
14560551e706SIngo Weinhold	\brief Open a 'directory' of attributes for a \a vnode.
14570551e706SIngo Weinhold
14580551e706SIngo Weinhold	See \ref concepts "Generic Concepts" on directories and iterators.
14590551e706SIngo Weinhold	Basically, the VFS uses the same way of traversing through attributes as it
14600551e706SIngo Weinhold	traverses through a directory.
14610551e706SIngo Weinhold
14620551e706SIngo Weinhold	\param volume The volume object.
14630551e706SIngo Weinhold	\param vnode The node object.
14640551e706SIngo Weinhold	\param[out] _cookie Pointer where the file system can store a directory
14650551e706SIngo Weinhold		cookie if the attribute directory is succesfully opened.
14660551e706SIngo Weinhold	\return \c B_OK if everything went fine, another error code otherwise.
14670551e706SIngo Weinhold*/
14680551e706SIngo Weinhold
14690551e706SIngo Weinhold/*!
14700551e706SIngo Weinhold	\fn status_t (*fs_vnode_ops::close_attr_dir)(fs_volume *volume,
14710551e706SIngo Weinhold			fs_vnode *vnode, void *cookie)
14720551e706SIngo Weinhold	\brief Close a 'directory' of attributes for a \a vnode.
14730551e706SIngo Weinhold
14740551e706SIngo Weinhold	Note that you should free the cookie in the free_attr_dir_cookie() call.
14750551e706SIngo Weinhold
14760551e706SIngo Weinhold	\param volume The volume object.
14770551e706SIngo Weinhold	\param vnode The node object.
14780551e706SIngo Weinhold	\param cookie The cookie associated with this 'directory'.
14790551e706SIngo Weinhold	\return \c B_OK if everything went fine, another error code otherwise.
14800551e706SIngo Weinhold*/
14810551e706SIngo Weinhold
14820551e706SIngo Weinhold/*!
14830551e706SIngo Weinhold	\fn status_t (*fs_vnode_ops::free_attr_dir_cookie)(fs_volume *volume,
14840551e706SIngo Weinhold			fs_vnode *vnode, void *cookie)
14850551e706SIngo Weinhold	\brief Free the \a cookie to an attribute 'directory'.
14860551e706SIngo Weinhold
14870551e706SIngo Weinhold	\param volume The volume object.
14880551e706SIngo Weinhold	\param vnode The node object.
14890551e706SIngo Weinhold	\param cookie The cookie associated that should be freed.
14900551e706SIngo Weinhold	\return \c B_OK if everything went fine, another error code otherwise.
14910551e706SIngo Weinhold*/
14920551e706SIngo Weinhold
14930551e706SIngo Weinhold/*!
14940551e706SIngo Weinhold	\fn status_t (*fs_vnode_ops::read_attr_dir)(fs_volume *volume,
14950551e706SIngo Weinhold			fs_vnode *vnode, void *cookie, struct dirent *buffer,
14960551e706SIngo Weinhold			size_t bufferSize, uint32 *_num)
14970551e706SIngo Weinhold	\brief Read the next one or more attribute directory entries.
14980551e706SIngo Weinhold
14990551e706SIngo Weinhold	This method should perform the same tasks as read_dir(), except that the '.'
15000551e706SIngo Weinhold	and '..' entries do not have to be present. Also, only the \c d_name and
15010551e706SIngo Weinhold	\c d_reclen fields have to be filled in.
15020551e706SIngo Weinhold*/
15030551e706SIngo Weinhold
15040551e706SIngo Weinhold/*!
15050551e706SIngo Weinhold	\fn status_t (*fs_vnode_ops::rewind_attr_dir)(fs_volume *volume,
15060551e706SIngo Weinhold			fs_vnode *vnode, void *cookie)
15070551e706SIngo Weinhold	\brief Rewind the attribute directory iterator to the first entry.
15080551e706SIngo Weinhold
15090551e706SIngo Weinhold	\param volume The volume object.
15100551e706SIngo Weinhold	\param vnode The node object.
15110551e706SIngo Weinhold	\param cookie The cookie associated with this 'directory'.
15120551e706SIngo Weinhold	\return \c B_OK if everything went fine, another error code otherwise.
15130551e706SIngo Weinhold*/
15140551e706SIngo Weinhold
15150551e706SIngo Weinhold//! @}
15160551e706SIngo Weinhold
15170551e706SIngo Weinhold/*!
15180551e706SIngo Weinhold	\name Attribute Operations
15190551e706SIngo Weinhold*/
15200551e706SIngo Weinhold
15210551e706SIngo Weinhold//! @{
15220551e706SIngo Weinhold
15230551e706SIngo Weinhold/*!
15240551e706SIngo Weinhold	\fn status_t (*fs_vnode_ops::create_attr)(fs_volume *volume,
15250551e706SIngo Weinhold			fs_vnode *vnode, const char *name, uint32 type, int openMode,
15260551e706SIngo Weinhold			void **_cookie)
15270551e706SIngo Weinhold	\brief Create a new attribute.
15280551e706SIngo Weinhold
15290551e706SIngo Weinhold	If the attribute already exists, you should open it in truncated mode.
15300551e706SIngo Weinhold
15310551e706SIngo Weinhold	\param volume The volume object.
15320551e706SIngo Weinhold	\param vnode The node object.
15330551e706SIngo Weinhold	\param name The name of the attribute.
15340551e706SIngo Weinhold	\param type The \c type_code of the attribute.
15350551e706SIngo Weinhold	\param openMode The openMode of the associated attribute.
15360551e706SIngo Weinhold	\param[out] _cookie A pointer where you can store an associated file system
15370551e706SIngo Weinhold		cookie.
15380551e706SIngo Weinhold	\return \c B_OK if everything went fine, another error code otherwise.
15390551e706SIngo Weinhold*/
15400551e706SIngo Weinhold
15410551e706SIngo Weinhold/*!
15420551e706SIngo Weinhold	\fn status_t (*fs_vnode_ops::open_attr)(fs_volume *volume, fs_vnode *vnode,
15430551e706SIngo Weinhold			const char *name, int openMode, void **_cookie)
15440551e706SIngo Weinhold	\brief Open an existing attribute.
15450551e706SIngo Weinhold
15460551e706SIngo Weinhold	\param volume The volume object.
15470551e706SIngo Weinhold	\param vnode The node object.
15480551e706SIngo Weinhold	\param name The name of the attribute.
15490551e706SIngo Weinhold	\param openMode The mode in which you want to open the attribute data.
15500551e706SIngo Weinhold	\param[out] _cookie A pointer where you can store an associated file system
15510551e706SIngo Weinhold		cookie.
15520551e706SIngo Weinhold	\return \c B_OK if everything went fine, another error code otherwise.
15530551e706SIngo Weinhold*/
15540551e706SIngo Weinhold
15550551e706SIngo Weinhold/*!
15560551e706SIngo Weinhold	\fn status_t (*fs_vnode_ops::close_attr)(fs_volume *volume, fs_vnode *vnode,
15570551e706SIngo Weinhold				void *cookie)
15580551e706SIngo Weinhold	\brief Close access to an attribute.
15590551e706SIngo Weinhold
15600551e706SIngo Weinhold	Note that you should not delete the cookie yet, you should do that when the
15610551e706SIngo Weinhold	VFS calls free_attr_cookie().
15620551e706SIngo Weinhold
15630551e706SIngo Weinhold	\param volume The volume object.
15640551e706SIngo Weinhold	\param vnode The node object.
15650551e706SIngo Weinhold	\param cookie The cookie you associated with this attribute.
15660551e706SIngo Weinhold	\return \c B_OK if everything went fine, another error code otherwise.
15670551e706SIngo Weinhold*/
15680551e706SIngo Weinhold
15690551e706SIngo Weinhold/*!
15700551e706SIngo Weinhold	\fn status_t (*fs_vnode_ops::free_attr_cookie)(fs_volume *volume,
15710551e706SIngo Weinhold			fs_vnode *vnode, void *cookie)
15720551e706SIngo Weinhold	\brief Free the cookie of an attribute.
15730551e706SIngo Weinhold
15740551e706SIngo Weinhold	The VFS calls this hook when all operations on the attribute have ceased.
15750551e706SIngo Weinhold
15760551e706SIngo Weinhold	\param volume The volume object.
15770551e706SIngo Weinhold	\param vnode The node object.
15780551e706SIngo Weinhold	\param cookie The cookie to the attribute that should be freed.
15790551e706SIngo Weinhold	\return \c B_OK if everything went fine, another error code otherwise.
15800551e706SIngo Weinhold*/
15810551e706SIngo Weinhold
15820551e706SIngo Weinhold/*!
15830551e706SIngo Weinhold	\fn status_t (*fs_vnode_ops::read_attr)(fs_volume *volume, fs_vnode *vnode,
15840551e706SIngo Weinhold			void *cookie, off_t pos, void *buffer, size_t *length)
15850551e706SIngo Weinhold	\brief Read attribute data.
15860551e706SIngo Weinhold
15870551e706SIngo Weinhold	Read until the \a buffer with size \a length is full, or until you are out
15880551e706SIngo Weinhold	of data, in which case you should update \a length.
15890551e706SIngo Weinhold
15900551e706SIngo Weinhold	\param volume The volume object.
15910551e706SIngo Weinhold	\param vnode The node object.
15920551e706SIngo Weinhold	\param cookie The cookie you associated with this attribute.
15930551e706SIngo Weinhold	\param pos The position to start reading from.
15940551e706SIngo Weinhold	\param buffer The buffer the data should be copied in.
15950551e706SIngo Weinhold	\param length The length of the buffer. Update this variable to the actual
15960551e706SIngo Weinhold		amount of bytes read.
15970551e706SIngo Weinhold	\return \c B_OK if everything went fine, another error code otherwise.
15980551e706SIngo Weinhold*/
15990551e706SIngo Weinhold
16000551e706SIngo Weinhold/*!
16010551e706SIngo Weinhold	\fn status_t (*fs_vnode_ops::write_attr)(fs_volume *volume, fs_vnode *vnode,
16020551e706SIngo Weinhold			void *cookie, off_t pos, const void *buffer, size_t *length)
16030551e706SIngo Weinhold	\brief Write attribute data.
16040551e706SIngo Weinhold
16050551e706SIngo Weinhold	\param volume The volume object.
16060551e706SIngo Weinhold	\param vnode The node object.
16070551e706SIngo Weinhold	\param cookie The cookie you associated with this attribute.
16080551e706SIngo Weinhold	\param pos The position to start writing to.
16090551e706SIngo Weinhold	\param buffer The buffer the data should be copied from.
16100551e706SIngo Weinhold	\param length The size of the buffer. Update this variable to the actual
16110551e706SIngo Weinhold		amount of bytes written.
16120551e706SIngo Weinhold	\return \c B_OK if everything went fine, another error code otherwise.
16130551e706SIngo Weinhold*/
16140551e706SIngo Weinhold
16150551e706SIngo Weinhold/*!
16160551e706SIngo Weinhold	\fn status_t (*fs_vnode_ops::read_attr_stat)(fs_volume *volume,
16170551e706SIngo Weinhold			fs_vnode *vnode, void *cookie, struct stat *stat)
16180551e706SIngo Weinhold	\brief Get the stats for an attribute.
16190551e706SIngo Weinhold
16200551e706SIngo Weinhold	Only the \c st_size and \c st_type fields need to be filled in.
16210551e706SIngo Weinhold
16220551e706SIngo Weinhold	\param volume The volume object.
16230551e706SIngo Weinhold	\param vnode The node object.
16240551e706SIngo Weinhold	\param cookie The cookie you associated with this attribute.
16250551e706SIngo Weinhold	\param stat A pointer to a stat structure you should fill.
16260551e706SIngo Weinhold	\return \c B_OK if everything went fine, another error code otherwise.
16270551e706SIngo Weinhold*/
16280551e706SIngo Weinhold
16290551e706SIngo Weinhold/*!
16300551e706SIngo Weinhold	\fn status_t (*fs_vnode_ops::write_attr_stat)(fs_volume *volume,
16310551e706SIngo Weinhold			fs_vnode *vnode, void *cookie, const struct stat *stat,
16320551e706SIngo Weinhold			int statMask)
16330551e706SIngo Weinhold	\brief Update the stats of an attribute.
16340551e706SIngo Weinhold
16350551e706SIngo Weinhold	Currently on the attribute size (B_STAT_SIZE) can be set.
16360551e706SIngo Weinhold
16370551e706SIngo Weinhold	\param volume The volume object.
16380551e706SIngo Weinhold	\param vnode The node object.
16390551e706SIngo Weinhold	\param cookie The cookie you associated with this attribute.
16400551e706SIngo Weinhold	\param stat A pointer to the new stats you should write.
1641a33f8fbdSAdrien Destugues	\param statMask One or more of the values of write_stat_mask that tell you
16420551e706SIngo Weinhold		which fields of \a stat are to be updated.
16430551e706SIngo Weinhold	\return \c B_OK if everything went fine, another error code otherwise.
16440551e706SIngo Weinhold*/
16450551e706SIngo Weinhold
16460551e706SIngo Weinhold/*!
16470551e706SIngo Weinhold	\fn status_t (*fs_vnode_ops::rename_attr)(fs_volume *volume,
16480551e706SIngo Weinhold			fs_vnode *fromVnode, const char *fromName, fs_vnode *toVnode,
16490551e706SIngo Weinhold			const char *toName)
16500551e706SIngo Weinhold	\brief Rename and/or relocate an attribute.
16510551e706SIngo Weinhold
16520551e706SIngo Weinhold	Currently there's no userland or kernel API moving an attribute from one
16530551e706SIngo Weinhold	node to another. So this hook is to allowed to only support the case where
16540551e706SIngo Weinhold	\a fromVnode and \a toVnode are equal and fail otherwise.
16550551e706SIngo Weinhold
16560551e706SIngo Weinhold	\param volume The volume object.
16570551e706SIngo Weinhold	\param fromVnode The node object for the vnode the attribute currently
16580551e706SIngo Weinhold		belongs to.
16590551e706SIngo Weinhold	\param fromName The old name of the attribute.
16600551e706SIngo Weinhold	\param toVnode The node object for the vnode the attribute should be
16610551e706SIngo Weinhold		moved to. This can be the same as \a fromVnode, in which case it only
16620551e706SIngo Weinhold		means the attribute should be renamed.
16630551e706SIngo Weinhold	\param toName The new name of the attribute. This can be the same as
16640551e706SIngo Weinhold		\a fromName, in which case it only means the attribute should be
16650551e706SIngo Weinhold		relocated.
16660551e706SIngo Weinhold	\retval B_OK The renaming and/or relocating succeeded.
16670551e706SIngo Weinhold	\retval B_BAD_VALUE One of the supplied parameters were invalid.
16680551e706SIngo Weinhold	\retval B_NOT_ALLOWED The user does not have the proper permissions.
16690551e706SIngo Weinhold	\retval "other errors" Another error condition was encountered.
16700551e706SIngo Weinhold*/
16710551e706SIngo Weinhold
16720551e706SIngo Weinhold/*!
16730551e706SIngo Weinhold	\fn status_t (*fs_vnode_ops::remove_attr)(fs_volume *volume,
16740551e706SIngo Weinhold			fs_vnode *vnode, const char *name)
16750551e706SIngo Weinhold	\brief Remove an attribute.
16760551e706SIngo Weinhold
16770551e706SIngo Weinhold	\param volume The volume object.
16780551e706SIngo Weinhold	\param vnode The node object.
16790551e706SIngo Weinhold	\param name The name of the attribute.
16800551e706SIngo Weinhold	\return \c B_OK if everything went fine, another error code otherwise.
16810551e706SIngo Weinhold*/
16820551e706SIngo Weinhold
16830551e706SIngo Weinhold//! @}
16840551e706SIngo Weinhold
16850551e706SIngo Weinhold/*!
16860551e706SIngo Weinhold	\name Node and FS Layers
16870551e706SIngo Weinhold*/
16880551e706SIngo Weinhold
1689ff1ee776SNiels Sascha Reedijk//! @{
16900551e706SIngo Weinhold
16910551e706SIngo Weinhold/*!
16920551e706SIngo Weinhold	\fn status_t (*fs_vnode_ops::create_special_node)(fs_volume *volume,
16930551e706SIngo Weinhold			fs_vnode *dir, const char *name, fs_vnode *subVnode, mode_t mode,
16940551e706SIngo Weinhold			uint32 flags, fs_vnode *_superVnode, ino_t *_nodeID)
16950551e706SIngo Weinhold	\brief TODO: Document!
16960551e706SIngo Weinhold*/
16970551e706SIngo Weinhold
16980551e706SIngo Weinhold/*!
16990551e706SIngo Weinhold	\fn status_t (*fs_vnode_ops::get_super_vnode)(fs_volume *volume,
17000551e706SIngo Weinhold			fs_vnode *vnode, fs_volume *superVolume, fs_vnode *superVnode)
17010551e706SIngo Weinhold	\brief TODO: Document!
17020551e706SIngo Weinhold*/
17030551e706SIngo Weinhold
17040551e706SIngo Weinhold
17050551e706SIngo Weinhold//! @}
17060551e706SIngo Weinhold
17070551e706SIngo Weinhold
170850c9917fSIngo Weinhold///// Vnode functions /////
170950c9917fSIngo Weinhold
171050c9917fSIngo Weinhold/*!
1711ff1ee776SNiels Sascha Reedijk	\name Vnode functions
1712ff1ee776SNiels Sascha Reedijk*/
1713ff1ee776SNiels Sascha Reedijk
1714ff1ee776SNiels Sascha Reedijk//! @{
1715ff1ee776SNiels Sascha Reedijk
1716ff1ee776SNiels Sascha Reedijk/*!
17170551e706SIngo Weinhold	\fn status_t new_vnode(fs_volume *volume, ino_t vnodeID, void *privateNode,
17180551e706SIngo Weinhold			fs_vnode_ops *ops)
171950c9917fSIngo Weinhold	\brief Create the vnode with ID \a vnodeID and associates it with the
17200551e706SIngo Weinhold		private data handle \a privateNode, but leaves is in an unpublished
17210551e706SIngo Weinhold		state.
172250c9917fSIngo Weinhold
172350c9917fSIngo Weinhold	The effect of the function is similar to publish_vnode(), but the vnode
172450c9917fSIngo Weinhold	remains in an unpublished state, with the effect that a subsequent
172550c9917fSIngo Weinhold	remove_vnode() will just delete the vnode and not invoke the file system's
17260551e706SIngo Weinhold	\link fs_vnode_ops::remove_vnode remove_vnode() \endlink when
172750c9917fSIngo Weinhold	the final reference is put down.
172850c9917fSIngo Weinhold
172950c9917fSIngo Weinhold	If the vnode shall be kept, publish_vnode() has to be invoked afterwards to
173050c9917fSIngo Weinhold	mark the vnode published. The combined effect is the same as only invoking
173150c9917fSIngo Weinhold	publish_vnode().
173250c9917fSIngo Weinhold
173350c9917fSIngo Weinhold	You'll usually use this function to secure a vnode ID from being reused
173450c9917fSIngo Weinhold	while you are in the process of creating the entry. Note that this function
173550c9917fSIngo Weinhold	will panic in case you call it for an existing vnode ID.
173650c9917fSIngo Weinhold
173750c9917fSIngo Weinhold	The function fails, if the vnode does already exist.
173850c9917fSIngo Weinhold
17390551e706SIngo Weinhold	\param volume The volume object.
174050c9917fSIngo Weinhold	\param vnodeID The ID of the node.
174150c9917fSIngo Weinhold	\param privateNode The private data handle to be associated with the node.
17420551e706SIngo Weinhold	\param ops The operation vector for this vnode. Is not copied and must be
17430551e706SIngo Weinhold		valid through the whole life time of the vnode.
174450c9917fSIngo Weinhold	\return \c B_OK if everything went fine, another error code otherwise.
174550c9917fSIngo Weinhold*/
174650c9917fSIngo Weinhold
174750c9917fSIngo Weinhold/*!
17480551e706SIngo Weinhold	\fn status_t publish_vnode(fs_volume *volume, ino_t vnodeID,
17490551e706SIngo Weinhold			void *privateNode, fs_vnode_ops *ops, int type, uint32 flags)
175050c9917fSIngo Weinhold	\brief Creates the vnode with ID \a vnodeID and associates it with the
175150c9917fSIngo Weinhold		private data handle \a privateNode or just marks it published.
175250c9917fSIngo Weinhold
175350c9917fSIngo Weinhold	If the vnode does already exist and has been published, the function fails.
175450c9917fSIngo Weinhold	If it has not been published yet (i.e. after a successful new_vnode()), the
175550c9917fSIngo Weinhold	function just marks the vnode published. If the vnode did not exist at all
175650c9917fSIngo Weinhold	before, it is created and published.
175750c9917fSIngo Weinhold
175850c9917fSIngo Weinhold	If the function is successful, the caller owns a reference to the vnode. A
175950c9917fSIngo Weinhold	sequence of new_vnode() and publish_vnode() results in just one reference as
176050c9917fSIngo Weinhold	well. The reference can be surrendered by calling put_vnode().
176150c9917fSIngo Weinhold
17620551e706SIngo Weinhold	If called after a new_vnode() the \a privateNode and \a ops parameters must
17630551e706SIngo Weinhold	be the same as previously passed to new_vnode().
176450c9917fSIngo Weinhold
17650551e706SIngo Weinhold	This call is equivalent to the former BeOS R5 new_vnode() function.
17660551e706SIngo Weinhold
17670551e706SIngo Weinhold	\param volume The volume object.
176850c9917fSIngo Weinhold	\param vnodeID The ID of the node.
176950c9917fSIngo Weinhold	\param privateNode The private data handle to be associated with the node.
17700551e706SIngo Weinhold	\param ops The operation vector for this vnode. Is not copied and must be
17710551e706SIngo Weinhold		valid through the whole life time of the vnode.
17720551e706SIngo Weinhold	\param type The type of the node as it would appear in a stat::st_mode (with
17730551e706SIngo Weinhold		all non type-related bits set to 0).
17740551e706SIngo Weinhold	\param flags A bitwise combination of none or more of the following:
17750551e706SIngo Weinhold		- B_VNODE_PUBLISH_REMOVED: The node is published in "removed" state,
17760551e706SIngo Weinhold			i.e. it has no entry referring to it and releasing the last
17770551e706SIngo Weinhold			reference to the vnode will remove it.
17780551e706SIngo Weinhold		- B_VNODE_DONT_CREATE_SPECIAL_SUB_NODE: Normally for FIFO or socket type
17790551e706SIngo Weinhold			nodes the VFS creates sub node providing the associated
17800551e706SIngo Weinhold			functionality. This flag prevents that from happing.
178150c9917fSIngo Weinhold	\return \c B_OK if everything went fine, another error code otherwise.
178250c9917fSIngo Weinhold*/
178350c9917fSIngo Weinhold
178450c9917fSIngo Weinhold/*!
17850551e706SIngo Weinhold	\fn status_t get_vnode(fs_volume *volume, ino_t vnodeID,
17860551e706SIngo Weinhold			void **_privateNode)
178750c9917fSIngo Weinhold	\brief Retrieves the private data handle for the node with the given ID.
178850c9917fSIngo Weinhold
178950c9917fSIngo Weinhold	If the function is successful, the caller owns a reference to the vnode. The
179050c9917fSIngo Weinhold	reference can be surrendered by calling put_vnode().
179150c9917fSIngo Weinhold
17920551e706SIngo Weinhold	\param volume The volume object.
179350c9917fSIngo Weinhold	\param vnodeID The ID of the node.
179450c9917fSIngo Weinhold	\param _privateNode Pointer to a pre-allocated variable the private data
179550c9917fSIngo Weinhold		handle shall be written to.
179650c9917fSIngo Weinhold	\return \c B_OK if everything went fine, another error code otherwise.
179750c9917fSIngo Weinhold*/
179850c9917fSIngo Weinhold
179950c9917fSIngo Weinhold/*!
18000551e706SIngo Weinhold	\fn status_t put_vnode(fs_volume *volume, ino_t vnodeID)
180150c9917fSIngo Weinhold	\brief Surrenders a reference to the specified vnode.
18020551e706SIngo Weinhold
18030551e706SIngo Weinhold	When the last reference to the vnode has been put the VFS will call
18040551e706SIngo Weinhold	fs_vnode_ops::put_vnode() (eventually), respectively, if the node has been
18050551e706SIngo Weinhold	marked removed fs_vnode_ops::remove_vnode() (immediately).
18060551e706SIngo Weinhold
18070551e706SIngo Weinhold	\param volume The volume object.
180850c9917fSIngo Weinhold	\param vnodeID The ID of the node.
180950c9917fSIngo Weinhold	\return \c B_OK if everything went fine, another error code otherwise.
181050c9917fSIngo Weinhold*/
181150c9917fSIngo Weinhold
181250c9917fSIngo Weinhold/*!
18130551e706SIngo Weinhold	\fn status_t acquire_vnode(fs_volume *volume, ino_t vnodeID)
18140551e706SIngo Weinhold	\brief Acquires another reference to a vnode.
18150551e706SIngo Weinhold
18160551e706SIngo Weinhold	Similar to get_vnode() in that the function acquires a vnode reference.
18170551e706SIngo Weinhold	Unlike get_vnode() this function can also be invoked between new_vnode()
18180551e706SIngo Weinhold	and publish_vnode().
18190551e706SIngo Weinhold
18200551e706SIngo Weinhold	\param volume The volume object.
18210551e706SIngo Weinhold	\param vnodeID The ID of the node.
18220551e706SIngo Weinhold	\return \c B_OK if everything went fine, another error code otherwise.
18230551e706SIngo Weinhold*/
18240551e706SIngo Weinhold
18250551e706SIngo Weinhold/*!
18260551e706SIngo Weinhold	\fn status_t remove_vnode(fs_volume *volume, ino_t vnodeID)
182750c9917fSIngo Weinhold	\brief Marks the specified vnode removed.
182850c9917fSIngo Weinhold
182950c9917fSIngo Weinhold	The caller must own a reference to the vnode or at least ensure that a
183050c9917fSIngo Weinhold	reference to the vnode exists. The function does not surrender a reference,
183150c9917fSIngo Weinhold	though.
183250c9917fSIngo Weinhold
183350c9917fSIngo Weinhold	As soon as the last reference to the vnode has been surrendered, the VFS
18340551e706SIngo Weinhold	invokes the node's \link fs_vnode_ops::remove_vnode remove_vnode() \endlink
183550c9917fSIngo Weinhold	hook.
183650c9917fSIngo Weinhold
18370551e706SIngo Weinhold	\param volume The volume object.
183850c9917fSIngo Weinhold	\param vnodeID The ID of the node.
183950c9917fSIngo Weinhold	\return \c B_OK if everything went fine, another error code otherwise.
184050c9917fSIngo Weinhold*/
184150c9917fSIngo Weinhold
184250c9917fSIngo Weinhold/*!
18430551e706SIngo Weinhold	\fn status_t unremove_vnode(fs_volume *volume, ino_t vnodeID)
184450c9917fSIngo Weinhold	\brief Clears the "removed" mark of the specified vnode.
184550c9917fSIngo Weinhold
184650c9917fSIngo Weinhold	The caller must own a reference to the vnode or at least ensure that a
184750c9917fSIngo Weinhold	reference to the vnode exists.
184850c9917fSIngo Weinhold
184950c9917fSIngo Weinhold	The function is usually called when the caller, who has invoked
185050c9917fSIngo Weinhold	remove_vnode() before realizes that it is not possible to remove the node
18510551e706SIngo Weinhold	(e.g. due to an error). Afterwards the vnode will continue to exist as if
18520551e706SIngo Weinhold	remove_vnode() had never been invoked.
185350c9917fSIngo Weinhold
18540551e706SIngo Weinhold	\param volume The volume object.
185550c9917fSIngo Weinhold	\param vnodeID The ID of the node.
185650c9917fSIngo Weinhold	\return \c B_OK if everything went fine, another error code otherwise.
185750c9917fSIngo Weinhold*/
185850c9917fSIngo Weinhold
185950c9917fSIngo Weinhold/*!
18600551e706SIngo Weinhold	\fn status_t get_vnode_removed(fs_volume *volume, ino_t vnodeID,
18610551e706SIngo Weinhold			bool *_removed)
186250c9917fSIngo Weinhold	\brief Returns whether the specified vnode is marked removed.
186350c9917fSIngo Weinhold
186450c9917fSIngo Weinhold	The caller must own a reference to the vnode or at least ensure that a
186550c9917fSIngo Weinhold	reference to the vnode exists.
186650c9917fSIngo Weinhold
18670551e706SIngo Weinhold	\param volume The volume object.
186850c9917fSIngo Weinhold	\param vnodeID The ID of the node.
18690551e706SIngo Weinhold	\param _removed Pointer to a pre-allocated variable set to \c true, if the
187050c9917fSIngo Weinhold		node is marked removed, to \c false otherwise.
187150c9917fSIngo Weinhold	\return \c B_OK if everything went fine, another error code otherwise.
187250c9917fSIngo Weinhold*/
187350c9917fSIngo Weinhold
18740551e706SIngo Weinhold/*!
18750551e706SIngo Weinhold	\fn fs_volume* volume_for_vnode(fs_vnode *vnode)
18760551e706SIngo Weinhold	\brief Returns the volume object for a given vnode.
18770551e706SIngo Weinhold
18780551e706SIngo Weinhold	\param vnode The node object.
18790551e706SIngo Weinhold	\return The volume object for the given vnode.
18800551e706SIngo Weinhold*/
18810551e706SIngo Weinhold
1882ff1ee776SNiels Sascha Reedijk//! @}
18830551e706SIngo Weinhold
188450c9917fSIngo Weinhold///// Notification Functions
188550c9917fSIngo Weinhold
188650c9917fSIngo Weinhold/*!
188750c9917fSIngo Weinhold	\name Notification Functions
188850c9917fSIngo Weinhold
188950c9917fSIngo Weinhold	The following functions are used to implement the node monitor functionality
189050c9917fSIngo Weinhold	in your file system. Whenever one of the below mentioned events occur, you
189150c9917fSIngo Weinhold	have to call them.
189250c9917fSIngo Weinhold
189350c9917fSIngo Weinhold	The node monitor will then notify all registered listeners for the nodes
189450c9917fSIngo Weinhold	that changed.
189550c9917fSIngo Weinhold*/
189650c9917fSIngo Weinhold
1897ff1ee776SNiels Sascha Reedijk//! @{
1898ff1ee776SNiels Sascha Reedijk
189950c9917fSIngo Weinhold/*!
190050c9917fSIngo Weinhold	\fn status_t notify_entry_created(dev_t device, ino_t directory,
190150c9917fSIngo Weinhold			const char *name, ino_t node)
190250c9917fSIngo Weinhold	\brief Notifies listeners that a file system entry has been created.
190350c9917fSIngo Weinhold*/
190450c9917fSIngo Weinhold
190550c9917fSIngo Weinhold/*!
190650c9917fSIngo Weinhold	\fn status_t notify_entry_removed(dev_t device, ino_t directory,
190750c9917fSIngo Weinhold			const char *name, ino_t node)
190850c9917fSIngo Weinhold	\brief Notifies listeners that a file system entry has been removed.
190950c9917fSIngo Weinhold*/
191050c9917fSIngo Weinhold
191150c9917fSIngo Weinhold/*!
191250c9917fSIngo Weinhold	\fn status_t notify_entry_moved(dev_t device, ino_t fromDirectory,
191350c9917fSIngo Weinhold			const char *fromName, ino_t toDirectory,
191450c9917fSIngo Weinhold			const char *toName, ino_t node)
19150551e706SIngo Weinhold	\brief Notifies listeners that a file system entry has been renamed and/or
19160551e706SIngo Weinhold		moved to another directory.
191750c9917fSIngo Weinhold*/
191850c9917fSIngo Weinhold
191950c9917fSIngo Weinhold/*!
19209a243c1bSJohn Scipione	\fn status_t notify_stat_changed(dev_t device, ino_t directory, ino_t node,
192150c9917fSIngo Weinhold			uint32 statFields)
19220551e706SIngo Weinhold	\brief Notifies listeners that certain \a statFields of a node were updated.
192350c9917fSIngo Weinhold*/
192450c9917fSIngo Weinhold
192550c9917fSIngo Weinhold/*!
19269a243c1bSJohn Scipione	\fn status_t notify_attribute_changed(dev_t device, ino_t directory,
19279a243c1bSJohn Scipione			ino_t node, const char *attribute, int32 cause)
19280551e706SIngo Weinhold	\brief Notifies listeners that an attribute of a node has been changed.
192950c9917fSIngo Weinhold*/
193050c9917fSIngo Weinhold
193150c9917fSIngo Weinhold/*!
193250c9917fSIngo Weinhold	\fn status_t notify_query_entry_created(port_id port, int32 token,
19330551e706SIngo Weinhold			dev_t device, ino_t directory, const char *name, ino_t node)
19340551e706SIngo Weinhold	\brief Notifies listeners that an entry has entered the result set of a live
19350551e706SIngo Weinhold		query.
193650c9917fSIngo Weinhold*/
193750c9917fSIngo Weinhold
193850c9917fSIngo Weinhold/*!
193950c9917fSIngo Weinhold	\fn status_t notify_query_entry_removed(port_id port, int32 token,
19400551e706SIngo Weinhold			dev_t device, ino_t directory, const char *name, ino_t node)
19410551e706SIngo Weinhold	\brief Notifies listeners that an entry has left the result set of a live
19420551e706SIngo Weinhold		query.
194350c9917fSIngo Weinhold*/
194450c9917fSIngo Weinhold
194550c9917fSIngo Weinhold//! @}
1946