Module: LinuxBlockDevice

Defined in:
lib/linux_block_device/version.rb

Constant Summary collapse

VERSION =
"0.1.0"

Class Method Summary collapse

Class Method Details

.size(rfd) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'ext/linux_block_device/linux_block_device.c', line 13

static VALUE
lbd_size(VALUE self, VALUE rfd) {
  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);
}