hrr_rb_mount 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7e40e0f523c2e10f4590e65254da3c1533347ddc07bd085543d331434b221449
4
- data.tar.gz: 557b4ac323a0c85c71e077fc87d85c1e6f23d29886b442c4ae0a45e40104526a
3
+ metadata.gz: ecb4bf5f144d93726b82b23785d8cbfcde2892f0f645f71425d3741c4ccc3ab6
4
+ data.tar.gz: 167e967e7026848a6839af9f0670e1b9aa72963fa6ff21ebe0947fd999dceb8a
5
5
  SHA512:
6
- metadata.gz: a2b316d880055d67c37d9e9230a36df9f6abb8d585fcc5cd9bd27f15a859c92734b4676047d21f7e96a64d14615ae02bdf5dde48434a6be43afbd3451aebccea
7
- data.tar.gz: cbe8545e911c7cdfc686ad545f22a85d62c01a5e727b3616786b4d8e5447a451cc2a2a0891613478e4b137b61b415b09179eb462362622734b80df82310c22b4
6
+ metadata.gz: ee7784f5c20e20944462e966573aab063ccd903156fb03c4a42ff4221c32d572083803a502f75670f91a9603b898194fe7b133a1329a449c2900dc965503ba83
7
+ data.tar.gz: 9a3ace10fcf53e160deb71cec6b4d3cb59fcf2305c711c30ba78ca2530a574270a31c6969ea019ccbd10405f4cfc8f0479325f4243117bde45fd4361bbf44054
@@ -1,7 +1,6 @@
1
1
  ---
2
2
  language: ruby
3
3
  cache: bundler
4
- rvm:
5
4
  rvm:
6
5
  - 2.0
7
6
  - 2.1
@@ -23,8 +22,8 @@ before_install:
23
22
  install:
24
23
  - bundle install
25
24
  before_script:
26
- - sudo env RBENV_VERSION="${RBENV_VERSION}" PATH="${RBENV_ROOT}/shims:${RBENV_ROOT}/bin:${PATH}" bundle exec rake clean clobber
25
+ - sudo env RBENV_VERSION="${RBENV_VERSION}" PATH="${RBENV_ROOT}/shims:${RBENV_ROOT}/bin:${PATH}" bundle exec rake clean
27
26
  script:
28
27
  - sudo env RBENV_VERSION="${RBENV_VERSION}" PATH="${RBENV_ROOT}/shims:${RBENV_ROOT}/bin:${PATH}" bundle exec rake compile spec
29
28
  after_script:
30
- - sudo env RBENV_VERSION="${RBENV_VERSION}" PATH="${RBENV_ROOT}/shims:${RBENV_ROOT}/bin:${PATH}" bundle exec rake clean clobber
29
+ - sudo env RBENV_VERSION="${RBENV_VERSION}" PATH="${RBENV_ROOT}/shims:${RBENV_ROOT}/bin:${PATH}" bundle exec rake clean
data/README.md CHANGED
@@ -41,6 +41,10 @@ flags = HrrRbMount::NOEXEC
41
41
  HrrRbMount.mount "tmpfs", "/path/to/target", "tmpfs", flags, "size=1M" # => 0
42
42
  HrrRbMount.mountpoint? "/path/to/target" # => true
43
43
  HrrRbMount.umount "/path/to/target" # => 0
44
+
45
+ HrrRbMount.bind "/path/to/source", "/path/to/target" # => 0
46
+ HrrRbMount.make_private "/path/to/target" # => 0
47
+ HrrRbMount.remount "/path/to/target", flags # => 0
44
48
  ```
45
49
 
46
50
  ## Development
@@ -7,7 +7,7 @@ VALUE rb_mHrrRbMountConst;
7
7
  /*
8
8
  * A wrapper around mount system call.
9
9
  *
10
- * == Synopsis:
10
+ * @example
11
11
  * HrrRbMount.mount "source", "target", "filesystemtype", mountflags, "data" # => 0
12
12
  *
13
13
  * @overload mount(source, target, filesystemtype, mountflags=0, data="") => 0
@@ -29,9 +29,9 @@ hrr_rb_mount_mount(int argc, VALUE *argv, VALUE self)
29
29
 
30
30
  source = StringValueCStr(argv[0]);
31
31
  target = StringValueCStr(argv[1]);
32
- filesystemtype = StringValueCStr(argv[2]);
32
+ filesystemtype = NIL_P(argv[2]) ? NULL : StringValueCStr(argv[2]);
33
33
  mountflags = argc < 4 ? 0 : NUM2ULONG(argv[3]);
34
- data = argc < 5 ? "" : StringValueCStr(argv[4]);
34
+ data = argc < 5 ? NULL : StringValueCStr(argv[4]);
35
35
 
36
36
  if (mount(source, target, filesystemtype, mountflags, data) < 0)
37
37
  rb_sys_fail("mount");
@@ -42,7 +42,7 @@ hrr_rb_mount_mount(int argc, VALUE *argv, VALUE self)
42
42
  /*
43
43
  * A wrapper around umount system call.
44
44
  *
45
- * == Synopsis:
45
+ * @example
46
46
  * HrrRbMount.umount "target", flags # => 0
47
47
  *
48
48
  * @overload umount(target, flags=0) => 0
@@ -3,7 +3,7 @@ require "hrr_rb_mount/hrr_rb_mount"
3
3
 
4
4
  # A wrapper around mount and umount. See mount(2) and umount(2) for details.
5
5
  #
6
- # == Synopsis:
6
+ # @example
7
7
  # require "hrr_rb_mount"
8
8
  #
9
9
  # flags = HrrRbMount::NOEXEC
@@ -20,6 +20,161 @@ module HrrRbMount
20
20
  # The path to /proc/self/mountinfo.
21
21
  PROC_MOUNTINFO_PATH = "/proc/self/mountinfo"
22
22
 
23
+ # A wrapper around mount --remount mountpoint command.
24
+ #
25
+ # @example
26
+ # HrrRbMount.remount "mountpoint" # => 0
27
+ #
28
+ # @param mountpoint [String] The location (a directory or file) specified by the pathname.
29
+ # @param mountflags [Integer] The umount operation is performed depending on the bits specified in the mountflags.
30
+ # @param data [String] Per filesystem options.
31
+ # @return [Integer] 0.
32
+ # @raise [Errno::EXXX] A SystemCallError is raised when the operation failed.
33
+ def self.remount mountpoint, mountflags=0, data=""
34
+ mount "none", mountpoint, nil, REMOUNT | mountflags, data
35
+ end
36
+
37
+ # A wrapper around mount --move source target command.
38
+ #
39
+ # @example
40
+ # HrrRbMount.move "source", "target" # => 0
41
+ #
42
+ # @param source [String] The pathname referring to a device or a pathname of a directory or file, or a dummy string.
43
+ # @param target [String] The location (a directory or file) specified by the pathname.
44
+ # @param mountflags [Integer] The umount operation is performed depending on the bits specified in the mountflags.
45
+ # @param data [String] Per filesystem options.
46
+ # @return [Integer] 0.
47
+ # @raise [Errno::EXXX] A SystemCallError is raised when the operation failed.
48
+ def self.move source, target, mountflags=0, data=""
49
+ mount source, target, nil, MOVE | mountflags, data
50
+ end
51
+
52
+ # A wrapper around mount --bind source target command.
53
+ #
54
+ # @example
55
+ # HrrRbMount.bind "source", "target" # => 0
56
+ #
57
+ # @param source [String] The pathname referring to a device or a pathname of a directory or file, or a dummy string.
58
+ # @param target [String] The location (a directory or file) specified by the pathname.
59
+ # @param mountflags [Integer] The mount operation is performed depending on the bits specified in the mountflags.
60
+ # @param data [String] Per filesystem options.
61
+ # @return [Integer] 0.
62
+ # @raise [Errno::EXXX] A SystemCallError is raised when the operation failed.
63
+ def self.bind source, target, mountflags=0, data=""
64
+ mount source, target, nil, BIND | mountflags, data
65
+ end
66
+
67
+ # A wrapper around mount --rbind source target command.
68
+ #
69
+ # @example
70
+ # HrrRbMount.rbind "source", "target" # => 0
71
+ #
72
+ # @param source [String] The pathname referring to a device or a pathname of a directory or file, or a dummy string.
73
+ # @param target [String] The location (a directory or file) specified by the pathname.
74
+ # @param mountflags [Integer] The mount operation is performed depending on the bits specified in the mountflags.
75
+ # @param data [String] Per filesystem options.
76
+ # @return [Integer] 0.
77
+ # @raise [Errno::EXXX] A SystemCallError is raised when the operation failed.
78
+ def self.rbind source, target, mountflags=0, data=""
79
+ mount source, target, nil, BIND | REC | mountflags, data
80
+ end
81
+
82
+ # A wrapper around mount --make-shared mountpoint command.
83
+ #
84
+ # @example
85
+ # HrrRbMount.make_shared "mountpoint" # => 0
86
+ #
87
+ # @param mountpoint [String] The location (a directory or file) specified by the pathname.
88
+ # @return [Integer] 0.
89
+ # @raise [Errno::EXXX] A SystemCallError is raised when the operation failed.
90
+ def self.make_shared mountpoint
91
+ mount "none", mountpoint, nil, SHARED
92
+ end
93
+
94
+ # A wrapper around mount --make-slave mountpoint command.
95
+ #
96
+ # @example
97
+ # HrrRbMount.make_slave "mountpoint" # => 0
98
+ #
99
+ # @param mountpoint [String] The location (a directory or file) specified by the pathname.
100
+ # @return [Integer] 0.
101
+ # @raise [Errno::EXXX] A SystemCallError is raised when the operation failed.
102
+ def self.make_slave mountpoint
103
+ mount "none", mountpoint, nil, SLAVE
104
+ end
105
+
106
+ # A wrapper around mount --make-private mountpoint command.
107
+ #
108
+ # @example
109
+ # HrrRbMount.make_private "mountpoint" # => 0
110
+ #
111
+ # @param mountpoint [String] The location (a directory or file) specified by the pathname.
112
+ # @return [Integer] 0.
113
+ # @raise [Errno::EXXX] A SystemCallError is raised when the operation failed.
114
+ def self.make_private mountpoint
115
+ mount "none", mountpoint, nil, PRIVATE
116
+ end
117
+
118
+ # A wrapper around mount --make-unbindable mountpoint command.
119
+ #
120
+ # @example
121
+ # HrrRbMount.make_unbindable "mountpoint" # => 0
122
+ #
123
+ # @param mountpoint [String] The location (a directory or file) specified by the pathname.
124
+ # @return [Integer] 0.
125
+ # @raise [Errno::EXXX] A SystemCallError is raised when the operation failed.
126
+ def self.make_unbindable mountpoint
127
+ mount "none", mountpoint, nil, UNBINDABLE
128
+ end
129
+
130
+ # A wrapper around mount --make-rshared mountpoint command.
131
+ #
132
+ # @example
133
+ # HrrRbMount.make_rshared "mountpoint" # => 0
134
+ #
135
+ # @param mountpoint [String] The location (a directory or file) specified by the pathname.
136
+ # @return [Integer] 0.
137
+ # @raise [Errno::EXXX] A SystemCallError is raised when the operation failed.
138
+ def self.make_rshared mountpoint
139
+ mount "none", mountpoint, nil, REC | SHARED
140
+ end
141
+
142
+ # A wrapper around mount --make-rslave mountpoint command.
143
+ #
144
+ # @example
145
+ # HrrRbMount.make_rslave "mountpoint" # => 0
146
+ #
147
+ # @param mountpoint [String] The location (a directory or file) specified by the pathname.
148
+ # @return [Integer] 0.
149
+ # @raise [Errno::EXXX] A SystemCallError is raised when the operation failed.
150
+ def self.make_rslave mountpoint
151
+ mount "none", mountpoint, nil, REC | SLAVE
152
+ end
153
+
154
+ # A wrapper around mount --make-rprivate mountpoint command.
155
+ #
156
+ # @example
157
+ # HrrRbMount.make_rprivate "mountpoint" # => 0
158
+ #
159
+ # @param mountpoint [String] The location (a directory or file) specified by the pathname.
160
+ # @return [Integer] 0.
161
+ # @raise [Errno::EXXX] A SystemCallError is raised when the operation failed.
162
+ def self.make_rprivate mountpoint
163
+ mount "none", mountpoint, nil, REC | PRIVATE
164
+ end
165
+
166
+ # A wrapper around mount --make-runbindable mountpoint command.
167
+ #
168
+ # @example
169
+ # HrrRbMount.make_runbindable "mountpoint" # => 0
170
+ #
171
+ # @param mountpoint [String] The location (a directory or file) specified by the pathname.
172
+ # @return [Integer] 0.
173
+ # @raise [Errno::EXXX] A SystemCallError is raised when the operation failed.
174
+ def self.make_runbindable mountpoint
175
+ mount "none", mountpoint, nil, REC | UNBINDABLE
176
+ end
177
+
23
178
  # Returns true if the target directory or file is a mountpoint. Otherwise, returns false.
24
179
  #
25
180
  # Internally, uses /proc/self/mountinfo file to detect if the target is a mountpoint.
@@ -27,7 +182,7 @@ module HrrRbMount
27
182
  # When the file is not available, then uses stat(2).
28
183
  # In this case, bind mount is not able to be detected.
29
184
  #
30
- # == Synopsis:
185
+ # @example
31
186
  # HrrRbMount.mountpoint? "/proc" # => true
32
187
  # HrrRbMount.mountpoint? "/proc/1" # => false
33
188
  #
@@ -1,3 +1,3 @@
1
1
  module HrrRbMount
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hrr_rb_mount
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - hirura
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-09 00:00:00.000000000 Z
11
+ date: 2020-03-22 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A wrapper around mount and umount for CRuby
14
14
  email: