Back to index

lshw  02.16
Public Member Functions | Public Attributes
sysfs_t Struct Reference
Collaboration diagram for sysfs_t:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 sysfs_t ()
 ~sysfs_t ()

Public Attributes

string path
bool temporary
bool has_sysfs

Detailed Description

Definition at line 32 of file sysfs.cc.


Constructor & Destructor Documentation

sysfs_t::sysfs_t ( ) [inline]

Definition at line 34 of file sysfs.cc.

           :path("/sys"),
    temporary(false),
    has_sysfs(false)
  {
    has_sysfs = exists(path + "/class/.");

    if (!has_sysfs)                               // sysfs doesn't seem to be mounted
// try to mount it in a temporary directory
    {
      char buffer[50];
      char *tmpdir = NULL;

      strncpy(buffer,
        "/var/tmp/sys-XXXXXX",
        sizeof(buffer));
      tmpdir = mkdtemp(buffer);

      if (tmpdir)
      {
        temporary = true;
        path = string(tmpdir);
        chmod(tmpdir,
          0000);                                  // to make clear it is a mount point
        mount("none",
          path.c_str(),
          "sysfs",
          0,
          NULL);
      }

      has_sysfs = exists(path + "/classes/.");
    }
  }

Here is the call graph for this function:

sysfs_t::~sysfs_t ( ) [inline]

Definition at line 68 of file sysfs.cc.

  {
    if (temporary)
    {
      umount(path.c_str());
      rmdir(path.c_str());
    }
  }

Member Data Documentation

Definition at line 79 of file sysfs.cc.

string sysfs_t::path

Definition at line 77 of file sysfs.cc.

Definition at line 78 of file sysfs.cc.


The documentation for this struct was generated from the following file: