sys-uname 0.8.6-universal-mingw32 → 0.9.2-universal-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +16 -0
- data/README +7 -4
- data/Rakefile +20 -45
- data/doc/uname.txt +10 -10
- data/examples/uname_test.rb +6 -5
- data/lib/unix/sys/uname.rb +330 -0
- data/lib/windows/sys/uname.rb +469 -0
- data/sys-uname.gemspec +11 -7
- data/test/test_sys_uname.rb +118 -108
- metadata +30 -58
- data/lib/sys/uname.rb +0 -471
data/CHANGES
CHANGED
@@ -1,3 +1,19 @@
|
|
1
|
+
== 0.9.2 - 1-May-2013
|
2
|
+
* Added a workaround for a win32ole thread bug. Thanks go to Tianlong Wu
|
3
|
+
for the spot.
|
4
|
+
* Altered platform handling slightly for Windows in the Rakefile.
|
5
|
+
|
6
|
+
== 0.9.1 - 3-Jan-2013
|
7
|
+
* Made FFI functions private.
|
8
|
+
* Properly alias uname FFI function.
|
9
|
+
* Fixed the QuantumLength and QuantumType bug again (see 0.8.4), which I
|
10
|
+
somehow accidentally reintroduced.
|
11
|
+
|
12
|
+
== 0.9.0 - 8-Dec-2011
|
13
|
+
* Conversion to FFI.
|
14
|
+
* Added some additional methods and information for Solaris.
|
15
|
+
* Minor tweaks for 1.9 to silence warnings.
|
16
|
+
|
1
17
|
== 0.8.6 - 2-Sep-2011
|
2
18
|
* Fixed a failing test for Ruby 1.9.x.
|
3
19
|
* The gemspec for Windows is now 'universal'.
|
data/README
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
= Description
|
2
2
|
A Ruby interface for getting operating system information. The name comes
|
3
|
-
from the Unix 'uname' command, but this library works on Windows as well.
|
3
|
+
from the Unix 'uname' command, but this library works on MS Windows as well.
|
4
|
+
|
5
|
+
= Prerequisites
|
6
|
+
ffi 1.0 or later
|
4
7
|
|
5
8
|
= Installation
|
6
9
|
gem install sys-uname
|
@@ -15,8 +18,8 @@
|
|
15
18
|
p Uname.uname
|
16
19
|
|
17
20
|
= Solaris Notes
|
18
|
-
|
19
|
-
and
|
21
|
+
Users on SunOS get several extra methods: architecture, platform,
|
22
|
+
hw_serial, hw_provider, srpc_domain, isa_list, and dhcp_cache.
|
20
23
|
|
21
24
|
= BSD flavors, including OS X
|
22
25
|
Users on BSD platforms get the extra Uname.model method.
|
@@ -28,7 +31,7 @@
|
|
28
31
|
|
29
32
|
= MS Windows Notes
|
30
33
|
The C version for Windows has been completely scrapped in favor of an OLE
|
31
|
-
plus WMI approach.
|
34
|
+
plus WMI approach. It is pure Ruby. Please see the MSDN documentation for
|
32
35
|
the Win32_OperatingSystem class for a complete list of what each of the
|
33
36
|
UnameStruct members mean.
|
34
37
|
|
data/Rakefile
CHANGED
@@ -1,73 +1,48 @@
|
|
1
1
|
require 'rake'
|
2
|
-
require 'rake/clean'
|
3
2
|
require 'rake/testtask'
|
3
|
+
require 'rake/clean'
|
4
4
|
require 'rbconfig'
|
5
|
-
include Config
|
6
5
|
|
7
|
-
|
8
|
-
|
9
|
-
CLEAN.include(
|
10
|
-
'**/*.gem', # Gem files
|
11
|
-
'**/*.rbc', # Rubinius
|
12
|
-
'**/*.o', # C object file
|
13
|
-
'**/*.log', # Ruby extension build log
|
14
|
-
'**/Makefile', # C Makefile
|
15
|
-
'**/conftest.dSYM', # OS X build directory
|
16
|
-
"**/*.#{CONFIG['DLEXT']}" # C shared object
|
17
|
-
)
|
18
|
-
|
19
|
-
desc "Build the source for C extensions"
|
20
|
-
task :build => [:clean] do
|
21
|
-
Dir.chdir("ext"){
|
22
|
-
ruby "extconf.rb"
|
23
|
-
sh "make"
|
24
|
-
cp "uname." + Config::CONFIG['DLEXT'], 'sys'
|
25
|
-
}
|
26
|
-
end
|
6
|
+
CLEAN.include("**/*.rbc", "**/*.rbx", "**/*.gem")
|
27
7
|
|
28
8
|
desc "Run the example program"
|
29
|
-
task :example
|
30
|
-
if
|
31
|
-
sh 'ruby -Ilib examples/uname_test.rb'
|
9
|
+
task :example do
|
10
|
+
if File::ALT_SEPARATOR
|
11
|
+
sh 'ruby -Ilib/windows examples/uname_test.rb'
|
32
12
|
else
|
33
|
-
sh 'ruby -
|
13
|
+
sh 'ruby -Ilib/unix examples/uname_test.rb'
|
34
14
|
end
|
35
15
|
end
|
36
16
|
|
37
|
-
namespace
|
17
|
+
namespace :gem do
|
38
18
|
desc "Create the sys-uname gem"
|
39
|
-
task :create do
|
19
|
+
task :create => [:clean] do
|
40
20
|
spec = eval(IO.read('sys-uname.gemspec'))
|
41
|
-
|
42
|
-
|
43
|
-
spec.platform = Gem::Platform::
|
44
|
-
spec.platform.cpu = 'universal'
|
45
|
-
spec.platform.version = nil
|
46
|
-
spec.original_platform = spec.platform
|
47
|
-
else
|
48
|
-
spec.files = spec.files.reject{ |f| f.include?('lib') }
|
49
|
-
spec.extensions = ['ext/extconf.rb']
|
50
|
-
spec.extra_rdoc_files += ['ext/sys/uname.c']
|
21
|
+
|
22
|
+
if File::ALT_SEPARATOR
|
23
|
+
spec.platform = Gem::Platform::new(['universal', 'mingw32'])
|
51
24
|
end
|
25
|
+
|
52
26
|
Gem::Builder.new(spec).build
|
53
27
|
end
|
54
28
|
|
55
29
|
desc "Install the sys-uname gem"
|
56
|
-
task :install => [:
|
57
|
-
file = Dir[
|
30
|
+
task :install => [:build] do
|
31
|
+
file = Dir["*.gem"].first
|
58
32
|
sh "gem install #{file}"
|
59
33
|
end
|
60
34
|
end
|
61
35
|
|
62
36
|
desc "Run the test suite"
|
63
37
|
Rake::TestTask.new("test") do |t|
|
64
|
-
if
|
65
|
-
t.libs << 'lib'
|
38
|
+
if File::ALT_SEPARATOR
|
39
|
+
t.libs << 'lib/windows'
|
66
40
|
else
|
67
|
-
|
68
|
-
t.libs << 'ext'
|
69
|
-
t.libs.delete('lib')
|
41
|
+
t.libs << 'lib/unix'
|
70
42
|
end
|
43
|
+
|
44
|
+
t.warning = true
|
45
|
+
t.verbose = true
|
71
46
|
end
|
72
47
|
|
73
48
|
task :default => :test
|
data/doc/uname.txt
CHANGED
@@ -26,25 +26,25 @@ VERSION
|
|
26
26
|
|
27
27
|
== Class Methods
|
28
28
|
Uname.sysname
|
29
|
-
Returns the operating system name
|
29
|
+
Returns the operating system name. e.g. "SunOS"
|
30
30
|
|
31
31
|
Uname.nodename
|
32
|
-
Returns the nodename.
|
32
|
+
Returns the nodename. This is usually, but not necessarily, the
|
33
33
|
same as the system's hostname.
|
34
34
|
|
35
35
|
You cannot currently set the nodename (root or otherwise). This may
|
36
36
|
be added in a future release.
|
37
37
|
|
38
38
|
Uname.machine
|
39
|
-
Returns the machine hardware type
|
39
|
+
Returns the machine hardware type. e.g. "i686"
|
40
40
|
|
41
41
|
Uname.version
|
42
|
-
Returns the operating system version. e.g. "5.8".
|
42
|
+
Returns the operating system version. e.g. "5.8". In the case of MS
|
43
43
|
Windows, it returns the version plus patch information, separated by
|
44
44
|
a hyphen, e.g. "2915-Service Pack 2".
|
45
45
|
|
46
46
|
Uname.release
|
47
|
-
Returns the operating system release
|
47
|
+
Returns the operating system release. e.g. "2.2.16-3"
|
48
48
|
|
49
49
|
Uname.uname
|
50
50
|
Returns a struct of type UnameStruct that contains sysname, nodename,
|
@@ -57,10 +57,10 @@ Uname.uname
|
|
57
57
|
|
58
58
|
== Solaris Only
|
59
59
|
Uname.architecture
|
60
|
-
Returns the instruction set architecture
|
60
|
+
Returns the instruction set architecture. e.g. "sparc"
|
61
61
|
|
62
62
|
Uname.platform
|
63
|
-
Returns the platform identifier
|
63
|
+
Returns the platform identifier. e.g. "SUNW,Sun-Blade-100"
|
64
64
|
|
65
65
|
Uname.isa_list
|
66
66
|
Returns a space separated string containing a list of all variant
|
@@ -88,8 +88,8 @@ Uname.model
|
|
88
88
|
Returns the model type, e.g. "PowerBook5,1"
|
89
89
|
|
90
90
|
== HP-UX Only
|
91
|
-
Uname.
|
92
|
-
Returns the id number, e.g. 234233587.
|
91
|
+
Uname.id
|
92
|
+
Returns the id number, e.g. 234233587. This is a String, not a Fixnum.
|
93
93
|
|
94
94
|
== Notes
|
95
95
|
Not all of the information that you might be used to seeing with
|
@@ -112,7 +112,7 @@ Uname.id_number
|
|
112
112
|
Artistic 2.0
|
113
113
|
|
114
114
|
== Copyright
|
115
|
-
(C) 2002-
|
115
|
+
(C) 2002-2013 Daniel J. Berger
|
116
116
|
All Rights Reserved
|
117
117
|
|
118
118
|
== Warranty
|
data/examples/uname_test.rb
CHANGED
@@ -5,6 +5,7 @@
|
|
5
5
|
# should generally be run via the 'rake example' task.
|
6
6
|
########################################################################
|
7
7
|
require 'sys/uname'
|
8
|
+
require 'rbconfig'
|
8
9
|
include Sys
|
9
10
|
|
10
11
|
puts "VERSION: " + Uname::VERSION
|
@@ -14,8 +15,8 @@ puts 'Version: ' + Uname.version
|
|
14
15
|
puts 'Release: ' + Uname.release
|
15
16
|
puts 'Machine: ' + Uname.machine # May be "unknown" on Win32
|
16
17
|
|
17
|
-
if
|
18
|
-
print "\nSolaris specific tests\n"
|
18
|
+
if RbConfig::CONFIG['host_os'] =~ /sun|solaris/i
|
19
|
+
print "\nSolaris specific tests\n"
|
19
20
|
puts "==========================="
|
20
21
|
puts 'Architecture: ' + Uname.architecture
|
21
22
|
puts 'Platform: ' + Uname.platform
|
@@ -26,13 +27,13 @@ if RUBY_PLATFORM =~ /sun|solaris/i
|
|
26
27
|
puts 'DHCP Cache: ' + Uname.dhcp_cache # might be empty
|
27
28
|
end
|
28
29
|
|
29
|
-
if
|
30
|
-
print "\nBSD/OS X specific tests\n"
|
30
|
+
if RbConfig::CONFIG['host_os'] =~ /powerpc|darwin|bsd|mach/i
|
31
|
+
print "\nBSD/OS X specific tests\n"
|
31
32
|
puts "======================="
|
32
33
|
puts 'Model: ' + Uname.model
|
33
34
|
end
|
34
35
|
|
35
|
-
if
|
36
|
+
if RbConfig::CONFIG['host_os'] =~ /hpux/i
|
36
37
|
print "\nHP-UX specific tests\n"
|
37
38
|
puts "========================"
|
38
39
|
puts "ID: " + Uname.id
|
@@ -0,0 +1,330 @@
|
|
1
|
+
require 'ffi'
|
2
|
+
require 'rbconfig'
|
3
|
+
require 'ostruct'
|
4
|
+
|
5
|
+
# The Sys module serves as a namespace only.
|
6
|
+
module Sys
|
7
|
+
# The Uname class encapsulates information about the system.
|
8
|
+
class Uname
|
9
|
+
extend FFI::Library
|
10
|
+
ffi_lib FFI::Library::LIBC
|
11
|
+
|
12
|
+
# Error raised if the uname() function fails.
|
13
|
+
class Error < StandardError; end
|
14
|
+
|
15
|
+
# The version of the sys-uname library
|
16
|
+
VERSION = '0.9.2'
|
17
|
+
|
18
|
+
# :stopdoc
|
19
|
+
|
20
|
+
# Buffer size for uname struct char arrays
|
21
|
+
case RbConfig::CONFIG['host_os']
|
22
|
+
when /linux/i
|
23
|
+
BUFSIZE = 65
|
24
|
+
when /bsd/i
|
25
|
+
BUFSIZE = 32 # TODO: version method chopped
|
26
|
+
when /sunos|solaris/i
|
27
|
+
BUFSIZE = 257
|
28
|
+
else
|
29
|
+
BUFSIZE = 256
|
30
|
+
end
|
31
|
+
|
32
|
+
attach_function :uname_c, :uname, [:pointer], :int
|
33
|
+
private_class_method :uname_c
|
34
|
+
|
35
|
+
begin
|
36
|
+
attach_function :sysctl, [:pointer, :uint, :pointer, :pointer, :pointer, :size_t], :int
|
37
|
+
private_class_method :sysctl
|
38
|
+
|
39
|
+
CTL_HW = 6 # Generic hardware/cpu
|
40
|
+
HW_MODEL = 2 # Specific machine model
|
41
|
+
rescue FFI::NotFoundError
|
42
|
+
# Ignore. Not suppored.
|
43
|
+
end
|
44
|
+
|
45
|
+
begin
|
46
|
+
attach_function :sysinfo, [:int, :pointer, :long], :long
|
47
|
+
private_class_method :sysinfo
|
48
|
+
|
49
|
+
SI_SYSNAME = 1 # OS name
|
50
|
+
SI_HOSTNAME = 2 # Node name
|
51
|
+
SI_RELEASE = 3 # Operating system release
|
52
|
+
SI_VERSION = 4 # Version field of utsname
|
53
|
+
SI_MACHINE = 5 # Machine type
|
54
|
+
SI_ARCHITECTURE = 6 # Instruction set architecture
|
55
|
+
SI_HW_SERIAL = 7 # Hardware serial number
|
56
|
+
SI_HW_PROVIDER = 8 # Hardware manufacturer
|
57
|
+
SI_SRPC_DOMAIN = 9 # Secure RPC domain
|
58
|
+
SI_PLATFORM = 513 # Platform identifier
|
59
|
+
SI_ISALIST = 514 # Supported isalist
|
60
|
+
SI_DHCP_CACHE = 515 # Kernel cached DHCPACK
|
61
|
+
rescue FFI::NotFoundError
|
62
|
+
# Ignore. Not suppored.
|
63
|
+
end
|
64
|
+
|
65
|
+
class UnameFFIStruct < FFI::Struct
|
66
|
+
members = [
|
67
|
+
:sysname, [:char, BUFSIZE],
|
68
|
+
:nodename, [:char, BUFSIZE],
|
69
|
+
:release, [:char, BUFSIZE],
|
70
|
+
:version, [:char, BUFSIZE],
|
71
|
+
:machine, [:char, BUFSIZE]
|
72
|
+
]
|
73
|
+
|
74
|
+
if RbConfig::CONFIG['host_os'] =~ /linux/i
|
75
|
+
members.push(:domainname, [:char, BUFSIZE])
|
76
|
+
end
|
77
|
+
|
78
|
+
if RbConfig::CONFIG['host_os'] =~ /hpux/i
|
79
|
+
members.push(:__id_number, [:char, BUFSIZE])
|
80
|
+
end
|
81
|
+
|
82
|
+
layout(*members)
|
83
|
+
end
|
84
|
+
|
85
|
+
fields = %w[
|
86
|
+
sysname
|
87
|
+
nodename
|
88
|
+
release
|
89
|
+
version
|
90
|
+
machine
|
91
|
+
]
|
92
|
+
|
93
|
+
if RbConfig::CONFIG['host_os'] =~ /linux/i
|
94
|
+
fields.push('domainname')
|
95
|
+
end
|
96
|
+
|
97
|
+
if RbConfig::CONFIG['host_os'] =~ /hpux/i
|
98
|
+
fields.push('id_number')
|
99
|
+
end
|
100
|
+
|
101
|
+
if RbConfig::CONFIG['host_os'] =~ /sunos|solaris/i
|
102
|
+
fields.push(
|
103
|
+
'architecture',
|
104
|
+
'dhcp_cache',
|
105
|
+
'hw_provider',
|
106
|
+
'hw_serial',
|
107
|
+
'isa_list',
|
108
|
+
'platform',
|
109
|
+
'srpc_domain'
|
110
|
+
)
|
111
|
+
end
|
112
|
+
|
113
|
+
if RbConfig::CONFIG['host_os'] =~ /darwin|bsd/i
|
114
|
+
fields.push('model')
|
115
|
+
end
|
116
|
+
|
117
|
+
# :startdoc:
|
118
|
+
|
119
|
+
UnameStruct = Struct.new("UnameStruct", *fields)
|
120
|
+
|
121
|
+
# Returns a struct that contains the sysname, nodename, machine, version
|
122
|
+
# and release of your system.
|
123
|
+
#
|
124
|
+
# On OS X it will also include the model.
|
125
|
+
#
|
126
|
+
# On Solaris, it will also include the architecture and platform.
|
127
|
+
#
|
128
|
+
# On HP-UX, it will also include the id_number.
|
129
|
+
#
|
130
|
+
# Example:
|
131
|
+
#
|
132
|
+
# require 'sys/uname'
|
133
|
+
#
|
134
|
+
# p Sys::Uname.uname
|
135
|
+
#
|
136
|
+
def self.uname
|
137
|
+
utsname = UnameFFIStruct.new
|
138
|
+
|
139
|
+
if uname_c(utsname) < 0
|
140
|
+
raise Error, "uname() function call failed"
|
141
|
+
end
|
142
|
+
|
143
|
+
struct = UnameStruct.new
|
144
|
+
struct[:sysname] = utsname[:sysname].to_s
|
145
|
+
struct[:nodename] = utsname[:nodename].to_s
|
146
|
+
struct[:release] = utsname[:release].to_s
|
147
|
+
struct[:version] = utsname[:version].to_s
|
148
|
+
struct[:machine] = utsname[:machine].to_s
|
149
|
+
|
150
|
+
if RbConfig::CONFIG['host_os'] =~ /darwin|bsd/i
|
151
|
+
struct[:model] = get_model()
|
152
|
+
end
|
153
|
+
|
154
|
+
if RbConfig::CONFIG['host_os'] =~ /sunos|solaris/i
|
155
|
+
struct[:architecture] = get_si(SI_ARCHITECTURE)
|
156
|
+
struct[:platform] = get_si(SI_PLATFORM)
|
157
|
+
struct[:hw_serial] = get_si(SI_HW_SERIAL)
|
158
|
+
struct[:hw_provider] = get_si(SI_HW_PROVIDER)
|
159
|
+
struct[:srpc_domain] = get_si(SI_SRPC_DOMAIN)
|
160
|
+
struct[:isa_list] = get_si(SI_ISALIST)
|
161
|
+
struct[:dhcp_cache] = get_si(SI_DHCP_CACHE)
|
162
|
+
|
163
|
+
# FFI and Solaris don't get along so well, so we try again
|
164
|
+
struct[:sysname] = get_si(SI_SYSNAME) if struct.sysname.empty?
|
165
|
+
struct[:nodename] = get_si(SI_HOSTNAME) if struct.nodename.empty?
|
166
|
+
struct[:release] = get_si(SI_RELEASE) if struct.release.empty?
|
167
|
+
struct[:version] = get_si(SI_VERSION) if struct.version.empty?
|
168
|
+
struct[:machine] = get_si(SI_MACHINE) if struct.machine.empty?
|
169
|
+
end
|
170
|
+
|
171
|
+
if RbConfig::CONFIG['host_os'] =~ /hpux/i
|
172
|
+
struct[:id_number] = utsname[:__id_number].to_s
|
173
|
+
end
|
174
|
+
|
175
|
+
if RbConfig::CONFIG['host_os'] =~ /linux/i
|
176
|
+
struct[:domainname] = utsname[:domainname].to_s
|
177
|
+
end
|
178
|
+
|
179
|
+
# Let's add a members method that works for testing and compatibility
|
180
|
+
if struct.members.nil?
|
181
|
+
struct.instance_eval(%Q{
|
182
|
+
def members
|
183
|
+
@table.keys.map{ |k| k.to_s }
|
184
|
+
end
|
185
|
+
})
|
186
|
+
end
|
187
|
+
|
188
|
+
struct.freeze
|
189
|
+
end
|
190
|
+
|
191
|
+
# Returns the name of this implementation of the operating system.
|
192
|
+
#
|
193
|
+
# Example:
|
194
|
+
#
|
195
|
+
# Uname.sysname # => 'SunOS'
|
196
|
+
#
|
197
|
+
def self.sysname
|
198
|
+
uname.sysname
|
199
|
+
end
|
200
|
+
|
201
|
+
# Returns the name of this node within the communications network to
|
202
|
+
# which this node is attached, if any. This is often, but not
|
203
|
+
# necessarily, the same as the host name.
|
204
|
+
#
|
205
|
+
# Example:
|
206
|
+
#
|
207
|
+
# Uname.nodename # => 'your_host.foo.com'
|
208
|
+
#
|
209
|
+
def self.nodename
|
210
|
+
uname.nodename
|
211
|
+
end
|
212
|
+
|
213
|
+
# Returns the current release level of your operating system.
|
214
|
+
#
|
215
|
+
# Example:
|
216
|
+
#
|
217
|
+
# Uname.release # => '2.2.16-3'
|
218
|
+
#
|
219
|
+
def self.release
|
220
|
+
uname.release
|
221
|
+
end
|
222
|
+
|
223
|
+
# Returns the current version level of your operating system.
|
224
|
+
#
|
225
|
+
# Example:
|
226
|
+
#
|
227
|
+
# Uname.version # => '5.9'
|
228
|
+
#
|
229
|
+
def self.version
|
230
|
+
uname.version
|
231
|
+
end
|
232
|
+
|
233
|
+
# Returns the machine hardware type.
|
234
|
+
#
|
235
|
+
# Example:
|
236
|
+
#
|
237
|
+
# Uname.machine # => 'i686'
|
238
|
+
#
|
239
|
+
def self.machine
|
240
|
+
uname.machine
|
241
|
+
end
|
242
|
+
|
243
|
+
if defined? :sysctl
|
244
|
+
# Returns the model type.
|
245
|
+
#
|
246
|
+
# Example:
|
247
|
+
#
|
248
|
+
# Uname.model # => 'MacBookPro5,3'
|
249
|
+
#
|
250
|
+
def self.model
|
251
|
+
uname.model
|
252
|
+
end
|
253
|
+
end
|
254
|
+
|
255
|
+
if defined? :sysinfo
|
256
|
+
# The basic instruction set architecture of the current
|
257
|
+
# system, e.g. sparc, i386, etc.
|
258
|
+
#
|
259
|
+
def self.architecture
|
260
|
+
uname.architecture
|
261
|
+
end
|
262
|
+
|
263
|
+
# The specific model of the hardware platform, e.g Sun-Blade-1500, etc.
|
264
|
+
#
|
265
|
+
def self.platform
|
266
|
+
uname.platform
|
267
|
+
end
|
268
|
+
|
269
|
+
# The string consisting of the ASCII hexidecimal encoding of the name
|
270
|
+
# of the interface configured by boot(1M) followed by the DHCPACK reply
|
271
|
+
# from the server.
|
272
|
+
#
|
273
|
+
def self.dhcp_cache
|
274
|
+
uname.dhcp_cache
|
275
|
+
end
|
276
|
+
|
277
|
+
# The variant instruction set architectures executable on the
|
278
|
+
# current system.
|
279
|
+
#
|
280
|
+
def self.isa_list
|
281
|
+
uname.isa_list
|
282
|
+
end
|
283
|
+
|
284
|
+
# The ASCII representation of the hardware-specific serial number
|
285
|
+
# of the physical machine on which the function is executed.
|
286
|
+
#
|
287
|
+
def self.hw_serial
|
288
|
+
uname.hw_serial.to_i
|
289
|
+
end
|
290
|
+
|
291
|
+
# The name of the of the hardware provider.
|
292
|
+
#
|
293
|
+
def self.hw_provider
|
294
|
+
uname.hw_provider
|
295
|
+
end
|
296
|
+
|
297
|
+
# The Secure Remote Procedure Call domain name.
|
298
|
+
#
|
299
|
+
def self.srpc_domain
|
300
|
+
uname.srpc_domain
|
301
|
+
end
|
302
|
+
end
|
303
|
+
|
304
|
+
private
|
305
|
+
|
306
|
+
# Returns the model for systems that define sysctl().
|
307
|
+
#
|
308
|
+
def self.get_model
|
309
|
+
buf = 0.chr * BUFSIZE
|
310
|
+
mib = FFI::MemoryPointer.new(:int, 2).write_array_of_int([CTL_HW, HW_MODEL])
|
311
|
+
size = FFI::MemoryPointer.new(:long, 1).write_int(buf.size)
|
312
|
+
|
313
|
+
sysctl(mib, 2, buf, size, nil, 0)
|
314
|
+
|
315
|
+
buf.strip
|
316
|
+
end
|
317
|
+
|
318
|
+
private_class_method :get_model
|
319
|
+
|
320
|
+
# Returns the various sysinfo information based on +flag+.
|
321
|
+
#
|
322
|
+
def self.get_si(flag)
|
323
|
+
buf = 0.chr * BUFSIZE
|
324
|
+
sysinfo(flag, buf, BUFSIZE)
|
325
|
+
buf.strip
|
326
|
+
end
|
327
|
+
|
328
|
+
private_class_method :get_si
|
329
|
+
end
|
330
|
+
end
|