Module: LinuxBlockDevice

Defined in:
lib/linux_block_device/version.rb

Constant Summary collapse

VERSION =
"0.2.1"

Class Method Summary collapse

Class Method Details

.size(rfd) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'ext/linux_block_device/linux_block_device.c', line 16

static VALUE
lbd_size(VALUE self, VALUE rfd) {
#ifdef __linux__
  int  fd;
  int64_t sz;

  fd = NUM2INT(rfd);

  if (ioctl(fd, BLKGETSIZE64, &sz) < 0)   {
    rb_raise(rb_eSystemCallError,
      "%s.size - ioctl failed on file descriptor: %d, %s\n",
      module_name,
      fd,
      strerror(errno)
    );
  }
  return OFFT2NUM(sz);
#else
  rb_raise(rb_eNotImpError, "Not supported on this platform.\n");
#endif
}