mp-linux.cpp revision 5763f13421bf47d142d5165590170a5d991daede
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * IPRT - Multiprocessor, Linux.
4e8732935d428b2a70151b178a95cbba5d3839f5wrowe * Copyright (C) 2006-2008 Sun Microsystems, Inc.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * This file is part of VirtualBox Open Source Edition (OSE), as
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * available from http://www.virtualbox.org. This file is free software;
4e8732935d428b2a70151b178a95cbba5d3839f5wrowe * you can redistribute it and/or modify it under the terms of the GNU
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * General Public License (GPL) as published by the Free Software
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * Foundation, in version 2 as it comes in the "COPYING" file of the
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * The contents of this file may alternatively be used under the terms
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * of the Common Development and Distribution License Version 1.0
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
4e8732935d428b2a70151b178a95cbba5d3839f5wrowe * VirtualBox OSE distribution, in which case the provisions of the
4e8732935d428b2a70151b178a95cbba5d3839f5wrowe * CDDL are applicable instead of those of the GPL.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * You may elect to license modified versions of this file under the
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * terms and conditions of either the GPL or the CDDL or both.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * Clara, CA 95054 USA or visit http://www.sun.com if you need
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * additional information or have any questions.
4e8732935d428b2a70151b178a95cbba5d3839f5wrowe/*******************************************************************************
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding* Header Files *
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding*******************************************************************************/
4439ba95daf7b82794fe338726790e2dab89d119wrowe/** @todo move the rtLinuxSysFs* bits into sysfs.cpp and sysfs.h. */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * Checks if a sysfs file (or directory, device, symlink, whatever) exists.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @returns true / false, errno is preserved.
5ac28f3fe2417368757f29cf381338357605fd52wrowe * @param pszFormat The name format, without "/sys/".
5ac28f3fe2417368757f29cf381338357605fd52wrowe * @param va The format args.
4e8732935d428b2a70151b178a95cbba5d3839f5wrowebool rtLinuxSysFsExistsV(const char *pszFormat, va_list va)
9ec65cbae2f760e485a1c54df5b19853688d5c91wrowe * Construct the filename and call stat.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding static const size_t cchPrefix = sizeof("/sys/") - 1;
9ec65cbae2f760e485a1c54df5b19853688d5c91wrowe size_t cch = RTStrPrintfV(&szFilename[cchPrefix], sizeof(szFilename) - cchPrefix, pszFormat, va);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * Checks if a sysfs file (or directory, device, symlink, whatever) exists.
5ac28f3fe2417368757f29cf381338357605fd52wrowe * @returns true / false, errno is preserved.
5ac28f3fe2417368757f29cf381338357605fd52wrowe * @param pszFormat The name format, without "/sys/".
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @param ... The format args.
8c8173f49dd7122e10636b3d20ae841551bd0b43wrowe * Opens a sysfs file.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @returns The file descriptor. -1 and errno on failure.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @param pszFormat The name format, without "/sys/".
return fd;
return cchRead;
if (cchNum > 0)
else if (cchNum == 0)
return i64Ret;
return i64Ret;
return cMax;
return pSet;
return pSet;