Module: BlkID

Defined in:
lib/rblkid/constants.rb,
lib/rblkid.rb,
lib/rblkid/c.rb,
lib/rblkid/dev.rb,
lib/rblkid/cache.rb,
lib/rblkid/probe.rb,
lib/rblkid/c/types.rb,
lib/rblkid/partlist.rb,
lib/rblkid/topology.rb,
lib/rblkid/partition.rb,
lib/rblkid/parttable.rb,
lib/rblkid/c/functions.rb,
lib/rblkid/dev_iterate.rb,
lib/rblkid/tag_iterate.rb

Overview

– Copyleft shura. [ [email protected] ]

This file is part of rblkid.

rblkid is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

rblkid is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with rblkid. If not, see <www.gnu.org/licenses/>. ++

Defined Under Namespace

Modules: C Classes: Cache, Dev, DevIterate, PartList, PartTable, Partition, Probe, TagIterate, Topology

Constant Summary collapse

BLKID_PROBVAL_BUFSIZ =
64
BLKID_NVALS_SUBLKS =
14
BLKID_NVALS_TOPLGY =
5
BLKID_NVALS_PARTS =
10
BLKID_NVALS =
BLKID_NVALS_SUBLKS + BLKID_NVALS_TOPLGY + BLKID_NVALS_PARTS
BLKID_CHAIN_SUBLKS =
0
BLKID_CHAIN_TOPLGY =
1
BLKID_CHAIN_PARTS =
2
BLKID_NCHAINS =
3
BLKID_FLTR_NOTIN =
1
BLKID_FLTR_ONLYIN =
2
BLKID_DEV_CREATE =
0x0001
BLKID_DEV_FIND =
0x0000
BLKID_DEV_VERIFY =
0x0002
BLKID_DEV_NORMAL =
BLKID_DEV_CREATE | BLKID_DEV_VERIFY
BLKID_PARTS_ENTRY_DETAILS =
1 << 2
BLKID_PARTS_FORCE_GPT =
(1 << 1)
BLKID_SUBLKS_DEFAULT =
0
BLKID_SUBLKS_LABEL =
(1 << 1)
BLKID_SUBLKS_LABELRAW =
(1 << 2)
BLKID_SUBLKS_MAGIC =
(1 << 9)
BLKID_SUBLKS_SECTYPE =
(1 << 6)
BLKID_SUBLKS_TYPE =
(1 << 5)
BLKID_SUBLKS_USAGE =
(1 << 7)
BLKID_SUBLKS_UUID =
(1 << 3)
BLKID_SUBLKS_UUIDRAW =
(1 << 4)
BLKID_SUBLKS_VERSION =
(1 << 8)
BLKID_USAGE_CRYPTO =
(1 << 3)
BLKID_USAGE_FILESYSTEM =
(1 << 1)
BLKID_USAGE_OTHER =
(1 << 4)
BLKID_USAGE_RAID =
(1 << 2)

Class Method Summary collapse

Class Method Details

.dev_size(fd) ⇒ Object



126
127
128
# File 'lib/rblkid.rb', line 126

def dev_size (fd)
  BlkID::C.blkid_get_dev_size(fd)
end

.devno_to_devname(devno) ⇒ Object



116
117
118
# File 'lib/rblkid.rb', line 116

def devno_to_devname (devno)
  BlkID::C.blkid_devno_to_devname(devno)
end

.devno_to_wholedisk(dev) ⇒ Object



120
121
122
123
124
# File 'lib/rblkid.rb', line 120

def devno_to_wholedisk (dev)
  diskdevno = FFI::MemoryPointer.new(:ulong, 1)
  BlkID::C.blkid_devno_to_wholedisk(dev, nil, 0, diskdevno)
  diskdevno.read_ulong
end

.evaluate_spec(spec, cache = nil) ⇒ Object



41
42
43
44
45
# File 'lib/rblkid.rb', line 41

def evaluate_spec(spec, cache=nil)
  cache = cache.ptr if cache.is_a?(BlkID::Cache)

  BlkID::C.evaluate_spec(spec, cache)
end

.evaluate_tag(token, value, cache = nil) ⇒ Object



35
36
37
38
39
# File 'lib/rblkid.rb', line 35

def evaluate_tag (token, value, cache=nil)
  cache = cache.ptr if cache.is_a?(BlkID::Cache)

  BlkID::C.blkid_evaluate_tag(token, value, cache)
end

.filter_partitions_type(flag, names) ⇒ Object



94
95
96
97
98
99
100
101
102
# File 'lib/rblkid.rb', line 94

def filter_partitions_type (flag, names)
  n = FFI::MemoryPointer.new(:pointer, names.size + 1)
  names.each_with_index {|s, i|
    n[i].put_pointer(0, FFI::MemoryPointer.from_string(s))
  }
  n[names.size].put_pointer(0, nil)

  BlkID::C.blkid_probe_filter_partitions_type(@struct, flag, n)
end

.filter_superblocks_type(flag, names) ⇒ Object



60
61
62
63
64
65
66
67
68
# File 'lib/rblkid.rb', line 60

def filter_superblocks_type (flag, names)
  n = FFI::MemoryPointer.new(:pointer, names.size + 1)
  names.each_with_index {|s, i|
    n[i].put_pointer(0, FFI::MemoryPointer.from_string(s))
  }
  n[names.size].put_pointer(0, nil)

  BlkID::C.blkid_probe_filter_superblocks_type(@struct, flag, n)
end

.filter_superblocks_usage(flag, usage) ⇒ Object



70
71
72
# File 'lib/rblkid.rb', line 70

def filter_superblocks_usage (flag, usage)
  BlkID::C.blkid_probe_filter_superblocks_usage(@struct, flag, usage)
end

.invert_partitions_filterObject



104
105
106
# File 'lib/rblkid.rb', line 104

def invert_partitions_filter
  BlkID::C.blkid_probe_invert_partitions_filter(@struct)
end

.invert_superblocks_filterObject



74
75
76
# File 'lib/rblkid.rb', line 74

def invert_superblocks_filter
  BlkID::C.blkid_probe_invert_superblocks_filter(@struct)
end

.known_fstype?(fstype) ⇒ Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/rblkid.rb', line 47

def known_fstype? (fstype)
  BlkID::C.blkid_known_fstype(fstype)
end

.known_pttype?(pttype) ⇒ Boolean

Returns:

  • (Boolean)


112
113
114
# File 'lib/rblkid.rb', line 112

def known_pttype? (pttype)
  BlkID::C.blkid_known_pttype(pttype)
end

.name(idx) ⇒ Object



51
52
53
54
55
56
57
58
# File 'lib/rblkid.rb', line 51

def name (idx)
  name = FFI::MemoryPointer.new(:string)
  usage = FFI::MemoryPointer.new(:int)

  BlkID::C.blkid_superblocks_get_name(idx, FFI::MemoryPointer.new(:pointer).write_pointer(name), usage).tap {|res|
    break [name.read_string, usage.read_int] if res
  }
end

.partitions=(bool) ⇒ Object



86
87
88
# File 'lib/rblkid.rb', line 86

def partitions= (bool)
  BlkID::C.blkid_probe_enable_partitions(@struct, bool)
end

.partitions_flags=(flags) ⇒ Object



90
91
92
# File 'lib/rblkid.rb', line 90

def partitions_flags= (flags)
  BlkID::C.blkid_probe_set_partitions_flags(@struct, flags)
end

.reset_partitions_filterObject



108
109
110
# File 'lib/rblkid.rb', line 108

def reset_partitions_filter
  BlkID::C.blkid_probe_reset_partitions_filter(@struct)
end

.reset_superblocks_filterObject



78
79
80
# File 'lib/rblkid.rb', line 78

def reset_superblocks_filter
  BlkID::C.blkid_probe_reset_superblocks_filter(@struct)
end

.send_uevent(devname, action) ⇒ Object



130
131
132
# File 'lib/rblkid.rb', line 130

def send_uevent (devname, action)
  BlkID::C.blkid_send_uevent(devname, action)
end

.superblocks_flags=(flags) ⇒ Object



82
83
84
# File 'lib/rblkid.rb', line 82

def superblocks_flags= (flags)
  BlkID::C.blkid_probe_set_superblocks_flags(@struct, flags)
end