Back to index

lshw  02.16
Functions
disk.h File Reference
#include "hw.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

bool scan_disk (hwNode &n)

Function Documentation

bool scan_disk ( hwNode n)

Definition at line 32 of file disk.cc.

{
  long size = 0;
  unsigned long long bytes = 0;
  int sectsize = 0;
  int physsectsize = 0;

  if (n.getLogicalName() == "")
    return false;

  int fd = open(n.getLogicalName().c_str(), O_RDONLY | O_NONBLOCK);

  if (fd < 0)
    return false;

  if (ioctl(fd, BLKPBSZGET, &physsectsize) != 0)
    physsectsize = 0;
  if(physsectsize)
    n.setConfig("sectorsize", physsectsize);

  if (n.getSize() == 0)
  {
    if(ioctl(fd, BLKGETSIZE64, &bytes) == 0)
    {
      n.setSize(bytes);
    }
    else
    {
      if (ioctl(fd, BLKGETSIZE, &size) != 0)
        size = 0;
      if (ioctl(fd, BLKSSZGET, &sectsize) != 0)
        sectsize = 0;

      if ((size > 0) && (sectsize > 0))
        n.setSize((unsigned long long) size * (unsigned long long) sectsize);
    }
  }

  close(fd);

  if(n.getSize()>=0)
  {
    n.addHint("icon", string("disc"));
    scan_partitions(n);
  }

  return true;
}

Here is the call graph for this function:

Here is the caller graph for this function: