1/* 2 * Copyright 2007 Haiku Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Ingo Weinhold 7 * Niels Sascha Reedijk <niels.reedijk@gmail.com> 8 * Corresponds to: 9 * /trunk/headers/os/drivers/fs_interface.h rev 20724 10 */ 11 12/*! 13 \file fs_interface.h 14 \ingroup drivers 15 \brief Provides an interface for file system modules. 16 17 See the \ref fs_modules "introduction to file system modules" for a guide on 18 how to get started with writing file system modules. 19*/ 20 21///// Typedefs ///// 22 23/*! 24 \typedef typedef dev_t mount_id 25 \brief A \c mount_id refers to a mounted volume. 26*/ 27 28/*! 29 \typedef typedef ino_t vnode_id 30 \brief A \c vnode_id refers to one of the available vnodes. 31*/ 32 33/*! 34 \typedef typedef void *fs_volume 35 \brief Private data structure for the filesystem to store data associated 36 with volumes. 37*/ 38 39/*! 40 \typedef typedef void *fs_cookie 41 \brief Private data structure that is passed to the filesystem when it is 42 called. 43*/ 44 45/*! 46 \typedef typedef void *fs_vnode 47 \brief Private data structure that is passed to the filesystem when it is 48 operating on vnodes. 49*/ 50 51///// write_stat_mask ////// 52 53/*! 54 \enum write_stat_mask 55 \brief This mask is used in file_system_module_info::write_stat() to 56 determine which values need to be written. 57*/ 58 59/*! 60 \var write_stat_mask::FS_WRITE_STAT_MODE 61 \brief The mode parameter should be updated. 62*/ 63 64/*! 65 \var write_stat_mask::FS_WRITE_STAT_UID 66 \brief The UID field should be updated. 67*/ 68 69/*! 70 \var write_stat_mask::FS_WRITE_STAT_GID 71 \brief The GID field should be updated. 72*/ 73 74/*! 75 \var write_stat_mask::FS_WRITE_STAT_SIZE 76 \brief The size field should be updated. If the actual size is less than the 77 new provided file size, the file should be set to the new size and the 78 extra space should be filled with zeros. 79*/ 80 81/*! 82 \var write_stat_mask::FS_WRITE_STAT_ATIME 83 \brief The access time should be updated. 84*/ 85 86/*! 87 \var write_stat_mask::FS_WRITE_STAT_MTIME 88 \brief The 'last modified' field should be updated. 89*/ 90 91/*! 92 \var write_stat_mask::FS_WRITE_STAT_CRTIME 93 \brief The 'creation time' should be updated. 94*/ 95 96///// FS_WRITE_FSINFO_NAME ///// 97 98/*! 99 \def FS_WRITE_FSINFO_NAME 100 \brief Passed to file_system_module_info::write_fs_info(). 101*/ 102 103///// file_io_vec ///// 104 105/*! 106 \struct file_io_vec 107 \brief Structure that describes the io vector of a file. 108*/ 109 110/*! 111 \var off_t file_io_vec::offset 112 \brief The offset within the file. 113*/ 114 115/*! 116 \var off_t file_io_vec::length 117 \brief The length of the vector. 118*/ 119 120///// B_CURRENT_FS_API_VERSION ///// 121 122/*! 123 \def B_CURRENT_FS_API_VERSION 124 \brief Constant that defines the version of the filesystem API that your 125 filesystem conforms to. 126*/ 127 128///// file_system_module_info ///// 129 130 131/*! 132 \struct file_system_module_info 133 \brief Kernel module interface for file systems. 134 135 See the \ref fs_modules "introduction to file system modules" for an 136 introduction to writing file systems. 137*/ 138 139/*! 140 \name Data members 141*/ 142 143//! @{ 144 145/*! 146 \var module_info file_system_module_info::info 147 \brief Your module_info object which is required for all modules. 148*/ 149 150/*! 151 \var const char *file_system_module_info::pretty_name 152 \brief A NULL-terminated string with a 'pretty' name for you file system. 153*/ 154 155//! @} 156 157/*! 158 \name Scanning 159*/ 160 161//! @{ 162 163/*! 164 \fn float (*file_system_module_info::identify_partition)(int fd, partition_data *partition, void **cookie) 165 \brief Undocumented. TODO. 166*/ 167 168/*! 169 \fn status_t (*file_system_module_info::scan_partition)(int fd, partition_data *partition, void *cookie) 170 \brief Undocumented. TODO. 171*/ 172 173/*! 174 \fn void (*file_system_module_info::free_identify_partition_cookie)(partition_data *partition, void *cookie) 175 \brief Undocumented. TODO. 176*/ 177 178/*! 179 \fn void (*file_system_module_info::free_partition_content_cookie)(partition_data *partition) 180 \brief Undocumented. TODO. 181*/ 182 183//! @} 184 185/*! 186 \name General Operations 187*/ 188 189//! @{ 190 191/*! 192 \fn status_t (*file_system_module_info::mount)(mount_id id, const char *device, 193 uint32 flags, const char *args, fs_volume *_fs, vnode_id *_rootVnodeID) 194 \brief Mount a volume according to the specified parameters. 195 196 Invoked by the VFS when it has been requested to mount the volume. The FS is 197 supposed to perform whatever one-time initialization is necessary for the 198 volume. It is required to create a volume handle for the volume and pass it 199 back in \a _fs. Moreover it must invoke publish_vnode() for the root node 200 of the volume and pass the ID of the volume back in \a _rootVnodeID. 201 202 A disk-based FS will need to check whether \a device is not \c NULL, open 203 it, and analyze whether the device or image file actually represents a volume 204 of that FS type. 205 206 If mounting the volume fails for whatever reason, the hook must return an 207 error code other than \c B_OK. In this case all resources allocated by the 208 hook must be freed before returning. If and only if \c B_OK is returned, the 209 unmount() hook will be invoked at a later point when unmounting the volume. 210 211 \param id The ID of the volume to be mounted. It should be saved in the FS's 212 volume private data (volume handle). 213 \param device The path to the device (or image file) representing the volume 214 to be mounted. Can be \c NULL. 215 \param flags Flags: 216 - \c B_MOUNT_READ_ONLY: Mount the volume read-only. 217 \param args Null-terminated string in driver settings format, containing FS 218 specific parameters. 219 \param _fs Pointer to a pre-allocated variable the volume handle shall be 220 written to. 221 \param _rootVnodeID Pointer to a pre-allocated variable the ID of the 222 volume's root directory shall be written to. 223 \return \c B_OK if everything went fine, another error code otherwise. 224*/ 225 226/*! 227 \fn status_t (*file_system_module_info::unmount)(fs_volume fs) 228 \brief Unmounts the given volume. 229 230 Invoked by the VFS when it is asked to unmount the volume. The function must 231 free all resources associated with the mounted volume, including the volume 232 handle. Although the mount() hook called publish_vnode() for the root node 233 of the volume, unmount() must not invoke put_vnode(). 234 235 \param fs The volume handle. 236 \return \c B_OK if everything went fine, another error code otherwise. The 237 error code will be ignored, though. 238*/ 239 240/*! 241 \fn status_t (*file_system_module_info::read_fs_info)(fs_volume fs, 242 struct fs_info *info) 243 \brief Retrieves general information about the volume. 244 245 The following fields of the \c fs_info structure need to be filled in: 246 - \c flags: Flags applying to the volume, e.g. \c B_FS_IS_READONLY, 247 \c B_FS_HAS_ATTR, etc. 248 - \c block_size: The size of blocks the volume data are organized in. 249 Meaningful mainly for disk-based FSs, other FSs should use some reasonable 250 value for computing \c total_blocks and \c free_blocks. 251 - \c io_size: Preferred size of the buffers passed to read() and write(). 252 - \c total_blocks: Total number of blocks the volume contains. 253 - \c free_blocks: Number of free blocks on the volume. 254 - \c total_nodes: Maximal number of nodes the volume can contain. If there is 255 no such limitation use \c LONGLONG_MAX. 256 - \c free_nodes: Number of additional nodes the volume could contain. If 257 there is no such limitation use \c LONGLONG_MAX. 258 - \c device_name: The name of the device or image file containing the volume. 259 Non-disk-based FSs shall fill in an empty string. 260 - \c volume_name: The name of the volume. 261 262 The other values are filled in by the VFS. 263 264 \param fs The volume handle. 265 \param info Pointer to a pre-allocated variable the FS info shall be written 266 to. 267 \return \c B_OK if everything went fine, another error code otherwise. The 268 error code will be ignored, though. 269*/ 270 271/*! 272 \fn status_t (*file_system_module_info::write_fs_info)(fs_volume fs, const 273 struct fs_info *info, uint32 mask) 274 \brief Update filesystem information on the volume. 275 276 You are requested to update certain information on the volume \a fs. The 277 supplied \a info contains the new values filled in for the \a mask. 278 Currently, the only possible mask is solely the \c FS_WRITE_FSINFO_NAME, 279 which asks you to update the volume name represented by the value 280 \c volume_name in the \c fs_info struct. 281 282 \param fs The cookie your filesystem supplied to the volume that should be 283 updated. 284 \param info The structure that contains the new data. 285 \param mask The values of the \a info that need to be updated. 286 \return \c B_OK if everything went fine, if not, one of the error codes. 287*/ 288 289/*! 290 \fn status_t (*file_system_module_info::sync)(fs_volume fs) 291 \brief Synchronize the cached data with the contents of the disk. 292 293 The VFS layer sometimes wants you to synchronize any cached values with the 294 data on the device. 295 296 TODO: WHEN IS THIS CALLED AND FOR WHAT PURPOSE? 297 298 \param fs The cookie your filesystem supplied to the volume that should be 299 updated. 300*/ 301 302//! @} 303 304/*! 305 \name VNode Operations 306*/ 307 308//! @{ 309 310/*! 311 \fn status_t (*file_system_module_info::lookup)(fs_volume fs, fs_vnode dir, 312 const char *name, vnode_id *_id, int *_type) 313 \brief Looks up the node a directory entry refers to. 314 315 The VFS uses this hook to resolve path names to vnodes. It is used quite 316 often and should be implemented efficiently. 317 318 If the parameter \a dir does not specify a directory, the function shall 319 fail. It shall also fail, if it is a directory, but does not contain an entry 320 with the given name \a name. Otherwise the function shall invoke get_vnode() 321 for the node the entry refers to and pass back the ID and the type of the 322 node in \a _id and \a _type respectively. 323 324 Note that a directory must contain the special entries \c "." and \c "..", 325 referring to the same directory and the parent directory respectively. 326 lookup() must resolve the nodes accordingly. \c ".." for the root directory 327 of the volume shall be resolved to the root directory itself. 328 329 \param fs The volume handle. 330 \param dir The node handle of the directory. 331 \param name The name of the directory entry. 332 \param _id Pointer to a pre-allocated variable the ID of the found node 333 shall be written to. 334 \param _type Pointer to a pre-allocated variable the type of the found node 335 shall be written to. The type is encoded as in the \c st_mode field of a 336 <tt>struct stat</tt> (bitwise anded with \c S_IFMT). 337 \retval B_OK Everything went fine. 338 \retval B_ENTRY_NOT_FOUND The given directory does not contain an entry with 339 the given name. 340*/ 341 342/*! 343 \fn status_t (*file_system_module_info::get_vnode_name)(fs_volume fs, 344 fs_vnode vnode, char *buffer, size_t bufferSize) 345 \brief Return the file name of a vnode. 346 347 \param fs The file system provided cookie associated with this volume. 348 \param vnode The file system provided cookie associated with this vnode. 349 \param buffer The buffer that the name can be copied into. 350 \param bufferSize The size of the buffer. 351 \retval B_OK You successfully copied the file name into the \a buffer. 352 \retval "other errors" There was some error looking up or copying the name. 353*/ 354 355/*! 356 \fn status_t (*file_system_module_info::get_vnode)(fs_volume fs, vnode_id id, 357 fs_vnode *_vnode, bool reenter) 358 \brief Creates the private data handle to be associated with the node 359 referred to by \a id. 360 361 Invoked by the VFS when it creates the vnode for the respective node. 362 363 \param fs The volume handle. 364 \param id The ID of the node. 365 \param _vnode Pointer to a pre-allocated variable the node handle shall be 366 written to. 367 \param reenter \c true if the hook invocation has been caused by the FS 368 itself, e.g. by invoking ::get_vnode(). 369 \return \c B_OK if everything went fine, another error code otherwise. 370*/ 371 372/*! 373 \fn \fn status_t (*file_system_module_info::put_vnode)(fs_volume fs, 374 fs_vnode vnode, bool reenter) 375 \brief Deletes the private data handle associated with the specified node. 376 377 Invoked by the VFS when it deletes the vnode for the respective node and the 378 node is not marked removed. 379 380 \param fs The volume handle. 381 \param vnode The node handle. 382 \param reenter \c true if the hook invocation has been caused by the FS 383 itself, e.g. by invoking ::put_vnode(). 384 \return \c B_OK if everything went fine, another error code otherwise. 385*/ 386 387/*! 388 \fn status_t (*file_system_module_info::remove_vnode)(fs_volume fs, 389 fs_vnode vnode, bool reenter) 390 \brief Deletes the private data handle associated with the specified node. 391 392 Invoked by the VFS when it deletes the vnode for the respective node and the 393 node is marked removed. 394 395 \param fs The volume handle. 396 \param vnode The node handle. 397 \param reenter \c true if the hook invocation has been caused by the FS 398 itself, e.g. by invoking ::put_vnode(). 399 \return \c B_OK if everything went fine, another error code otherwise. 400*/ 401 402//! @} 403 404/*! 405 \name VM file access 406*/ 407 408//! @{ 409 410/*! 411 \fn bool (*file_system_module_info::can_page)(fs_volume fs, fs_vnode vnode, fs_cookie cookie) 412 \brief Undocumented. TODO. 413 414 TODO: In both the dos and the bfs implementations this thing simply returns 415 false... Is there anything more to it? 416*/ 417 418/*! 419 \fn status_t (*file_system_module_info::read_pages)(fs_volume fs, fs_vnode vnode, fs_cookie cookie, 420 off_t pos, const iovec *vecs, size_t count, size_t *_numBytes, 421 bool reenter) 422 \brief Undocumented. TODO. 423*/ 424 425/*! 426 \fn status_t (*file_system_module_info::write_pages)(fs_volume fs, fs_vnode vnode, fs_cookie cookie, 427 off_t pos, const iovec *vecs, size_t count, size_t *_numBytes, 428 bool reenter) 429 \brief Undocumented. TODO. 430*/ 431 432//! @} 433 434/*! 435 \name Cache File Access 436*/ 437 438//! @{ 439 440/*! 441 \fn status_t (*file_system_module_info::get_file_map)(fs_volume fs, fs_vnode vnode, off_t offset, 442 size_t size, struct file_io_vec *vecs, size_t *_count) 443 \brief Undocumented. TODO. 444*/ 445 446//! @} 447 448/*! 449 \name Standard Operations 450*/ 451 452//! @{ 453 454/*! 455 \fn status_t (*file_system_module_info::ioctl)(fs_volume fs, fs_vnode vnode, 456 fs_cookie cookie, ulong op, void *buffer, size_t length) 457 \brief Perform file system specific operations. 458 459 You can implement a customized API using this call. This can be extremely 460 handy for debugging purposes. There are no obligatory operations for you to 461 implement. 462 463 If you don't want to use this feature, you don't have to implement it. 464 465 \param fs The file system provided cookie associated with this volume. 466 \param vnode The file system provided cookie associated with the vnode (if 467 applicable). 468 \param cookie The file system provided cookie associated with, for example, 469 an open file (if applicable). 470 \param op The operation code. You will have to define them yourself. 471 \param buffer A buffer (if applicable). 472 \param length The size of the buffer. 473 \return You should return any of your status codes. 474*/ 475 476/*! 477 \fn status_t (*file_system_module_info::set_flags)(fs_volume fs, fs_vnode 478 vnode, fs_cookie cookie, int flags) 479 \brief Set the open mode flags for an opened file. 480 481 This function should change the open flags for an opened file. 482 483 \param fs The file system provided cookie associated with this volume. 484 \param vnode The file system provided cookie associated with the vnode. 485 \param cookie The file system provided cookie associated with the opened 486 file. 487 \param flags The new flags. 488 \return \c B_OK if the operation succeeded, or else an error code. 489*/ 490 491/*! 492 \fn status_t (*file_system_module_info::select)(fs_volume fs, fs_vnode vnode, fs_cookie cookie, 493 uint8 event, uint32 ref, selectsync *sync) 494 \brief Undocumented. TODO. 495 496 TODO: What should this do? 497*/ 498 499/*! 500 \fn status_t (*file_system_module_info::deselect)(fs_volume fs, fs_vnode vnode, fs_cookie cookie, 501 uint8 event, selectsync *sync) 502 \brief Undocumented. TODO. 503 504 TODO: What should this do? 505*/ 506 507/*! 508 \fn status_t (*file_system_module_info::fsync)(fs_volume fs, fs_vnode vnode) 509 \brief Synchronize the buffers with the on disk data. 510 511 \param fs The file system provided cookie associated with this volume. 512 \param vnode The file system provided cookie associated with the vnode. 513 \return \c B_OK if the operation succeeded, or else an error code. 514*/ 515 516/*! 517 \fn status_t (*file_system_module_info::read_symlink)(fs_volume fs, 518 fs_vnode link, char *buffer, size_t *_bufferSize) 519 \brief Read the value of a symbolic link. 520 521 If the function is successful, the string written to the buffer shall be 522 null-terminated and the variable \a _bufferSize points to shall be set to 523 the length of that string, including the terminating null character. 524 525 \param fs The volume handle. 526 \param link The node handle. 527 \param buffer Pointer to a pre-allocated buffer the link value shall be 528 written to. 529 \param buffer Pointer to a pre-allocated variable containing the size of the 530 buffer supplied to the function. Upon successful completion the hook shall 531 store the number of bytes actually written into the buffer in the variable. 532 \retval B_OK Everything went fine. 533 \retval B_BAD_VALUE \a link does not identify a symbolic link. 534 \retval B_BUFFER_OVERFLOW The supplied buffer is not big enough to contain 535 the complete link value. 536*/ 537 538/*! 539 \fn status_t (*file_system_module_info::create_symlink)(fs_volume fs, 540 fs_vnode dir, const char *name, const char *path, int mode) 541 \brief Create a new symbolic link. 542 543 Your implementation should check if the user has permission to perform this 544 operation. 545 546 \param fs The file system provided cookie associated with this volume. 547 \param dir The file system provided cookie associated with the directory 548 the symbolic link should be created in. 549 \param name The name of the new symbolic link. 550 \param path The path of the original inode the symbolic link should refer to. 551 \param mode The mode that this symbolic link should be created in. (TODO 552 what exactly?) 553 \return \c B_OK if you succeeded, or an error code if you failed. 554*/ 555 556/*! 557 \fn status_t (*file_system_module_info::link)(fs_volume fs, fs_vnode dir, 558 const char *name, fs_vnode vnode) 559 \brief Create a new hard link. 560 561 You should make sure the user has the proper permissions. 562 563 The virtual file system will request the creation of symbolic links with 564 create_symlink(). 565 566 \param fs The file system provided cookie associated with this volume. 567 \param dir The cookie associated to the directory where the link should be 568 saved. 569 \param name The name the link should have. 570 \param vnode The vnode the new link should resolve to. 571 \retval B_OK The hard link is properly created. 572 \retval B_NOT_ALLOWED The user does not have the proper permissions. 573 \retval "other errors" Another error occured. 574*/ 575 576/*! 577 \fn status_t (*file_system_module_info::unlink)(fs_volume fs, fs_vnode dir, 578 const char *name) 579 \brief Remove a node or directory. 580 581 You should make sure the user has the proper permissions. 582 583 \param fs The file system provided cookie associated with this volume. 584 \param dir The parent directory of the node that should be removed. 585 \param name The name of the node that should be deleted. 586 \retval B_OK Removal succeeded. 587 \retval B_ENTRY_NOT_FOUND The entry does not exist. 588 \retval B_NOT_ALLOWED The user does not have the proper permissions. 589 \retval B_DIRECTORY_NOT_EMPTY The \a name refers to a directory. The virtual 590 file system expects directories to be emptied before they can be unlinked. 591 \retval "other errors" Another error occured. 592*/ 593 594/*! 595 \fn status_t (*file_system_module_info::rename)(fs_volume fs, fs_vnode 596 fromDir, const char *fromName, fs_vnode toDir, const char *toName) 597 \brief Rename and/or relocate a vnode. 598 599 The virtual file system merely relays the request, so make sure the user is 600 not changing the file name to something like '.', '..' or anything starting 601 with '/'. 602 603 This also means that it if the node is a directory, that it should not be 604 moved into one of its own children. 605 606 You should also make sure the user has the proper permissions. 607 608 \param fs The file system provided cookie associated with this volume. 609 \param fromDir The cookie of the parent directory the vnode should be moved 610 from. 611 \param fromName The old name of the node. 612 \param toDir The cookie of the parent directory the vnode should be moved to. 613 \param toName The new name of the node. 614 \retval B_OK The renaming and relocating succeeded. 615 \retval B_BAD_VALUE One of the supplied parameters were invalid. 616 \retval B_NOT_ALLOWED The user does not have the proper permissions. 617 \retval "other errors" Another error condition was encountered. 618*/ 619 620/*! 621 \fn status_t (*file_system_module_info::access)(fs_volume fs, fs_vnode vnode, 622 int mode) 623 \brief Checks whether the current user is allowed to access the node in the 624 specified way. 625 626 \a mode is a bitwise combination of: 627 - \c R_OK: Read access. 628 - \c W_OK: Write access. 629 - \c X_OK: Execution. 630 631 If the current user does not have any of the access permissions represented 632 by the set bits, the function shall return \c B_NOT_ALLOWED. As a special 633 case, if the volume is read-only and write access is requested, 634 \c B_READ_ONLY_DEVICE shall be returned. If the requested access mode 635 complies with the user's access permissions, the function shall return 636 \c B_OK. 637 638 For most FSs the permissions a user has are defined by the \c st_mode, 639 \c st_uid, and \c st_gid fields of the node's stat data. As a special 640 exception, the root user (<tt>geteuid() == 0</tt>) does always have 641 read and write permissions, execution permission only when at least one of 642 the execution permission bits are set. 643 644 \param fs The volume handle. 645 \param vnode The node handle. 646 \param mode The access mode mask. 647 \retval B_OK The user has the permissions to access the node in the requested 648 way. 649 \retval B_READ_ONLY_DEVICE The volume is read-only, but the write access has 650 been requested. 651 \retval B_NOT_ALLOWED The user does not have all permissions to access the 652 node in the requested way. 653*/ 654 655/*! 656 \fn status_t (*file_system_module_info::read_stat)(fs_volume fs, 657 fs_vnode vnode, struct stat *stat) 658 \brief Retrieves the stat data for a given node. 659 660 All values of the <tt>struct stat</tt> save \c st_dev, \c st_ino, \c st_rdev, 661 and \c st_type need to be filled in. 662 663 \param fs The volume handle. 664 \param vnode The node handle. 665 \param stat Pointer to a pre-allocated variable the stat data shall be 666 written to. 667 \return \c B_OK if everything went fine, another error code otherwise. 668*/ 669 670/*! 671 \fn status_t (*file_system_module_info::write_stat)(fs_volume fs, fs_vnode 672 vnode, const struct stat *stat, uint32 statMask) 673 \brief Update the stats for a vnode. 674 675 You should make sure that the new values are valid and that the user has the 676 proper permissions to update the stats. 677 678 \param fs The file system provided cookie to the volume. 679 \param vnode The cookie to the vnode. 680 \param stat The structure with the updated values. 681 \param statMask One of the #write_stat_mask enumeration, which forms a mask 682 of which of the values in \a stat should actually be updated. 683 \retval B_OK The update succeeded. 684 \retval B_NOT_ALLOWED The user does not have the proper permissions. 685 \retval "other errors" Another error condition occured. 686*/ 687 688//! @} 689 690/*! 691 \name File Operations 692*/ 693 694//! @{ 695 696/*! 697 \fn status_t (*file_system_module_info::create)(fs_volume fs, fs_vnode dir, 698 const char *name, int openMode, int perms, fs_cookie *_cookie, 699 vnode_id *_newVnodeID) 700 \brief Create a new file. 701 702 Your implementation shall check whether it is possible to create the node. 703 You will need to take the user's permissions into account. When you create 704 a new file, you will also have to open it. This means also checking the 705 permissions the user requires to open the file according to the \a mode. 706 See \link file_system_module_info::open() open() \endlink for the possible 707 values of \a mode. 708 709 \param fs The file system provided cookie associated with this volume. 710 \param dir The file system provided cookie associated with the directory 711 where the file should appear. 712 \param name The name of the new file. 713 \param openMode The mode associated to the file. 714 \param perms The permissions the new file should have. 715 \param[out] _cookie In case of success, the you can store your file system 716 data for this node in this variable. 717 \param[out] _newVnodeID In case of success, you can store the new vnode id 718 in this variable. 719 \return You should return \c B_OK if creating the new node succeeded, and if 720 you put data in both \a _cookie and \a _newVnodeID. Else you should return 721 an error code. 722*/ 723 724/*! 725 \fn status_t (*file_system_module_info::open)(fs_volume fs, fs_vnode vnode, 726 int openMode, fs_cookie *_cookie) 727 \brief Opens the given node. 728 729 The function shall check whether it is possible to open the node according to 730 the mode specified by \c openMode (also considering the user's access 731 permissions), create a node cookie, and store it in the variable 732 \a _cookie points to. 733 734 The open mode \a openMode is encoded in the same way as the parameter of the 735 POSIX function \c open(), i.e. it is either \c O_RDONLY, \c O_WRONLY, or 736 \c O_RDWR, bitwise or'ed with flags. The only relevant flags for this hook 737 are \c O_TRUNC and \c O_NONBLOCK. 738 739 \param fs The volume handle. 740 \param vnode The node handle. 741 \param openMode The open mode. 742 \param _cookie Pointer to a pre-allocated variable the node cookie shall be 743 written to. 744 \return \c B_OK if everything went fine, another error code otherwise. 745*/ 746 747/*! 748 \fn status_t (*file_system_module_info::close)(fs_volume fs, fs_vnode vnode, 749 fs_cookie cookie) 750 \brief Closes the given node cookie. 751 752 The hook is invoked, when closing the node has been requested. At this point 753 other threads might still use the cookie, i.e. still execute hooks to which 754 the cookie has been passed. If the FS supports blocking I/O operations, this 755 hook should make sure to unblock all currently blocking threads performing 756 an operation using the cookie, and mark the cookie such that no further 757 threads will block using it. 758 759 For many FSs this hook is a no-op. 760 761 \param fs The volume handle. 762 \param vnode The node handle. 763 \param cookie The node cookie as returned by open(). 764 \return \c B_OK if everything went fine, another error code otherwise. 765*/ 766 767/*! 768 \fn status_t (*file_system_module_info::free_cookie)(fs_volume fs, 769 fs_vnode vnode, fs_cookie cookie) 770 \brief Frees the given node cookie. 771 772 The hook is invoked after close(), when no other thread uses or is going to 773 use the cookie. All resources associated with the cookie must be freed. 774 775 \param fs The volume handle. 776 \param vnode The node handle. 777 \param cookie The node cookie as returned by open(). 778 \return \c B_OK if everything went fine, another error code otherwise. 779*/ 780 781/*! 782 \fn status_t (*file_system_module_info::read)(fs_volume fs, fs_vnode vnode, 783 fs_cookie cookie, off_t pos, void *buffer, size_t *length) 784 \brief Reads data from a file. 785 786 This function should fail if 787 - the node is not a file, 788 - the cookie has not been opened for reading, 789 - \a pos is negative, or 790 - some other error occurs while trying to read the data, and no data have 791 been read at all. 792 793 The number of bytes to be read is stored in the variable pointed to by 794 \a length. If less data is available at file position \a pos, or if \a pos 795 if greater than the size of the file, only as many data as available shall 796 be read, the function shall store the number of bytes actually read into the 797 variable pointed to by \a length, and return \c B_OK. 798 799 \param fs The volume handle. 800 \param vnode The node handle. 801 \param cookie The node cookie as returned by open(). 802 \param pos The file position where to start reading data. 803 \param buffer Pointer to a pre-allocated buffer the read data shall be 804 written to. 805 \param length Pointer to a pre-allocated variable containing the size of the 806 buffer when invoked, and into which the size of the data actually read 807 shall be written. 808 \return \c B_OK if everything went fine, another error code otherwise. 809*/ 810 811/*! 812 \fn status_t (*file_system_module_info::write)(fs_volume fs, fs_vnode vnode, 813 fs_cookie cookie, off_t pos, const void *buffer, size_t *length) 814 \brief Write data to a file. 815 816 This function should fail if 817 - the node is not a file, 818 - the cookie has not been opened for writing, 819 - \a pos is negative, or 820 - some other error occurs while trying to read the data, and no data have 821 been read at all. 822 823 The number of bytes to be written is stored in the variable pointed to by 824 \a length. 825 826 TODO: What to do if we were to write less than the \a length? Should this 827 function fail? 828 829 \param fs The file system provided cookie associated with this volume. 830 \param vnode The file system provided cookie associated with the vnode. 831 \param cookie The file system provided cookie associated with the file. 832 \param pos The position to start writing. 833 \param buffer The buffer that contains the data that will need to be written. 834 \param length The length of the data that needs to be written. 835 \return \c B_OK if everything went fine, another error code otherwise. 836*/ 837 838//! @} 839 840/*! 841 \name Directory Operations 842*/ 843 844/*! 845 \fn status_t (*file_system_module_info::create_dir)(fs_volume fs, fs_vnode 846 parent, const char *name, int perms, vnode_id *_newVnodeID) 847 \brief Create a new directory. 848 849 Your implementation should make sure that the directory actually can be 850 created in the \a parent directory. You will have to check if the user has 851 permissions to actually write to the \a parent. If not, this function should 852 fail (probably with \c B_NOT_ALLOWED, or in case of a read-only filesystem, 853 with \c B_READ_ONLY_DEVICE). If the operation succeeds, you should put the 854 new vnode id in \a _newVnodeID. 855 856 \param fs The file system provided cookie associated with this volume. 857 \param parent The file system provided cookie associated with the parent 858 node. 859 \param name The name the new directory should have. 860 \param perms The permissions the new directory should have. 861 \param[out] _newVnodeID If creating the directory succeeds, than you should 862 put the new vnode id in this variable. 863 \return If the operation succeeds and the \a _newVnodeID is populated with 864 the new vnode, then you should return \c B_OK. Else you should return with 865 an error code. 866*/ 867 868/*! 869 \fn status_t (*file_system_module_info::remove_dir)(fs_volume fs, fs_vnode 870 parent, const char *name) 871 \brief Remove a directory. 872 873 You should make sure the user has the proper permissions. You should also 874 check that the directory is empty. 875 876 \param fs The file system provided cookie associated with this volume. 877 \param parent The file system provided cookie associated with the parent 878 node. 879 \param name The \a name of the directory that needs to be removed. 880 \retval B_OK Operation succeeded. 881 \retval B_DIRECTORY_NOT_EMPTY The directory is not empty. 882 \retval B_ENTRY_NOT_FOUND There is no directory with this \a name. 883 \retval B_NOT_A_DIRECTORY The entry is not a directory. 884 \retval "other errors" Other errors occured. 885*/ 886 887/*! 888 \fn status_t (*file_system_module_info::open_dir)(fs_volume fs, fs_vnode vnode, 889 fs_cookie *_cookie) 890 \brief Opens the given directory node. 891 892 If the specified node is not a directory, or if the current user does not 893 have the permissions to read the directory, the function shall fail. 894 Otherwise it shall allocate a directory cookie and store it in the variable 895 \a _cookie points to. A subsequent read_dir() using the cookie shall start 896 reading the first entry of the directory. 897 898 \param fs The volume handle. 899 \param vnode The node handle. 900 \param _cookie Pointer to a pre-allocated variable the directory cookie shall 901 be written to. 902 \return \c B_OK if everything went fine, another error code otherwise. 903*/ 904 905/*! 906 \fn status_t (*file_system_module_info::close_dir)(fs_volume fs, 907 fs_vnode vnode, fs_cookie cookie) 908 \brief Closes the given directory cookie. 909 910 Generally the situation is similar to the one described for close(). In 911 practice it is a bit, though, since directory cookies are exclusively used 912 for directory iteration, and it normally doesn't make sense to have multiple 913 threads read the same directory concurrently. Furthermore reading a directory 914 should not block. Therefore for most FSs this hook is a no-op. 915 916 \param fs The volume handle. 917 \param vnode The node handle. 918 \param cookie The directory cookie as returned by open_dir(). 919 \return \c B_OK if everything went fine, another error code otherwise. 920*/ 921 922/*! 923 \fn status_t (*file_system_module_info::free_dir_cookie)(fs_volume fs, 924 fs_vnode vnode, fs_cookie cookie) 925 \brief Frees the given directory cookie. 926 927 The hook is invoked after close_dir(), when no other thread uses or is going 928 to use the cookie. All resources associated with the cookie must be freed. 929 930 \param fs The volume handle. 931 \param vnode The node handle. 932 \param cookie The directory cookie as returned by open_dir(). 933 \return \c B_OK if everything went fine, another error code otherwise. 934*/ 935 936/*! 937 \fn status_t (*file_system_module_info::read_dir)(fs_volume fs, fs_vnode vnode, 938 fs_cookie cookie, struct dirent *buffer, size_t bufferSize, uint32 *_num) 939 \brief Reads the next one or more directory entries. 940 941 The number of entries to be read at maximum is stored in the variable \a _num 942 points to. 943 944 Per read \c dirent the following fields have to be filled in: 945 - \c d_dev: The volume ID. 946 - \c d_ino: The ID of the node the entry refers to. 947 - \c d_name: The null-terminated name of the entry. 948 - \c d_reclen: The size of the \c dirent structure in bytes, starting from 949 the beginning of the structure, counting all bytes up to and including 950 the null-termination char of the name stored in \c d_name. 951 952 If more than one entry is read, the corresponding \c dirent structures are 953 tightly packed, i.e. the second entry begins directly after the end of the 954 first one (i.e. \c d_reclen bytes after the beginning of the first one). 955 Most FSs read only one entry at a time though, even if more are requested. 956 957 When the function is invoked after the end of the directory has been reached, 958 it shall set the variable \a _num points to to \c 0 and return \c B_OK. If 959 the provided buffer is too small to contain even the single next entry, 960 \c B_BUFFER_OVERFLOW shall be returned. It shall not fail, if at least one 961 entry has been read, and the buffer is just too small to hold as many entries 962 as requested. 963 964 Note that a directory is expected to contain the special entries \c "." and 965 \c "..", referring to the same directory and the parent directory 966 respectively. The \c dirent structure returned for the \c ".." entry of the 967 volume's root directory shall refer to the root node itself. 968 969 \param fs The volume handle. 970 \param vnode The node handle. 971 \param cookie The directory cookie as returned by open_dir(). 972 \param buffer Pointer to a pre-allocated buffer the directory entries shall 973 be written to. 974 \param bufferSize The size of \a buffer in bytes. 975 \param _num Pointer to a pre-allocated variable, when invoked, containing the 976 number of directory entries to be read, and into which the number of 977 entries actually read shall be written. 978 \return \c B_OK if everything went fine, another error code otherwise. 979*/ 980 981/*! 982 \fn status_t (*file_system_module_info::rewind_dir)(fs_volume fs, 983 fs_vnode vnode, fs_cookie cookie) 984 \brief Resets the directory cookie to the first entry of the directory. 985 \param fs The volume handle. 986 \param vnode The node handle. 987 \param cookie The directory cookie as returned by open_dir(). 988 \return \c B_OK if everything went fine, another error code otherwise. 989*/ 990 991//! @} 992 993/*! 994 \name Attribute Directory Operations 995*/ 996 997//! @{ 998 999/*! 1000 \fn status_t (*file_system_module_info::open_attr_dir)(fs_volume fs, fs_vnode 1001 vnode, fs_cookie *_cookie) 1002 \brief Open a 'directory' of attributes for a \a vnode. 1003 1004 See \ref concepts "Generic Concepts" on directories and iterators. Basically, 1005 the VFS uses the same way of traversing through attributes as it traverses 1006 through a directory. 1007 1008 \param fs The file system provided cookie to the volume. 1009 \param vnode The vnode on which the file system wants to read the attributes. 1010 \param[out] _cookie Pointer where the file system can store a directory 1011 cookie if the attribute directory is succesfully opened. 1012 \return \c B_OK if everything went fine, another error code otherwise. 1013*/ 1014 1015/*! 1016 \fn status_t (*file_system_module_info::close_attr_dir)(fs_volume fs, 1017 fs_vnode vnode, fs_cookie cookie) 1018 \brief Close a 'directory' of attributes for a \a vnode. 1019 1020 Note that you should free the cookie in the free_attr_dir_cookie() call. 1021 1022 \param fs The file system provided cookie to the volume. 1023 \param vnode The vnode on which the 'directory' was opened. 1024 \param cookie The cookie associated with this 'directory'. 1025 \return \c B_OK if everything went fine, another error code otherwise. 1026*/ 1027 1028/*! 1029 \fn status_t (*file_system_module_info::free_attr_dir_cookie)(fs_volume fs, 1030 fs_vnode vnode, fs_cookie cookie) 1031 \brief Free the \a cookie to an attribute 'directory'. 1032 1033 \param fs The file system provided cookie to the volume. 1034 \param vnode The vnode on which the 'directory' was opened. 1035 \param cookie The cookie associated that should be freed. 1036 \return \c B_OK if everything went fine, another error code otherwise. 1037*/ 1038 1039/*! 1040 \fn status_t (*file_system_module_info::read_attr_dir)(fs_volume fs, fs_vnode 1041 vnode, fs_cookie cookie, struct dirent *buffer, size_t bufferSize, 1042 uint32 *_num) 1043 \brief Read the next one or more attribute directory entries. 1044 1045 This method should perform the same tasks as read_dir(), except that the '.' 1046 and '..' entries do not have to be present. 1047*/ 1048 1049/*! 1050 \fn status_t (*file_system_module_info::rewind_attr_dir)(fs_volume fs, 1051 fs_vnode vnode, fs_cookie cookie) 1052 \brief Rewind the attribute directory iterator to the first entry. 1053 1054 \param fs The file system provided cookie to the volume. 1055 \param vnode The vnode on which the 'directory' was opened. 1056 \param cookie The cookie associated with this 'directory'. 1057 \return \c B_OK if everything went fine, another error code otherwise. 1058*/ 1059 1060//! @} 1061 1062/*! 1063 \name Attribute Operations 1064*/ 1065 1066//! @{ 1067 1068/*! 1069 \fn status_t (*file_system_module_info::create_attr)(fs_volume fs, fs_vnode 1070 vnode, const char *name, uint32 type, int openMode, fs_cookie *_cookie) 1071 \brief Create a new attribute. 1072 1073 If the attribute already exists, you should open it in truncated mode. 1074 1075 \param fs The file system provided cookie to the volume. 1076 \param vnode The file system provided cookie to the vnode. 1077 \param name The name of the attribute. 1078 \param type The \c type_code of the attribute. 1079 \param openMode The openMode of the associated attribute. 1080 \param[out] _cookie A pointer where you can store an associated file system 1081 cookie. 1082 \return \c B_OK if everything went fine, another error code otherwise. 1083*/ 1084 1085/*! 1086 \fn status_t (*file_system_module_info::open_attr)(fs_volume fs, fs_vnode 1087 vnode, const char *name, int openMode, fs_cookie *_cookie) 1088 \brief Open an existing attribute. 1089 1090 \param fs The file system provided cookie to the volume. 1091 \param vnode The file system provided cookie to the vnode. 1092 \param name The name of the attribute. 1093 \param openMode The mode in which you want to open the attribute data. 1094 \param[out] _cookie A pointer where you can store an associated file system 1095 cookie. 1096 \return \c B_OK if everything went fine, another error code otherwise. 1097*/ 1098 1099/*! 1100 \fn status_t (*file_system_module_info::close_attr)(fs_volume fs, fs_vnode 1101 vnode, fs_cookie cookie) 1102 \brief Close access to an attribute. 1103 1104 Note that you should not delete the cookie yet, you should do that when the 1105 VFS calls free_attr_cookie(). 1106 1107 \param fs The file system provided cookie to the volume. 1108 \param vnode The file system provided cookie to the vnode. 1109 \param cookie The cookie you associated to this attribute. 1110 \return \c B_OK if everything went fine, another error code otherwise. 1111*/ 1112 1113/*! 1114 \fn status_t (*file_system_module_info::free_attr_cookie)(fs_volume fs, 1115 fs_vnode vnode, fs_cookie cookie) 1116 \brief Free the cookie of an attribute. 1117 1118 The VFS calls this hook when all operations on the attribute have ceased. 1119 1120 \param fs The file system provided cookie to the volume. 1121 \param vnode The file system provided cookie to the vnode. 1122 \param cookie The cookie to the attribute that should be freed. 1123 \return \c B_OK if everything went fine, another error code otherwise. 1124*/ 1125 1126/*! 1127 \fn status_t (*file_system_module_info::read_attr)(fs_volume fs, fs_vnode 1128 vnode, fs_cookie cookie, off_t pos, void *buffer, size_t *length) 1129 \brief Read attribute data associated with \a cookie. 1130 1131 Read until the \a buffer with size \a length is full, or until you are out of 1132 data, in which case you should update \a length. 1133 1134 \param fs The file system provided cookie to the volume. 1135 \param vnode The file system provided cookie to the vnode. 1136 \param cookie The cookie you associated to this attribute. 1137 \param pos The position to start reading from. 1138 \param buffer The buffer the data should be copied in. 1139 \param length The length of the buffer. Update this variable to the actual 1140 amount of bytes read. 1141 \return \c B_OK if everything went fine, another error code otherwise. 1142*/ 1143 1144/*! 1145 \fn status_t (*file_system_module_info::write_attr)(fs_volume fs, fs_vnode 1146 vnode, fs_cookie cookie, off_t pos, const void *buffer, size_t *length) 1147 \brief Write attribute data associated with \a cookie. 1148 1149 \param fs The file system provided cookie to the volume. 1150 \param vnode The file system provided cookie to the vnode. 1151 \param cookie The cookie you associated with this attribute. 1152 \param pos The position to start writing to. 1153 \param buffer The buffer the data should be copied from. 1154 \param length The size of the buffer. Update this variable to the actual 1155 amount of bytes written. 1156 \return \c B_OK if everything went fine, another error code otherwise. 1157*/ 1158 1159/*! 1160 \fn status_t (*file_system_module_info::read_attr_stat)(fs_volume fs, 1161 fs_vnode vnode, fs_cookie cookie, struct stat *stat) 1162 \brief Get the stats for an attribute. 1163 1164 \param fs The file system provided cookie to the volume. 1165 \param vnode The file system provided cookie to the vnode. 1166 \param cookie The cookie you associated with this attribute. 1167 \param stat A pointer to a stat structure you should fill. 1168 \return \c B_OK if everything went fine, another error code otherwise. 1169*/ 1170 1171/*! 1172 \fn status_t (*file_system_module_info::write_attr_stat)(fs_volume fs, 1173 fs_vnode vnode, fs_cookie cookie, const struct stat *stat, int statMask) 1174 \brief Update the stats of an attribute. 1175 1176 \param fs The file system provided cookie to the volume. 1177 \param vnode The file system provided cookie to the vnode. 1178 \param cookie The cookie you associated with this attribute. 1179 \param stat A pointer to the new stats you should write. 1180 \param statMask One or more of the values of #write_stat_mask that tell you 1181 which fields of \a stat are to be updated. 1182 \return \c B_OK if everything went fine, another error code otherwise. 1183*/ 1184 1185/*! 1186 \fn status_t (*file_system_module_info::rename_attr)(fs_volume fs, 1187 fs_vnode fromVnode, const char *fromName, fs_vnode toVnode, 1188 const char *toName) 1189 \brief Rename and/or relocate an attribute. 1190 1191 You should make sure the user has the proper permissions. 1192 1193 \param fs The file system provided cookie associated with this volume. 1194 \param fromVnode The cookie associated with the vnode the attribute currently 1195 is related to. 1196 \param fromName The old name of the attribute. 1197 \param toVnode The cookie associated with the vnode the attribute should be 1198 moved to. This can be the same as \a fromVnode, in which case it only means 1199 the attribute should be renamed. 1200 \param toName The new name of the attribute.This can be the same as 1201 \a fromName, in which case it only means the attribute should be relocated. 1202 \retval B_OK The renaming and/or relocating succeeded. 1203 \retval B_BAD_VALUE One of the supplied parameters were invalid. 1204 \retval B_NOT_ALLOWED The user does not have the proper permissions. 1205 \retval "other errors" Another error condition was encountered. 1206*/ 1207 1208/*! 1209 \fn status_t (*file_system_module_info::remove_attr)(fs_volume fs, 1210 fs_vnode vnode, const char *name) 1211 \brief Remove an attribute. 1212 1213 \param fs The file system provided cookie to the volume. 1214 \param vnode The file system provided cookie to the vnode. 1215 \param name The name of the attribute. 1216 \return \c B_OK if everything went fine, another error code otherwise. 1217*/ 1218 1219//! @} 1220 1221/*! 1222 \name Index Directory and Operation 1223*/ 1224 1225//! @{ 1226 1227/*! 1228 \fn status_t (*file_system_module_info::open_index_dir)(fs_volume fs, 1229 fs_cookie *_cookie) 1230 \brief Open the list of an indeces as a directory. 1231 1232 See \ref concepts "Generic Concepts" on directories and iterators. Basically, 1233 the VFS uses the same way of traversing through indeces as it traverses 1234 through a directory. 1235 1236 \param fs The file system provided cookie to the volume. 1237 \param[out] _cookie Pointer where the file system can store a directory 1238 cookie if the index directory is succesfully opened. 1239 \return \c B_OK if everything went fine, another error code otherwise. 1240*/ 1241 1242/*! 1243 \fn status_t (*file_system_module_info::close_index_dir)(fs_volume fs, 1244 fs_cookie cookie) 1245 \brief Close a 'directory' of indeces. 1246 1247 Note that you should free the cookie in the free_index_dir_cookie() call.: 1248 1249 \param fs The file system provided cookie to the volume. 1250 \param cookie The cookie associated with this 'directory'. 1251 \return B_OK if everything went fine, another error code otherwise. 1252*/ 1253 1254/*! 1255 \fn status_t (*file_system_module_info::free_index_dir_cookie)(fs_volume fs, 1256 fs_cookie cookie) 1257 \brief Free the \a cookie to the index 'directory'. 1258 1259 \param fs The file system provided cookie for the volume. 1260 \param cookie The cookie that should be freed. 1261 \return B_OK if everything went fine, another error code otherwise. 1262*/ 1263 1264/*! 1265 \fn status_t (*file_system_module_info::read_index_dir)(fs_volume fs, 1266 fs_cookie cookie, struct dirent *buffer, size_t bufferSize, uint32 *_num) 1267 \brief Read the next one or more index entries. 1268 1269 This method should perform the same task as read_dir(), except that the '.' 1270 and the '..' entries don't have to be present. 1271*/ 1272 1273/*! 1274 \fn status_t (*file_system_module_info::rewind_index_dir)(fs_volume fs, 1275 fs_cookie cookie) 1276 \brief Reset the index directory cookie to the first entry of the directory. 1277 1278 \param fs The file system provided handle to the volume. 1279 \param cookie The directory cookie as returned by open_index_dir(). 1280 \return \c B_OK if everything went fine, another error code otherwise. 1281*/ 1282 1283/*! 1284 \fn status_t (*file_system_module_info::create_index)(fs_volume fs, 1285 const char *name, uint32 type, uint32 flags) 1286 \brief Create a new index. 1287 1288 \param fs The file system provided handle to the volume. 1289 \param name The name of the new index. 1290 \param type The type of index. BFS implements the following types: 1291 - \c B_INT32_TYPE 1292 - \c B_UINT32_TYPE 1293 - \c B_INT64_TYPE 1294 - \c B_UINT64_TYPE 1295 - \c B_FLOAT_TYPE 1296 - \c B_DOUBLE_TYPE 1297 - \c B_STRING_TYPE 1298 - \c B_MIME_STRING_TYPE 1299 \param flags There are currently no extra flags specified. This parameter can 1300 be ignored. 1301 \return You should return \c B_OK if the creation succeeded, or return an 1302 error otherwise. 1303*/ 1304 1305/*! 1306 \fn status_t (*file_system_module_info::remove_index)(fs_volume fs, 1307 const char *name) 1308 \brief Remove the index with \a name. 1309 1310 \param fs The file system provided handle to the volume. 1311 \param name The name of the index to be removed. 1312 \return You should return \c B_OK if the creation succeeded, or return an 1313 error otherwise. 1314*/ 1315 1316/*! 1317 \fn status_t (*file_system_module_info::read_index_stat)(fs_volume fs, 1318 const char *name, struct stat *stat) 1319 \brief Read the \a stat of the index with a name. 1320 1321 \param fs The file system provided handle to the volume. 1322 \param name The name of the index to be queried. 1323 \param stat A pointer to a structure where you should store the values. 1324 \return You should return \c B_OK if the creation succeeded, or return an 1325 error otherwise. 1326*/ 1327 1328//! @} 1329 1330/*! 1331 \name Query Operations 1332*/ 1333 1334//! @{ 1335 1336/*! 1337 \fn status_t (*file_system_module_info::open_query)(fs_volume fs, 1338 const char *query, uint32 flags, port_id port, uint32 token, 1339 fs_cookie *_cookie) 1340 \brief Open a query as a 'directory'. 1341 1342 TODO: query expressions should be documented and also the format for sending 1343 query updates over the port should be updated. 1344 1345 See \ref concepts "Generic Concepts" on directories and iterators. Basically, 1346 the VFS uses the same way of traversing through indeces as it traverses 1347 through a directory. 1348 1349 \param fs The file system provided cookie to the volume. 1350 \param query The string that represents a query. 1351 \param flags Either one of these flags: 1352 - \c #B_LIVE_QUERY The query is live. When a query is live, it is 1353 constantly updated using the \a port. In this case the file system should 1354 be pro-active. 1355 - \c #B_QUERY_NON_INDEXED When this parameter is provided, the query 1356 should be carried out over the whole file system. This parameter is 1357 provided with the idea that sometimes the indeces can be out of date. If 1358 the requestor for this query requires absolutely everything to be 1359 queried, it will pass this parameter. Of course, if your indeces are 1360 always up to date, you can ignore this parameter. 1361 \param port The id of the port where updates need to be sent to in case the 1362 query is live. 1363 \param token A token that should be attached to the messages sent over the 1364 \a port. 1365 \param[out] _cookie The cookie that will be used as 'directory' to traverse 1366 through the results of the query. 1367 \return You should return \c B_OK if the creation succeeded, or return an 1368 error otherwise. 1369*/ 1370 1371/*! 1372 \fn status_t (*file_system_module_info::close_query)(fs_volume fs, 1373 fs_cookie cookie) 1374 \brief Close a 'directory' of a query. 1375 1376 Note that you should free the cookie in the free_query_cookie() call. 1377 1378 \param fs The file system provided cookie to the volume. 1379 \param cookie The cookie that refers to this query. 1380 \return You should return \c B_OK if the creation succeeded, or return an 1381 error otherwise. 1382*/ 1383 1384/*! 1385 \fn status_t (*file_system_module_info::free_query_cookie)(fs_volume fs, 1386 fs_cookie cookie) 1387 \brief Free a cookie of a query. 1388 1389 \param fs The file system provided cookie to the volume. 1390 \param cookie The cookie that should be freed. 1391 \return You should return \c B_OK if the creation succeeded, or return an 1392 error otherwise. 1393*/ 1394 1395/*! 1396 \fn status_t (*file_system_module_info::read_query)(fs_volume fs, 1397 fs_cookie cookie, struct dirent *buffer, size_t bufferSize, uint32 *_num) 1398 \brief Read the next one or more entries matching the query. 1399 1400 This hook function works pretty much the same way as read_dir(), with the 1401 difference that it doesn't read the entries of a directory, but the entries 1402 matching the given query. 1403 1404 \param fs The volume handle. 1405 \param cookie The query cookie as returned by open_query(). 1406 \param buffer Pointer to a pre-allocated buffer the directory entries shall 1407 be written to. 1408 \param bufferSize The size of \a buffer in bytes. 1409 \param _num Pointer to a pre-allocated variable, when invoked, containing the 1410 number of entries to be read, and into which the number of entries 1411 actually read shall be written. 1412 \return \c B_OK if everything went fine, another error code otherwise. 1413*/ 1414 1415/*! 1416 \fn status_t (*file_system_module_info::rewind_query)(fs_volume fs, 1417 fs_cookie cookie) 1418 \brief Reset the query cookie to the first entry of the results. 1419 1420 \param fs The file system provided handle to the volume. 1421 \param cookie The query cookie as returned by open_query(). 1422 \return \c B_OK if everything went fine, another error code otherwise. 1423*/ 1424 1425//! @} 1426 1427/*! 1428 \name Capability Querying 1429*/ 1430 1431//! @{ 1432 1433/*! 1434 \fn bool (*file_system_module_info::supports_defragmenting)(partition_data 1435 *partition, bool *whileMounted) 1436 \brief Undocumented. TODO. 1437*/ 1438 1439/*! 1440 \fn bool (*file_system_module_info::supports_repairing)(partition_data *partition, 1441 bool checkOnly, bool *whileMounted) 1442 \brief Undocumented. TODO. 1443*/ 1444 1445/*! 1446 \fn bool (*file_system_module_info::supports_resizing)(partition_data *partition, 1447 bool *whileMounted) 1448 \brief Undocumented. TODO. 1449*/ 1450 1451/*! 1452 \fn bool (*file_system_module_info::supports_moving)(partition_data *partition, bool *isNoOp) 1453 \brief Undocumented. TODO. 1454*/ 1455 1456/*! 1457 \fn bool (*file_system_module_info::supports_setting_content_name)(partition_data *partition, 1458 bool *whileMounted) 1459 \brief Undocumented. TODO. 1460*/ 1461 1462/*! 1463 \fn bool (*file_system_module_info::supports_setting_content_parameters)(partition_data *partition, 1464 bool *whileMounted) 1465 \brief Undocumented. TODO. 1466*/ 1467 1468/*! 1469 \fn bool (*file_system_module_info::supports_initializing)(partition_data *partition) 1470 \brief Undocumented. TODO. 1471*/ 1472 1473/*! 1474 \fn bool (*file_system_module_info::validate_resize)(partition_data *partition, off_t *size) 1475 \brief Undocumented. TODO. 1476*/ 1477 1478/*! 1479 \fn bool (*file_system_module_info::validate_move)(partition_data *partition, off_t *start) 1480 \brief Undocumented. TODO. 1481*/ 1482 1483/*! 1484 \fn bool (*file_system_module_info::validate_set_content_name)(partition_data *partition, 1485 char *name) 1486 \brief Undocumented. TODO. 1487*/ 1488 1489/*! 1490 \fn bool (*file_system_module_info::validate_set_content_parameters)(partition_data *partition, 1491 const char *parameters) 1492 \brief Undocumented. TODO. 1493*/ 1494 1495/*! 1496 \fn bool (*file_system_module_info::validate_initialize)(partition_data *partition, char *name, 1497 const char *parameters) 1498 \brief Undocumented. TODO. 1499*/ 1500 1501//! @} 1502 1503/*! 1504 \name Shadow Partition Modification 1505*/ 1506 1507//! @{ 1508 1509/*! 1510 \fn status_t (*file_system_module_info::shadow_changed)(partition_data *partition, 1511 uint32 operation) 1512 \brief Undocumented. TODO. 1513*/ 1514 1515//! @} 1516 1517/*! 1518 \name Special Operations 1519*/ 1520 1521//! @{ 1522 1523/*! 1524 \fn status_t (*file_system_module_info::defragment)(int fd, partition_id partition, 1525 disk_job_id job) 1526 \brief Undocumented. TODO. 1527*/ 1528 1529/*! 1530 \fn status_t (*file_system_module_info::repair)(int fd, partition_id partition, bool checkOnly, 1531 disk_job_id job) 1532 \brief Undocumented. TODO. 1533*/ 1534 1535/*! 1536 \fn status_t (*file_system_module_info::resize)(int fd, partition_id partition, off_t size, 1537 disk_job_id job) 1538 \brief Undocumented. TODO. 1539*/ 1540 1541/*! 1542 \fn status_t (*file_system_module_info::move)(int fd, partition_id partition, off_t offset, 1543 disk_job_id job) 1544 \brief Undocumented. TODO. 1545*/ 1546 1547/*! 1548 \fn status_t (*file_system_module_info::set_content_name)(int fd, partition_id partition, 1549 const char *name, disk_job_id job) 1550 \brief Undocumented. TODO. 1551*/ 1552 1553/*! 1554 \fn status_t (*file_system_module_info::set_content_parameters)(int fd, partition_id partition, 1555 const char *parameters, disk_job_id job) 1556 \brief Undocumented. TODO. 1557*/ 1558 1559/*! 1560 \fn status_t (*file_system_module_info::initialize)(const char *partition, const char *name, 1561 const char *parameters, disk_job_id job) 1562 \brief Undocumented. TODO. 1563*/ 1564 1565//! @} 1566 1567///// Global Functions ///// 1568 1569/*! 1570 \fn status_t new_vnode(mount_id mountID, vnode_id vnodeID, 1571 fs_vnode privateNode) 1572 \brief Create the vnode with ID \a vnodeID and associates it with the 1573 private data handle \a privateNode, but leaves is in an unpublished state. 1574 1575 The effect of the function is similar to publish_vnode(), but the vnode 1576 remains in an unpublished state, with the effect that a subsequent 1577 remove_vnode() will just delete the vnode and not invoke the file system's 1578 \link file_system_module_info::remove_vnode remove_vnode() \endlink is not 1579 invoked. 1580 1581 If the vnode shall be kept, publish_vnode() has to be invoked afterwards to 1582 mark the vnode published. The combined effect is the same as only invoking 1583 publish_vnode(). 1584 1585 The function fails, if the vnode does already exist. 1586 1587 \param mountID The ID of the volume. 1588 \param vnodeID The ID of the node. 1589 \param privateNode The private data handle to be associated with the node. 1590 \return \c B_OK if everything went fine, another error code otherwise. 1591*/ 1592 1593/*! 1594 \fn status_t publish_vnode(mount_id mountID, vnode_id vnodeID, 1595 fs_vnode privateNode) 1596 \brief Creates the vnode with ID \a vnodeID and associates it with the 1597 private data handle \a privateNode or just marks it published. 1598 1599 If the vnode does already exist and has been published, the function fails. 1600 If it has not been published yet (i.e. after a successful new_vnode()), the 1601 function just marks the vnode published. If the vnode did not exist at all 1602 before, it is created and published. 1603 1604 If the function is successful, the caller owns a reference to the vnode. A 1605 sequence of new_vnode() and publish_vnode() results in just one reference as 1606 well. The reference can be surrendered by calling put_vnode(). 1607 1608 \param mountID The ID of the volume. 1609 \param vnodeID The ID of the node. 1610 \param privateNode The private data handle to be associated with the node. 1611 \return \c B_OK if everything went fine, another error code otherwise. 1612*/ 1613 1614/*! 1615 \fn status_t get_vnode(mount_id mountID, vnode_id vnodeID, 1616 fs_vnode *_privateNode) 1617 \brief Retrieves the private data handle for the node with the given ID. 1618 1619 If the function is successful, the caller owns a reference to the vnode. The 1620 reference can be surrendered by calling put_vnode(). 1621 1622 \param mountID The ID of the volume. 1623 \param vnodeID The ID of the node. 1624 \param _privateNode Pointer to a pre-allocated variable the private data 1625 handle shall be written to. 1626 \return \c B_OK if everything went fine, another error code otherwise. 1627*/ 1628 1629/*! 1630 \fn status_t put_vnode(mount_id mountID, vnode_id vnodeID) 1631 \brief Surrenders a reference to the specified vnode. 1632 \param mountID The ID of the volume. 1633 \param vnodeID The ID of the node. 1634 \return \c B_OK if everything went fine, another error code otherwise. 1635*/ 1636 1637/*! 1638 \fn status_t remove_vnode(mount_id mountID, vnode_id vnodeID) 1639 \brief Marks the specified vnode removed. 1640 1641 The caller must own a reference to the vnode or at least ensure that a 1642 reference to the vnode exists. The function does not surrender a reference, 1643 though. 1644 1645 As soon as the last reference to the vnode has been surrendered, the VFS 1646 invokes the file system's 1647 \link file_system_module_info::remove_vnode remove_vnode() \endlink 1648 hook. 1649 1650 \param mountID The ID of the volume. 1651 \param vnodeID The ID of the node. 1652 \return \c B_OK if everything went fine, another error code otherwise. 1653*/ 1654 1655/*! 1656 \fn status_t unremove_vnode(mount_id mountID, vnode_id vnodeID); 1657 \brief Clears the "removed" mark of the specified vnode. 1658 1659 The caller must own a reference to the vnode or at least ensure that a 1660 reference to the vnode exists. 1661 1662 The function is usually called when the caller, who has invoked 1663 remove_vnode() before realizes that it is not possible to remove the node 1664 (e.g. due to an error). 1665 1666 \param mountID The ID of the volume. 1667 \param vnodeID The ID of the node. 1668 \return \c B_OK if everything went fine, another error code otherwise. 1669*/ 1670 1671/*! 1672 \fn status_t get_vnode_removed(mount_id mountID, vnode_id vnodeID, 1673 bool* removed); 1674 \brief Returns whether the specified vnode is marked removed. 1675 1676 The caller must own a reference to the vnode or at least ensure that a 1677 reference to the vnode exists. 1678 1679 \param mountID The ID of the volume. 1680 \param vnodeID The ID of the node. 1681 \param removed Pointer to a pre-allocated variable set to \c true, if the 1682 node is marked removed, to \c false otherwise. 1683 \return \c B_OK if everything went fine, another error code otherwise. 1684*/ 1685 1686///// Deprecated Global Functions 1687 1688/*! 1689 \name Deprecated functions 1690 1691 The following list of functions should not be used, and could be removed even 1692 before the release of Haiku R1. 1693*/ 1694 1695//! @{ 1696 1697/*! 1698 \fn status_t notify_listener(int op, mount_id device, vnode_id parentNode, 1699 vnode_id toParentNode, vnode_id node, const char *name) 1700 \brief Deprecated. This feature will be removed in future versions. 1701*/ 1702 1703/*! 1704 \fn status_t notify_entry_created(mount_id device, vnode_id directory, 1705 const char *name, vnode_id node) 1706 \brief Deprecated. This feature will be removed in future versions. 1707*/ 1708 1709/*! 1710 \fn status_t notify_entry_removed(mount_id device, vnode_id directory, 1711 const char *name, vnode_id node) 1712 \brief Deprecated. This feature will be removed in future versions. 1713*/ 1714 1715/*! 1716 \fn status_t notify_entry_moved(mount_id device, vnode_id fromDirectory, 1717 const char *fromName, vnode_id toDirectory, 1718 const char *toName, vnode_id node) 1719 \brief Deprecated. This feature will be removed in future versions. 1720*/ 1721 1722/*! 1723 \fn status_t notify_stat_changed(mount_id device, vnode_id node, 1724 uint32 statFields) 1725 \brief Deprecated. This feature will be removed in future versions. 1726*/ 1727 1728/*! 1729 \fn status_t notify_attribute_changed(mount_id device, vnode_id node, 1730 const char *attribute, int32 cause) 1731 \brief Deprecated. This feature will be removed in future versions. 1732*/ 1733 1734/*! 1735 \fn status_t notify_query_entry_created(port_id port, int32 token, 1736 mount_id device, vnode_id directory, const char *name, 1737 vnode_id node) 1738 \brief Deprecated. This feature will be removed in future versions. 1739*/ 1740 1741/*! 1742 \fn status_t notify_query_entry_removed(port_id port, int32 token, 1743 mount_id device, vnode_id directory, const char *name, 1744 vnode_id node) 1745 \brief Deprecated. This feature will be removed in future versions. 1746*/ 1747 1748//! @} 1749