VirtualBox

source: vbox/trunk/include/iprt/filesystem.h@ 40387

Last change on this file since 40387 was 40036, checked in by vboxsync, 13 years ago

Runtime: export new filesystem code.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.8 KB
Line 
1/** @file
2 * IPRT Filesystem API.
3 */
4
5/*
6 * Copyright (C) 2012 Oracle Corporation
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.virtualbox.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License (GPL) as published by the Free Software
12 * Foundation, in version 2 as it comes in the "COPYING" file of the
13 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15 *
16 * The contents of this file may alternatively be used under the terms
17 * of the Common Development and Distribution License Version 1.0
18 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
19 * VirtualBox OSE distribution, in which case the provisions of the
20 * CDDL are applicable instead of those of the GPL.
21 *
22 * You may elect to license modified versions of this file under the
23 * terms and conditions of either the GPL or the CDDL or both.
24 */
25
26#ifndef ___iprt_filesystem_h
27#define ___iprt_filesystem_h
28
29#include <iprt/types.h>
30
31RT_C_DECLS_BEGIN
32
33/** @defgroup grp_filesystem IPRT Filesystem
34 * @{
35 */
36
37/** Handle to a filesystem. */
38typedef struct RTFILESYSTEMINT *RTFILESYSTEM;
39/** A pointer to a filesystem handle. */
40typedef RTFILESYSTEM *PRTFILESYSTEM;
41/** NIL filesystem handle. */
42#define NIL_RTFILESYSTEM ((RTFILESYSTEM)~0)
43
44/**
45 * Callback to read data from the underlying medium of the filesystem.
46 *
47 * @returns IPRT status code.
48 * @param pvUser Opaque user data passed on creation.
49 * @param off Offset to start reading from.
50 * @param pvBuf Where to store the read data.
51 * @param cbRead How many bytes to read.
52 */
53typedef DECLCALLBACK(int) FNRTFILESYSTEMREAD(void *pvUser, uint64_t off, void *pvBuf, size_t cbRead);
54/** Pointer to a read callback. */
55typedef FNRTFILESYSTEMREAD *PFNRTFILESYSTEMREAD;
56
57/**
58 * Callback to write data to the underlying medium of the filesystem.
59 *
60 * @returns IPRT status code.
61 * @param pvUser Opaque user data passed on creation.
62 * @param off Offset to start writing to.
63 * @param pvBuf The data to write.
64 * @param cbRead How many bytes to write.
65 */
66typedef DECLCALLBACK(int) FNRTFILESYSTEMWRITE(void *pvUser, uint64_t off, const void *pvBuf, size_t cbWrite);
67/** Pointer to a read callback. */
68typedef FNRTFILESYSTEMWRITE *PFNRTFILESYSTEMWRITE;
69
70/**
71 * Probes for and opens a filesystem from the given medium.
72 *
73 * @returns IPRT status code.
74 * @retval VERR_NOT_SUPPORTED if the filesystem on the given medium is unsupported.
75 * @param phFs Where to store the handle to the filesystem object on success.
76 * @param pfnRead Read callback for the medium.
77 * @param pfnWrite Write callback for the medium.
78 * @param cbMedium Size of the whole medium.
79 * @param cbSector Size of one sector on the medium.
80 * @param pvUser Opaque user data used in the read/write callbacks.
81 * @param fFlags Flags to open the filesystem with.
82 */
83RTDECL(int) RTFilesystemOpen(PRTFILESYSTEM phFs, PFNRTFILESYSTEMREAD pfnRead,
84 PFNRTFILESYSTEMWRITE pfnWrite, uint64_t cbMedium,
85 uint64_t cbSector, void *pvUser, uint32_t fFlags);
86
87/**
88 * Retain a given filesystem object.
89 *
90 * @returns New reference count on success, UINT32_MAX on failure.
91 * @param hFs The filesystem object handle.
92 */
93RTDECL(uint32_t) RTFilesystemRetain(RTFILESYSTEM hFs);
94
95/**
96 * Releases a given volume manager.
97 *
98 * @returns New reference count on success (0 if closed), UINT32_MAX on failure.
99 * @param hFs The filesystem object handle.
100 */
101RTDECL(uint32_t) RTFilesystemRelease(RTFILESYSTEM hFs);
102
103/**
104 * Returns the format name of the used filesystem.
105 *
106 * @returns Name of the filesystem format used.
107 * @param hFs The filesystem object handle.
108 */
109RTDECL(const char *) RTFilesystemGetFormat(RTFILESYSTEM hFs);
110
111/**
112 * Returns the smallest accessible unit of the filesystem.
113 *
114 * @returns Block size of the given filesystem or 0 on failure.
115 * @param hFs The filesystem object handle.
116 */
117RTDECL(uint64_t) RTFilesystemGetBlockSize(RTFILESYSTEM hFs);
118
119/**
120 * Queries whether the given range on the medium is used by the filesystem.
121 *
122 * @returns IPRT status code.
123 * @param hFs The filesystem object handle.
124 * @param offStart The start offset on the medium to check for.
125 * @param cb Size of the range to check for.
126 * @param pfUsed Where to store whether the range is in use by the filesystem
127 * on success.
128 */
129RTDECL(int) RTFilesystemQueryRangeUse(RTFILESYSTEM hFs, uint64_t offStart,
130 size_t cb, bool *pfUsed);
131
132/** @} */
133
134RT_C_DECLS_END
135
136#endif /* !___iprt_filesystem_h */
137
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette