VirtualBox

Changeset 23309 in vbox for trunk/include/iprt


Ignore:
Timestamp:
Sep 24, 2009 7:44:27 PM (15 years ago)
Author:
vboxsync
Message:

iprt/linux: add APIs for locating device nodes to sysfs APIs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/linux/sysfs.h

    r20374 r23309  
    3636#include <iprt/stdarg.h>
    3737
     38#include <sys/types.h>
    3839
    3940RT_C_DECLS_BEGIN
     
    119120
    120121/**
     122 * Reads a device number from a sysfs file.
     123 *
     124 * @returns device number on success, 0 and errno on failure.
     125 * @param   pszFormat   The filename format, either absolute or relative to "/sys/".
     126 * @param   va          Format args.
     127 */
     128RTDECL(dev_t) RTLinuxSysFsReadDevNumFileV(const char *pszFormat, va_list va);
     129
     130/**
     131 * Reads a device number from a sysfs file.
     132 *
     133 * @returns device number on success, 0 and errno on failure.
     134 * @param   pszFormat   The filename format, either absolute or relative to "/sys/".
     135 * @param   ...         Format args.
     136 */
     137RTDECL(dev_t) RTLinuxSysFsReadDevNumFile(const char *pszFormat, ...);
     138
     139/**
    121140 * Reads a string from a sysfs file.  If the file contains a newline, we only
    122141 * return the text up until there.
     
    178197RTDECL(ssize_t) RTLinuxSysFsGetLinkDest(char *pszBuf, size_t cchBuf, const char *pszFormat, ...);
    179198
     199/**
     200 * Find the path of a device node under /dev, given then device number.  This
     201 * function will recursively search under /dev until it finds a device node
     202 * matching @a devnum, and store the path into @a pszBuf.  The caller may
     203 * provide an expected path in pszSuggestion, which will be tried before
     204 * searching, but due to the variance in Linux systems it can be hard to always
     205 * correctly predict the path.
     206 *
     207 * @returns the number of characters written on success, -1 and errno on
     208 *          failure
     209 * @returns -1 and ENOENT if no matching device node could be found
     210 * @param  devNum         the device number to search for
     211 * @param  fMode          the type of device - only RTFS_TYPE_DEV_CHAR
     212 *                        and RTFS_TYPE_DEV_BLOCK are valid values
     213 * @param  pszBuf         where to store the path
     214 * @param  cchBuf         the size of the buffer
     215 * @param  pszSuggestion  the expected path format of the device node, either
     216 *                        absolute or relative to "/dev" (optional)
     217 * @param  va             Format args.
     218 */
     219RTDECL(ssize_t) RTLinuxFindDevicePathV(dev_t devNum, RTFMODE fMode, char *pszBuf, size_t cchBuf, const char *pszSuggestion, va_list va);
     220
     221/**
     222 * Find the path of a device node under /dev, given then device number.  This
     223 * function will recursively search under /dev until it finds a device node
     224 * matching @a devnum, and store the path into @a pszBuf.  The caller may
     225 * provide an expected path in pszSuggestion, which will be tried before
     226 * searching, but due to the variance in Linux systems it can be hard to always
     227 * correctly predict the path.
     228 *
     229 * @returns the number of characters written on success, -1 and errno on
     230 *          failure
     231 * @returns -1 and ENOENT if no matching device node could be found
     232 * @param  devNum         the device number to search for
     233 * @param  fMode          the type of device - only RTFS_TYPE_DEV_CHAR
     234 *                        and RTFS_TYPE_DEV_BLOCK are valid values
     235 * @param  pszBuf         where to store the path
     236 * @param  cchBuf         the size of the buffer
     237 * @param  pszSuggestion  the expected path format of the device node, either
     238 *                        absolute or relative to "/dev" (optional)
     239 * @param  ...            Format args.
     240 */
     241RTDECL(ssize_t) RTLinuxFindDevicePath(dev_t devNum, RTFMODE fMode, char *pszBuf, size_t cchBuf, const char *pszSuggestion, ...);
     242
    180243/** @} */
    181244
Note: See TracChangeset for help on using the changeset viewer.

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