Changeset 60373 in vbox for trunk/include/iprt
- Timestamp:
- Apr 7, 2016 2:21:30 PM (9 years ago)
- svn:sync-xref-src-repo-rev:
- 106457
- Location:
- trunk/include/iprt
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/linux/sysfs.h
r57004 r60373 5 5 6 6 /* 7 * Copyright (C) 2008-201 5Oracle Corporation7 * Copyright (C) 2008-2016 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 44 44 * Checks if a sysfs file (or directory, device, symlink, whatever) exists. 45 45 * 46 * @returns true / false, errno is preserved. 46 * @returns true if the sysfs object exists. 47 * false otherwise or if an error occurred. 47 48 * @param pszFormat The name format, either absolute or relative to "/sys/". 48 49 * @param va The format args. … … 51 52 52 53 /** 54 * Checks if a sysfs object (directory, device, symlink, whatever) exists. 55 * 56 * @returns IPRT status code. 57 * @retval VINF_SUCCESS if the sysfs object exists. 58 * @retval VERR_FILE_NOT_FOUND if the sysfs object does not exist. 59 * @param pszFormat The name format, either absolute or relative to "/sys/". 60 * @param va The format args. 61 */ 62 RTDECL(int) RTLinuxSysFsExistsExV(const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(1, 0); 63 64 /** 53 65 * Checks if a sysfs file (or directory, device, symlink, whatever) exists. 54 66 * 55 * @returns true / false, errno is preserved. 67 * @returns true if the sysfs object exists. 68 * false otherwise or if an error occurred. 56 69 * @param pszFormat The name format, either absolute or relative to "/sys/". 57 70 * @param ... The format args. … … 60 73 61 74 /** 75 * Checks if a sysfs object (directory, device, symlink, whatever) exists. 76 * 77 * @returns IPRT status code. 78 * @retval VINF_SUCCESS if the sysfs object exists. 79 * @retval VERR_FILE_NOT_FOUND if the sysfs object does not exist. 80 * @param pszFormat The name format, either absolute or relative to "/sys/". 81 * @param ... The format args. 82 */ 83 RTDECL(int) RTLinuxSysFsExistsEx(const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2); 84 85 /** 62 86 * Opens a sysfs file. 63 87 * 64 * @returns The file descriptor. -1 and errno on failure. 88 * @returns IPRT status code. 89 * @param phFile Where to store the file handle on success. 65 90 * @param pszFormat The name format, either absolute or relative to "/sys/". 66 91 * @param va The format args. 67 */ 68 RTDECL(int) RTLinuxSysFsOpenV(const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(1, 0); 92 * 93 * @note Close the file using RTFileClose(). 94 */ 95 RTDECL(int) RTLinuxSysFsOpenV(PRTFILE phFile, const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(1, 0); 69 96 70 97 /** 71 98 * Opens a sysfs file. 72 99 * 73 * @returns The file descriptor. -1 and errno on failure. 100 * @returns IPRT status code. 101 * @param phFile Where to store the file handle on success. 74 102 * @param pszFormat The name format, either absolute or relative to "/sys/". 75 103 * @param ... The format args. 76 */ 77 RTDECL(int) RTLinuxSysFsOpen(const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2); 78 79 /** 80 * Closes a file opened with RTLinuxSysFsOpen or RTLinuxSysFsOpenV. 81 * 82 * @param fd File descriptor returned by RTLinuxSysFsOpen or 83 * RTLinuxSysFsOpenV. 84 */ 85 RTDECL(void) RTLinuxSysFsClose(int fd); 104 * 105 * @note Close the file using RTFileClose(). 106 */ 107 RTDECL(int) RTLinuxSysFsOpen(PRTFILE phFile, const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2); 86 108 87 109 /** 88 110 * Reads a string from a file opened with RTLinuxSysFsOpen or RTLinuxSysFsOpenV. 89 111 * 90 * @returns The number of bytes read. -1 and errno on failure.91 * @param fdThe file descriptor returned by RTLinuxSysFsOpen or RTLinuxSysFsOpenV.112 * @returns IPRT status code. 113 * @param hFile The file descriptor returned by RTLinuxSysFsOpen or RTLinuxSysFsOpenV. 92 114 * @param pszBuf Where to store the string. 93 115 * @param cchBuf The size of the buffer. Must be at least 2 bytes. 94 */ 95 RTDECL(ssize_t) RTLinuxSysFsReadStr(int fd, char *pszBuf, size_t cchBuf); 116 * @param pcchRead Where to store the amount of characters read on success - optional. 117 */ 118 RTDECL(int) RTLinuxSysFsReadStr(RTFILE hFile, char *pszBuf, size_t cchBuf, size_t *pcchRead); 96 119 97 120 /** … … 100 123 * 101 124 * @returns IPRT status code. 102 * @param fdThe file descriptor returned by RTLinuxSysFsOpen or RTLinuxSysFsOpenV.125 * @param hFile The file descriptor returned by RTLinuxSysFsOpen or RTLinuxSysFsOpenV. 103 126 * @param pvBuf Where to store the bits from the file. 104 127 * @param cbBuf The size of the buffer. 105 128 * @param pcbRead Where to return the number of bytes read. Optional. 106 129 */ 107 RTDECL(int) RTLinuxSysFsReadFile( int fd, void *pvBuf, size_t cbBuf, size_t *pcbRead);130 RTDECL(int) RTLinuxSysFsReadFile(RTFILE hFile, void *pvBuf, size_t cbBuf, size_t *pcbRead); 108 131 109 132 /** 110 133 * Reads a number from a sysfs file. 111 134 * 112 * @returns 64-bit signed value on success, -1 and errno on failure.135 * @returns IPRT status code. 113 136 * @param uBase The number base, 0 for autodetect. 137 * @param pi64 Where to store the 64-bit signed on success. 114 138 * @param pszFormat The filename format, either absolute or relative to "/sys/". 115 139 * @param va Format args. 116 140 */ 117 RTDECL(int 64_t) RTLinuxSysFsReadIntFileV(unsigned uBase, const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(2, 0);141 RTDECL(int) RTLinuxSysFsReadIntFileV(unsigned uBase, int64_t *pi64, const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(2, 0); 118 142 119 143 /** 120 144 * Reads a number from a sysfs file. 121 145 * 122 * @returns 64-bit signed value on success, -1 and errno on failure.146 * @returns IPRT status code. 123 147 * @param uBase The number base, 0 for autodetect. 124 * @param pszFormat The filename format, either absolute or relative to "/sys/". 125 * @param ... Format args. 126 */ 127 RTDECL(int64_t) RTLinuxSysFsReadIntFile(unsigned uBase, const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(2, 3); 148 * @param pi64 Where to store the 64-bit signed on success. 149 * @param pszFormat The filename format, either absolute or relative to "/sys/". 150 * @param ... Format args. 151 */ 152 RTDECL(int) RTLinuxSysFsReadIntFile(unsigned uBase, int64_t *pi64, const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(2, 3); 128 153 129 154 /** 130 155 * Reads a device number from a sysfs file. 131 156 * 132 * @returns device number on success, 0 and errno on failure. 157 * @returns IPRT status code. 158 * @param pDevNum Where to store the device number on success. 133 159 * @param pszFormat The filename format, either absolute or relative to "/sys/". 134 160 * @param va Format args. 135 161 */ 136 RTDECL( dev_t) RTLinuxSysFsReadDevNumFileV(const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(1, 0);162 RTDECL(int) RTLinuxSysFsReadDevNumFileV(dev_t *pDevNum, const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(1, 0); 137 163 138 164 /** 139 165 * Reads a device number from a sysfs file. 140 166 * 141 * @returns device number on success, 0 and errno on failure. 142 * @param pszFormat The filename format, either absolute or relative to "/sys/". 143 * @param ... Format args. 144 */ 145 RTDECL(dev_t) RTLinuxSysFsReadDevNumFile(const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2); 167 * @returns IPRT status code. 168 * @param pDevNum Where to store the device number on success. 169 * @param pszFormat The filename format, either absolute or relative to "/sys/". 170 * @param ... Format args. 171 */ 172 RTDECL(int) RTLinuxSysFsReadDevNumFile(dev_t *pDevNum, const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2); 146 173 147 174 /** … … 149 176 * return the text up until there. 150 177 * 151 * @returns number of characters read on success, -1 and errno on failure. 152 * @param pszBuf Where to store the path element. Must be at least two 153 * characters, but a longer buffer would be advisable. 154 * @param cchBuf The size of the buffer pointed to by @a pszBuf. 178 * @returns IPRT status code. 179 * @param pszBuf Where to store the path element. Must be at least two 180 * characters, but a longer buffer would be advisable. 181 * @param cchBuf The size of the buffer pointed to by @a pszBuf. 182 * @param pcchRead Where to store the amount of characters read on success - optional. 155 183 * @param pszFormat The filename format, either absolute or relative to "/sys/". 156 184 * @param va Format args. 157 185 */ 158 RTDECL( ssize_t) RTLinuxSysFsReadStrFileV(char *pszBuf, size_t cchBuf, const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(3, 0);186 RTDECL(int) RTLinuxSysFsReadStrFileV(char *pszBuf, size_t cchBuf, size_t *pcchRead, const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(3, 0); 159 187 160 188 /** … … 162 190 * return the text up until there. 163 191 * 164 * @returns number of characters read on success, -1 and errno on failure. 165 * @param pszBuf Where to store the path element. Must be at least two 166 * characters, but a longer buffer would be advisable. 167 * @param cchBuf The size of the buffer pointed to by @a pszBuf. 168 * @param pszFormat The filename format, either absolute or relative to "/sys/". 169 * @param ... Format args. 170 */ 171 RTDECL(ssize_t) RTLinuxSysFsReadStrFile(char *pszBuf, size_t cchBuf, const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(3, 4); 192 * @returns IPRT status code. 193 * @param pszBuf Where to store the path element. Must be at least two 194 * characters, but a longer buffer would be advisable. 195 * @param cchBuf The size of the buffer pointed to by @a pszBuf. 196 * @param pcchRead Where to store the amount of characters read on success - optional. 197 * @param pszFormat The filename format, either absolute or relative to "/sys/". 198 * @param ... Format args. 199 */ 200 RTDECL(int) RTLinuxSysFsReadStrFile(char *pszBuf, size_t cchBuf, size_t *pcchRead, const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(3, 4); 172 201 173 202 /** … … 179 208 * directory. 180 209 * 181 * @returns The length of the returned string on success, -1 and errno on182 * failure.183 * @param pszBuf Where to store the path element. Must be at least two184 * characters, but a longer buffer would be advisable.185 * @param cchBuf The size of the buffer pointed to by @a pszBuf.210 * @returns IPRT status code. 211 * @param pszBuf Where to store the path element. Must be at least two 212 * characters, but a longer buffer would be advisable. 213 * @param cchBuf The size of the buffer pointed to by @a pszBuf. 214 * @param pchBuf Where to store the length of the returned string on success - optional. 186 215 * @param pszFormat The filename format, either absolute or relative to "/sys/". 187 216 * @param va Format args. 188 217 */ 189 RTDECL( ssize_t) RTLinuxSysFsGetLinkDestV(char *pszBuf, size_t cchBuf, const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(3, 0);218 RTDECL(int) RTLinuxSysFsGetLinkDestV(char *pszBuf, size_t cchBuf, size_t *pchBuf, const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(3, 0); 190 219 191 220 /** … … 197 226 * directory. 198 227 * 199 * @returns The length of the returned string on success, -1 and errno on200 * failure.201 * @param pszBuf Where to store the path element. Must be at least two202 * characters, but a longer buffer would be advisable.203 * @param cchBuf The size of the buffer pointed to by @a pszBuf.204 * @param pszFormat The filename format, either absolute or relative to "/sys/". 205 * @param ... Format args. 206 */ 207 RTDECL( ssize_t) RTLinuxSysFsGetLinkDest(char *pszBuf, size_t cchBuf, const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(3, 4);228 * @returns IPRT status code. 229 * @param pszBuf Where to store the path element. Must be at least two 230 * characters, but a longer buffer would be advisable. 231 * @param cchBuf The size of the buffer pointed to by @a pszBuf. 232 * @param pchBuf Where to store the length of the returned string on success - optional. 233 * @param pszFormat The filename format, either absolute or relative to "/sys/". 234 * @param ... Format args. 235 */ 236 RTDECL(int) RTLinuxSysFsGetLinkDest(char *pszBuf, size_t cchBuf, size_t *pchBuf, const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(3, 4); 208 237 209 238 /** … … 211 240 * pattern and store the path into @a pszBuf. 212 241 * 213 * @returns The length of the returned string on success, -1 and errno on 214 * failure. 215 * @returns -1 and ENOENT if no matching device node could be found. 242 * @returns IPRT status code. 243 * @retval VERR_FILE_NOT_FOUND if no matching device node could be found. 216 244 * @param DevNum The device number to search for. 217 245 * @param fMode The type of device - only RTFS_TYPE_DEV_CHAR and … … 223 251 * @param va Format args. 224 252 */ 225 RTDECL( ssize_t) RTLinuxCheckDevicePathV(dev_t DevNum, RTFMODE fMode, char *pszBuf, size_t cchBuf,226 253 RTDECL(int) RTLinuxCheckDevicePathV(dev_t DevNum, RTFMODE fMode, char *pszBuf, size_t cchBuf, 254 const char *pszPattern, va_list va) RT_IPRT_FORMAT_ATTR(5, 0); 227 255 228 256 /** … … 230 258 * pattern and store the path into @a pszBuf. 231 259 * 232 * @returns The length of the returned string on success, -1 and errno on 233 * failure. 234 * @returns -1 and ENOENT if no matching device node could be found. 260 * @returns IPRT status code. 261 * @retval VERR_FILE_NOT_FOUND if no matching device node could be found. 235 262 * @param DevNum The device number to search for 236 263 * @param fMode The type of device - only RTFS_TYPE_DEV_CHAR and … … 242 269 * @param ... Format args. 243 270 */ 244 RTDECL( ssize_t) RTLinuxCheckDevicePath(dev_t DevNum, RTFMODE fMode, char *pszBuf, size_t cchBuf,245 271 RTDECL(int) RTLinuxCheckDevicePath(dev_t DevNum, RTFMODE fMode, char *pszBuf, size_t cchBuf, 272 const char *pszPattern, ...) RT_IPRT_FORMAT_ATTR(5, 6); 246 273 247 274 /** @} */ -
trunk/include/iprt/mangling.h
r60245 r60373 996 996 # define RTLinuxSysFsClose RT_MANGLER(RTLinuxSysFsClose) 997 997 # define RTLinuxSysFsExists RT_MANGLER(RTLinuxSysFsExists) 998 # define RTLinuxSysFsExistsEx RT_MANGLER(RTLinuxSysFsExistsEx) 999 # define RTLinuxSysFsExistsExV RT_MANGLER(RTLinuxSysFsExistsExV) 998 1000 # define RTLinuxSysFsExistsV RT_MANGLER(RTLinuxSysFsExistsV) 999 1001 # define RTLinuxSysFsGetLinkDest RT_MANGLER(RTLinuxSysFsGetLinkDest)
Note:
See TracChangeset
for help on using the changeset viewer.