sysfs.h revision c8278c7ae01edc83719fb99af38f040cc8c495ea
/* $Id$ */
/** @file
* sysfs.h - convenience routines for getting values from sysfs on Linux.
*/
/*
* Copyright (C) 2008 Sun Microsystems, Inc.
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* The contents of this file may alternatively be used under the terms
* of the Common Development and Distribution License Version 1.0
* (CDDL) only, as it comes in the "COPYING.CDDL" file of the
* VirtualBox OSE distribution, in which case the provisions of the
* CDDL are applicable instead of those of the GPL.
*
* You may elect to license modified versions of this file under the
* terms and conditions of either the GPL or the CDDL or both.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 USA or visit http://www.sun.com if you need
* additional information or have any questions.
*/
#ifndef ___VBox_sysfs_h
#define ___VBox_sysfs_h
/**
* Read a string value from a sysfs file.
* @returns iprt status value.
* @returns VERR_BUFFER_OVERFLOW if @a cbBuffer was not sufficient to hold the
* value.
* @param pszSysfsPath Path to the sysfs directory to be read from.
* @param pszFile Name of the file in @a pszSysfsPath to read the value
* from.
* @param pszBuffer Where to write the data read.
* @param cbBuffer The size of the buffer in @pszbuffer.
* @param pcbBufActual On success, the size of the data written. On buffer
* overflow the size of the buffer needed. Optional.
*/
{
int rc = VINF_SUCCESS;
char *pszFullName = NULL;
if (!FullName)
rc = VERR_NO_MEMORY;
if (RT_SUCCESS(rc))
if (RT_SUCCESS(rc))
/* Remove trailing newlines and zero-terminate */
if (pszBuffer[i] == '\n')
cbBufActual = i;
if (RT_SUCCESS(rc))
{
else
}
return rc;
}
/**
* Read a uint32 value from a sysfs file.
* @returns iprt status value.
* See also return codes from RTStrToUInt32Full().
* @param pszSysfsPath Path to the sysfs directory to be read from.
* @param pszFile Name of the file in @a pszSysfsPath to read the value
* from.
* @paramm uBase The base of the representation used.
* If this is zero, the function will look for known
* prefixes before defaulting to 10.
* @param pu32Value Where to store the value read.
*/
{
char szBuffer[256];
if (RT_SUCCESS(rc))
return rc;
}
#endif