solaris-file 0.3.5 → 0.3.6

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,3 +1,9 @@
1
+ == 0.3.6 - 12-Dec-2010
2
+ * Fixed a warning regarding an unused variable.
3
+ * Fixed a potential bug with an internal helper function's switch statement.
4
+ * Refactored the Rakefile and the gemspec.
5
+ * Updated the installation instructions in the README.
6
+
1
7
  == 0.3.5 - 28-Aug-2009
2
8
  * Changed the license to Artistic 2.0.
3
9
  * Added test-unit 2.x and sys-filesystem as development dependencies.
data/README CHANGED
@@ -1,51 +1,45 @@
1
1
  == Description
2
- Adds ACL support and door methods for the File class on Solaris.
3
-
4
- == Prerequisites
5
- Ruby 1.8.x
2
+ Adds ACL support and door methods for the File class on Solaris.
6
3
 
7
4
  == Installation
8
- === Gem Installation
9
- gem install solaris-file
10
- === Local Installation
11
- rake install
5
+ gem install solaris-file
12
6
 
13
7
  == Synopsis
14
- require 'solaris/file'
8
+ require 'solaris/file'
15
9
 
16
- f = 'some_file.txt'
17
- acl_text = "user::rw-,user:nobody:r--,group::r--,group:sys:r--,mask:r--,other:r--"
10
+ file = 'some_file.txt'
11
+ acl_text = "user::rw-,user:nobody:r--,group::r--,group:sys:r--,mask:r--,other:r--"
18
12
 
19
- File.trivial?(f) # => true (probably)
20
- File.acl_write_text(acl_text)
13
+ File.trivial?(file) # => true (probably)
14
+ File.acl_write_text(acl_text)
21
15
 
22
- # No longer a trivial file
23
- File.trivial?(f) # => false
24
- File.acl_read(f).each{ |acl| p acl }
16
+ # No longer a trivial file
17
+ File.trivial?(file) # => false
18
+ File.acl_read(file).each{ |acl| p acl }
25
19
 
26
- # Door file?
27
- File.door?("/var/run/syslog_door") # => true
28
- File.ftype("/var/run/syslog_door") # => 'door'
20
+ # Door file?
21
+ File.door?("/var/run/syslog_door") # => true
22
+ File.ftype("/var/run/syslog_door") # => 'door'
29
23
 
30
24
  == Known Bugs
31
- None that I am aware of. Please report any bugs using the tracker on the
32
- project page at http://www.rubyforge.org/projects/solarisutils
25
+ None that I am aware of. Please report any bugs using the tracker on the
26
+ project page at http://www.rubyforge.org/projects/solarisutils
33
27
 
34
28
  == Future Plans
35
- Add acl_write methods that accept an array of ACLStruct's.
36
- Add support for extended file attributes.
29
+ Add acl_write methods that accept an array of ACLStruct's.
30
+ Add support for extended file attributes.
37
31
 
38
32
  == Copyright
39
- (C) 2005-2009 Daniel J. Berger
40
- All Rights Reserved
33
+ (C) 2005-2010 Daniel J. Berger
34
+ All Rights Reserved
41
35
 
42
36
  == Warranty
43
- This package is provided "as is" and without any express or
44
- implied warranties, including, without limitation, the implied
45
- warranties of merchantability and fitness for a particular purpose.
37
+ This package is provided "as is" and without any express or
38
+ implied warranties, including, without limitation, the implied
39
+ warranties of merchantability and fitness for a particular purpose.
46
40
 
47
41
  == License
48
- Artistic 2.0
42
+ Artistic 2.0
49
43
 
50
44
  == Author
51
- Daniel J. Berger
45
+ Daniel J. Berger
data/Rakefile CHANGED
@@ -4,56 +4,50 @@ require 'rake/testtask'
4
4
  require 'rbconfig'
5
5
  include Config
6
6
 
7
- desc "Clean the build files for the solaris-file source"
8
- task :clean do
9
- FileUtils.rm_rf('solaris') if File.exists?('solaris')
10
-
11
- Dir.chdir('ext') do
12
- FileUtils.rm_rf('sfile.c') if File.exists?('sfile.c')
13
- FileUtils.rm_rf('sfile.h') if File.exists?('sfile.h')
14
- sh 'make distclean' if File.exists?('file.so')
15
- FileUtils.rm_rf('solaris/file.so') if File.exists?('solaris/file.so')
16
- end
17
- end
7
+ CLEAN.include(
8
+ '**/*.gem', # Gem files
9
+ '**/*.rbc', # Rubinius
10
+ '**/*.o', # C object file
11
+ '**/*.log', # Ruby extension build log
12
+ '**/Makefile', # C Makefile
13
+ '**/conftest.dSYM', # OS X build directory
14
+ "**/*.#{CONFIG['DLEXT']}" # C shared object
15
+ )
18
16
 
19
17
  desc "Build the solaris-file package (but don't install it)"
20
18
  task :build => [:clean] do
21
- Dir.chdir('ext') do
22
- ruby 'extconf.rb'
23
- sh 'make'
24
- Dir.mkdir('solaris') unless File.exists?('solaris')
25
- FileUtils.cp('file.so', 'solaris')
26
- end
27
- end
28
-
29
- desc "Install the solaris-file package (non-gem)"
30
- task :install => [:build] do
31
- Dir.chdir('ext') do
32
- sh 'make install'
33
- end
19
+ Dir.chdir('ext') do
20
+ ruby 'extconf.rb'
21
+ sh 'make'
22
+ Dir.mkdir('solaris') unless File.exists?('solaris')
23
+ FileUtils.cp('file.so', 'solaris')
24
+ end
34
25
  end
35
26
 
36
- desc "Install the solaris-file package as a gem"
37
- task :install_gem do
38
- ruby 'solaris-file.gemspec'
39
- file = Dir["*.gem"].first
40
- sh "gem install #{file}"
41
- end
42
-
43
- desc "Uninstall the solaris-file package. Use 'gem uninstall' for gem installs"
44
- task :uninstall => [:clean] do
45
- file = File.join(CONFIG['sitearchdir'], 'solaris', 'file.so')
46
- FileUtils.rm_rf(file, :verbose => true) if File.exists?(file)
27
+ namespace :gem do
28
+ desc "Create the solaris-file gem"
29
+ task :create => [:clean] do
30
+ spec = eval(IO.read('solaris-file.gemspec'))
31
+ Gem::Builder.new(spec).build
32
+ end
33
+
34
+ desc "Install the solaris-file gem"
35
+ task :install => [:create] do
36
+ file = Dir["*.gem"].first
37
+ sh "gem install #{file}"
38
+ end
47
39
  end
48
40
 
49
41
  desc "Run the example program"
50
42
  task :example => [:build] do
51
- ruby "-Iext examples/example_solaris_file.rb"
43
+ ruby "-Iext examples/example_solaris_file.rb"
52
44
  end
53
45
 
54
46
  Rake::TestTask.new do |t|
55
- task :test => :build
56
- t.libs << 'ext'
57
- t.warning = true
58
- t.verbose = true
47
+ task :test => :build
48
+ t.libs << 'ext'
49
+ t.warning = true
50
+ t.verbose = true
59
51
  end
52
+
53
+ task :default => :test
data/ext/solaris/sfile.c CHANGED
@@ -15,21 +15,21 @@
15
15
  * is a trivial file.
16
16
  */
17
17
  static VALUE acl_count(VALUE klass, VALUE v_path){
18
- int num_acls = 0;
19
- char pathp[PATH_MAX];
18
+ int num_acls = 0;
19
+ char pathp[PATH_MAX];
20
20
 
21
- SafeStringValue(v_path);
21
+ SafeStringValue(v_path);
22
22
 
23
- if(strlcpy(pathp, StringValuePtr(v_path), PATH_MAX) >= PATH_MAX)
24
- rb_raise(rb_eArgError, "path length exceeds limit of: %i", PATH_MAX);
23
+ if(strlcpy(pathp, StringValuePtr(v_path), PATH_MAX) >= PATH_MAX)
24
+ rb_raise(rb_eArgError, "path length exceeds limit of: %i", PATH_MAX);
25
25
 
26
- if((num_acls = acl(pathp, GETACLCNT, 0, NULL)) == -1)
27
- rb_sys_fail(0);
26
+ if((num_acls = acl(pathp, GETACLCNT, 0, NULL)) == -1)
27
+ rb_sys_fail(0);
28
28
 
29
- if(num_acls == MIN_ACL_ENTRIES)
30
- num_acls = 0;
29
+ if(num_acls == MIN_ACL_ENTRIES)
30
+ num_acls = 0;
31
31
 
32
- return INT2FIX(num_acls);
32
+ return INT2FIX(num_acls);
33
33
  }
34
34
 
35
35
  /*
@@ -40,16 +40,16 @@ static VALUE acl_count(VALUE klass, VALUE v_path){
40
40
  * the file is a trivial file.
41
41
  */
42
42
  static VALUE acl_icount(VALUE self){
43
- int num_acls = 0;
44
- int fd = FIX2INT(rb_funcall(self,rb_intern("fileno"), 0, 0));
43
+ int num_acls = 0;
44
+ int fd = FIX2INT(rb_funcall(self, rb_intern("fileno"), 0, 0));
45
45
 
46
- if((num_acls = facl(fd, GETACLCNT, 0, NULL)) == -1)
47
- rb_sys_fail(0);
46
+ if((num_acls = facl(fd, GETACLCNT, 0, NULL)) == -1)
47
+ rb_sys_fail(0);
48
48
 
49
- if(num_acls == MIN_ACL_ENTRIES)
50
- num_acls = 0;
49
+ if(num_acls == MIN_ACL_ENTRIES)
50
+ num_acls = 0;
51
51
 
52
- return INT2FIX(num_acls);
52
+ return INT2FIX(num_acls);
53
53
  }
54
54
 
55
55
  /*
@@ -65,43 +65,43 @@ static VALUE acl_icount(VALUE self){
65
65
  * Returns nil if +file_name+ is a trivial file.
66
66
  */
67
67
  static VALUE acl_read(VALUE klass, VALUE v_path){
68
- int num_acls = 0;
69
- char pathp[PATH_MAX];
70
- VALUE v_array = Qnil;
71
- int i;
68
+ int num_acls = 0;
69
+ char pathp[PATH_MAX];
70
+ VALUE v_array = Qnil;
71
+ int i;
72
72
 
73
- SafeStringValue(v_path);
73
+ SafeStringValue(v_path);
74
74
 
75
- if(strlcpy(pathp, StringValuePtr(v_path), PATH_MAX) >= PATH_MAX)
76
- rb_raise(rb_eArgError, "path length exceeds limit of: %i", PATH_MAX);
75
+ if(strlcpy(pathp, StringValuePtr(v_path), PATH_MAX) >= PATH_MAX)
76
+ rb_raise(rb_eArgError, "path length exceeds limit of: %i", PATH_MAX);
77
77
 
78
- if((num_acls = acl(pathp, GETACLCNT, 0, NULL)) == -1)
79
- rb_sys_fail(0);
78
+ if((num_acls = acl(pathp, GETACLCNT, 0, NULL)) == -1)
79
+ rb_sys_fail(0);
80
80
 
81
- if(num_acls != MIN_ACL_ENTRIES){
82
- aclent_t* acl_buf;
83
- v_array = rb_ary_new();
81
+ if(num_acls != MIN_ACL_ENTRIES){
82
+ aclent_t* acl_buf;
83
+ v_array = rb_ary_new();
84
84
 
85
- if( (acl_buf = malloc(sizeof(aclent_t) * num_acls) ) == NULL)
86
- rb_sys_fail(0);
85
+ if((acl_buf = malloc(sizeof(aclent_t) * num_acls) ) == NULL)
86
+ rb_sys_fail(0);
87
87
 
88
- if(acl(pathp, GETACL, num_acls, acl_buf) != num_acls)
89
- rb_sys_fail(0);
88
+ if(acl(pathp, GETACL, num_acls, acl_buf) != num_acls)
89
+ rb_sys_fail(0);
90
90
 
91
- for(i = 0; i < num_acls; i++){
92
- rb_ary_push(v_array,
93
- rb_struct_new(sACLStruct,
94
- acl_type_string(acl_buf[i].a_type),
95
- INT2FIX(acl_buf[i].a_id),
96
- INT2FIX(acl_buf[i].a_perm)
97
- )
98
- );
99
- }
91
+ for(i = 0; i < num_acls; i++){
92
+ rb_ary_push(v_array,
93
+ rb_struct_new(sACLStruct,
94
+ acl_type_string(acl_buf[i].a_type),
95
+ INT2FIX(acl_buf[i].a_id),
96
+ INT2FIX(acl_buf[i].a_perm)
97
+ )
98
+ );
99
+ }
100
100
 
101
- free(acl_buf);
102
- }
101
+ free(acl_buf);
102
+ }
103
103
 
104
- return v_array;
104
+ return v_array;
105
105
  }
106
106
 
107
107
  /*
@@ -117,37 +117,38 @@ static VALUE acl_read(VALUE klass, VALUE v_path){
117
117
  * Returns nil if the file is a trivial file.
118
118
  */
119
119
  static VALUE acl_iread(VALUE self){
120
- int i;
121
- int num_acls = 0;
122
- int fd = FIX2INT(rb_funcall(self, rb_intern("fileno"), 0, 0));
123
- VALUE v_array = Qnil;
120
+ int i;
121
+ int num_acls = 0;
122
+ int fd = FIX2INT(rb_funcall(self, rb_intern("fileno"), 0, 0));
123
+ VALUE v_array = Qnil;
124
+
125
+ if((num_acls = facl(fd, GETACLCNT, 0, NULL)) == -1)
126
+ rb_sys_fail(0);
127
+
128
+ if(num_acls != MIN_ACL_ENTRIES){
129
+ aclent_t* acl_buf;
130
+ v_array = rb_ary_new();
131
+
132
+ if((acl_buf = malloc(sizeof(aclent_t) * num_acls) ) == NULL)
133
+ rb_sys_fail(0);
124
134
 
125
- if( (num_acls = facl(fd, GETACLCNT, 0, NULL)) == -1)
135
+ if(facl(fd, GETACL, num_acls, acl_buf) != num_acls)
126
136
  rb_sys_fail(0);
127
137
 
128
- if(num_acls != MIN_ACL_ENTRIES){
129
- aclent_t* acl_buf;
130
- v_array = rb_ary_new();
131
-
132
- if( (acl_buf = malloc(sizeof(aclent_t) * num_acls) ) == NULL)
133
- rb_sys_fail(0);
134
-
135
- if(facl(fd, GETACL, num_acls, acl_buf) != num_acls)
136
- rb_sys_fail(0);
137
-
138
- for(i = 0; i < num_acls; i++){
139
- rb_ary_push(v_array,
140
- rb_struct_new(sACLStruct,
141
- acl_type_string(acl_buf[i].a_type),
142
- INT2FIX(acl_buf[i].a_id),
143
- INT2FIX(acl_buf[i].a_perm)
144
- )
145
- );
146
- }
147
-
148
- free(acl_buf);
149
- }
150
- return v_array;
138
+ for(i = 0; i < num_acls; i++){
139
+ rb_ary_push(v_array,
140
+ rb_struct_new(sACLStruct,
141
+ acl_type_string(acl_buf[i].a_type),
142
+ INT2FIX(acl_buf[i].a_id),
143
+ INT2FIX(acl_buf[i].a_perm)
144
+ )
145
+ );
146
+ }
147
+
148
+ free(acl_buf);
149
+ }
150
+
151
+ return v_array;
151
152
  }
152
153
 
153
154
  /*
@@ -158,34 +159,34 @@ static VALUE acl_iread(VALUE self){
158
159
  * is a trivial file, nil is returned.
159
160
  */
160
161
  static VALUE acl_read_text(VALUE klass, VALUE v_path){
161
- aclent_t* acl_buf;
162
- int num_acls = 0;
163
- char* acl_text;
164
- char pathp[PATH_MAX];
165
- VALUE v_text = Qnil;
162
+ aclent_t* acl_buf;
163
+ int num_acls = 0;
164
+ char* acl_text;
165
+ char pathp[PATH_MAX];
166
+ VALUE v_text = Qnil;
166
167
 
167
- SafeStringValue(v_path);
168
+ SafeStringValue(v_path);
168
169
 
169
- if(strlcpy(pathp, StringValuePtr(v_path), PATH_MAX) >= PATH_MAX)
170
- rb_raise(rb_eArgError, "path length exceeds limit of: %i", PATH_MAX);
170
+ if(strlcpy(pathp, StringValuePtr(v_path), PATH_MAX) >= PATH_MAX)
171
+ rb_raise(rb_eArgError, "path length exceeds limit of: %i", PATH_MAX);
171
172
 
172
- if( (num_acls = acl(pathp, GETACLCNT, 0, NULL)) == -1)
173
- rb_sys_fail(0);
173
+ if((num_acls = acl(pathp, GETACLCNT, 0, NULL)) == -1)
174
+ rb_sys_fail(0);
174
175
 
175
- if(num_acls != MIN_ACL_ENTRIES){
176
- if( (acl_buf = malloc(sizeof(aclent_t) * num_acls) ) == NULL)
177
- rb_sys_fail(0);
176
+ if(num_acls != MIN_ACL_ENTRIES){
177
+ if((acl_buf = malloc(sizeof(aclent_t) * num_acls) ) == NULL)
178
+ rb_sys_fail(0);
178
179
 
179
- if(acl(pathp, GETACL, num_acls, acl_buf) != num_acls)
180
- rb_sys_fail(0);
180
+ if(acl(pathp, GETACL, num_acls, acl_buf) != num_acls)
181
+ rb_sys_fail(0);
181
182
 
182
- acl_text = acltotext(acl_buf, num_acls);
183
+ acl_text = acltotext(acl_buf, num_acls);
183
184
 
184
- free(acl_buf);
185
- v_text = rb_str_new2(acl_text);
186
- }
185
+ free(acl_buf);
186
+ v_text = rb_str_new2(acl_text);
187
+ }
187
188
 
188
- return v_text;
189
+ return v_text;
189
190
  }
190
191
 
191
192
  /*
@@ -199,33 +200,32 @@ static VALUE acl_read_text(VALUE klass, VALUE v_path){
199
200
  * cases the offending entry number will be identified.
200
201
  */
201
202
  static VALUE acl_write_text(VALUE klass, VALUE v_path, VALUE v_text){
202
- aclent_t* acl_buf;
203
- int num_acls, which;
204
- char pathp[PATH_MAX];
205
- char* acl_text = StringValuePtr(v_text);
206
- int rv;
203
+ aclent_t* acl_buf;
204
+ int num_acls, which, rv;
205
+ char pathp[PATH_MAX];
206
+ char* acl_text = StringValuePtr(v_text);
207
207
 
208
- SafeStringValue(v_path);
209
- SafeStringValue(v_text);
208
+ SafeStringValue(v_path);
209
+ SafeStringValue(v_text);
210
210
 
211
- if(strlcpy(pathp, StringValuePtr(v_path), PATH_MAX) >= PATH_MAX)
212
- rb_raise(rb_eArgError, "path length exceeds limit of: %i", PATH_MAX);
211
+ if(strlcpy(pathp, StringValuePtr(v_path), PATH_MAX) >= PATH_MAX)
212
+ rb_raise(rb_eArgError, "path length exceeds limit of: %i", PATH_MAX);
213
213
 
214
- if((acl_buf = aclfromtext(acl_text, &num_acls)) == NULL)
215
- rb_raise(cSolarisFileError, "invalid ACL text");
214
+ if((acl_buf = aclfromtext(acl_text, &num_acls)) == NULL)
215
+ rb_raise(cSolarisFileError, "invalid ACL text");
216
216
 
217
- rv = aclcheck(acl_buf, num_acls, &which);
218
- do_acl_check(rv, which);
217
+ rv = aclcheck(acl_buf, num_acls, &which);
218
+ do_acl_check(rv, which);
219
219
 
220
- if(acl(pathp, SETACL, num_acls, acl_buf) == -1){
221
- free(acl_text);
222
- rb_sys_fail(0);
223
- }
220
+ if(acl(pathp, SETACL, num_acls, acl_buf) == -1){
221
+ free(acl_text);
222
+ rb_sys_fail(0);
223
+ }
224
224
 
225
- free(acl_text);
226
- free(acl_buf);
225
+ free(acl_text);
226
+ free(acl_buf);
227
227
 
228
- return klass;
228
+ return klass;
229
229
  }
230
230
 
231
231
  /*
@@ -238,15 +238,15 @@ static VALUE acl_write_text(VALUE klass, VALUE v_path, VALUE v_text){
238
238
  * are replaced by "/".
239
239
  */
240
240
  static VALUE solaris_resolvepath(VALUE klass, VALUE v_path){
241
- char pathp[PATH_MAX];
241
+ char pathp[PATH_MAX];
242
242
 
243
- SafeStringValue(v_path);
244
- memset(pathp, 0, PATH_MAX);
243
+ SafeStringValue(v_path);
244
+ memset(pathp, 0, PATH_MAX);
245
245
 
246
- if(resolvepath(StringValuePtr(v_path), pathp, PATH_MAX) == -1)
247
- rb_sys_fail(0);
246
+ if(resolvepath(StringValuePtr(v_path), pathp, PATH_MAX) == -1)
247
+ rb_sys_fail(0);
248
248
 
249
- return rb_str_new2(pathp);
249
+ return rb_str_new2(pathp);
250
250
  }
251
251
 
252
252
  /*
@@ -260,14 +260,14 @@ static VALUE solaris_resolvepath(VALUE klass, VALUE v_path){
260
260
  * will resolve to an absolute pathname where possible.
261
261
  */
262
262
  static VALUE solaris_realpath(VALUE klass, VALUE v_path){
263
- char pathp[PATH_MAX];
263
+ char pathp[PATH_MAX];
264
264
 
265
- SafeStringValue(v_path);
265
+ SafeStringValue(v_path);
266
266
 
267
- if(realpath(StringValuePtr(v_path), pathp) == NULL)
268
- rb_sys_fail(0);
267
+ if(realpath(StringValuePtr(v_path), pathp) == NULL)
268
+ rb_sys_fail(0);
269
269
 
270
- return rb_str_new2(pathp);
270
+ return rb_str_new2(pathp);
271
271
  }
272
272
 
273
273
  /* Instance Methods */
@@ -283,29 +283,28 @@ static VALUE solaris_realpath(VALUE klass, VALUE v_path){
283
283
  * cases the offending entry number will be identified.
284
284
  */
285
285
  static VALUE acl_iwrite_text(VALUE self, VALUE v_text){
286
- aclent_t* acl_buf;
287
- int num_acls, which;
288
- char* acl_text = StringValuePtr(v_text);
289
- int fd = FIX2INT(rb_funcall(self, rb_intern("fileno"), 0, 0));
290
- int rv;
286
+ aclent_t* acl_buf;
287
+ int num_acls, which, rv;
288
+ char* acl_text = StringValuePtr(v_text);
289
+ int fd = FIX2INT(rb_funcall(self, rb_intern("fileno"), 0, 0));
291
290
 
292
- SafeStringValue(v_text);
291
+ SafeStringValue(v_text);
293
292
 
294
- if((acl_buf = aclfromtext(acl_text, &num_acls)) == NULL)
295
- rb_raise(cSolarisFileError, "invalid ACL text");
293
+ if((acl_buf = aclfromtext(acl_text, &num_acls)) == NULL)
294
+ rb_raise(cSolarisFileError, "invalid ACL text");
296
295
 
297
- rv = aclcheck(acl_buf, num_acls, &which);
298
- do_acl_check(rv, which);
296
+ rv = aclcheck(acl_buf, num_acls, &which);
297
+ do_acl_check(rv, which);
299
298
 
300
- if(facl(fd, SETACL, num_acls, acl_buf) == -1){
301
- free(acl_text);
302
- rb_sys_fail(0);
303
- }
299
+ if(facl(fd, SETACL, num_acls, acl_buf) == -1){
300
+ free(acl_text);
301
+ rb_sys_fail(0);
302
+ }
304
303
 
305
- free(acl_text);
306
- free(acl_buf);
304
+ free(acl_text);
305
+ free(acl_buf);
307
306
 
308
- return self;
307
+ return self;
309
308
  }
310
309
 
311
310
 
@@ -317,30 +316,30 @@ static VALUE acl_iwrite_text(VALUE self, VALUE v_text){
317
316
  * the file is a trivial file, nil is returned.
318
317
  */
319
318
  static VALUE acl_iread_text(VALUE self){
320
- char* acl_text;
321
- int num_acls = 0;
322
- int fd = FIX2INT(rb_funcall(self,rb_intern("fileno"),0,0));
323
- VALUE v_text = Qnil;
319
+ char* acl_text;
320
+ int num_acls = 0;
321
+ int fd = FIX2INT(rb_funcall(self,rb_intern("fileno"),0,0));
322
+ VALUE v_text = Qnil;
324
323
 
325
- if( (num_acls = facl(fd,GETACLCNT,0,NULL)) == -1)
326
- rb_sys_fail(0);
324
+ if((num_acls = facl(fd,GETACLCNT,0,NULL)) == -1)
325
+ rb_sys_fail(0);
327
326
 
328
- if(num_acls != MIN_ACL_ENTRIES){
329
- aclent_t* acl_buf;
327
+ if(num_acls != MIN_ACL_ENTRIES){
328
+ aclent_t* acl_buf;
330
329
 
331
- if( (acl_buf = malloc(sizeof(aclent_t) * num_acls) ) == NULL)
332
- rb_sys_fail(0);
330
+ if((acl_buf = malloc(sizeof(aclent_t) * num_acls) ) == NULL)
331
+ rb_sys_fail(0);
333
332
 
334
- if(facl(fd, GETACL, num_acls, acl_buf) != num_acls)
335
- rb_sys_fail(0);
333
+ if(facl(fd, GETACL, num_acls, acl_buf) != num_acls)
334
+ rb_sys_fail(0);
336
335
 
337
- acl_text = acltotext(acl_buf,num_acls);
336
+ acl_text = acltotext(acl_buf,num_acls);
338
337
 
339
- free(acl_buf);
340
- v_text = rb_str_new2(acl_text);
341
- }
338
+ free(acl_buf);
339
+ v_text = rb_str_new2(acl_text);
340
+ }
342
341
 
343
- return v_text;
342
+ return v_text;
344
343
  }
345
344
 
346
345
  /*
@@ -351,22 +350,22 @@ static VALUE acl_iread_text(VALUE self){
351
350
  * entries. Otherwise, it returns false.
352
351
  */
353
352
  static VALUE acl_is_trivial(VALUE klass, VALUE v_path){
354
- char pathp[PATH_MAX];
355
- int num_acls = 0;
356
- VALUE v_bool = Qfalse;
353
+ char pathp[PATH_MAX];
354
+ int num_acls = 0;
355
+ VALUE v_bool = Qfalse;
357
356
 
358
- SafeStringValue(v_path);
357
+ SafeStringValue(v_path);
359
358
 
360
- if(strlcpy(pathp, StringValuePtr(v_path), PATH_MAX) >= PATH_MAX)
361
- rb_raise(rb_eArgError, "path length exceeds limit of: %i", PATH_MAX);
359
+ if(strlcpy(pathp, StringValuePtr(v_path), PATH_MAX) >= PATH_MAX)
360
+ rb_raise(rb_eArgError, "path length exceeds limit of: %i", PATH_MAX);
362
361
 
363
- if((num_acls = acl(pathp, GETACLCNT, 0, NULL)) == -1)
364
- rb_sys_fail(0);
362
+ if((num_acls = acl(pathp, GETACLCNT, 0, NULL)) == -1)
363
+ rb_sys_fail(0);
365
364
 
366
- if(num_acls == MIN_ACL_ENTRIES)
367
- v_bool = Qtrue;
365
+ if(num_acls == MIN_ACL_ENTRIES)
366
+ v_bool = Qtrue;
368
367
 
369
- return v_bool;
368
+ return v_bool;
370
369
  }
371
370
 
372
371
  /*
@@ -377,17 +376,17 @@ static VALUE acl_is_trivial(VALUE klass, VALUE v_path){
377
376
  * ACL entries. Otherwise, it returns false.
378
377
  */
379
378
  static VALUE acl_itrivial(VALUE self){
380
- int fd = FIX2INT(rb_funcall(self, rb_intern("fileno"), 0, 0));
381
- int num_acls = 0;
382
- VALUE v_bool = Qfalse;
379
+ int fd = FIX2INT(rb_funcall(self, rb_intern("fileno"), 0, 0));
380
+ int num_acls = 0;
381
+ VALUE v_bool = Qfalse;
383
382
 
384
- if( (num_acls = facl(fd, GETACLCNT, 0, NULL)) == -1)
385
- rb_sys_fail(0);
383
+ if((num_acls = facl(fd, GETACLCNT, 0, NULL)) == -1)
384
+ rb_sys_fail(0);
386
385
 
387
- if(num_acls == MIN_ACL_ENTRIES)
388
- v_bool = Qtrue;
386
+ if(num_acls == MIN_ACL_ENTRIES)
387
+ v_bool = Qtrue;
389
388
 
390
- return v_bool;
389
+ return v_bool;
391
390
  }
392
391
 
393
392
  /* File::Stat Additions */
@@ -399,83 +398,97 @@ static VALUE acl_itrivial(VALUE self){
399
398
  * Returns true if +statfile+ is a door, false otherwise.
400
399
  */
401
400
  static VALUE solaris_stat_is_door(VALUE self){
402
- struct stat stat_buf;
403
- VALUE v_bool = Qtrue;
404
- int mode = FIX2INT(rb_funcall(self, rb_intern("mode"), 0, 0));
401
+ VALUE v_bool = Qtrue;
402
+ int mode = FIX2INT(rb_funcall(self, rb_intern("mode"), 0, 0));
405
403
 
406
- if(S_ISDOOR(mode) == 0)
407
- v_bool = Qfalse;
404
+ if(S_ISDOOR(mode) == 0)
405
+ v_bool = Qfalse;
408
406
 
409
- return v_bool;
407
+ return v_bool;
410
408
  }
411
409
 
410
+ /*
411
+ * call-seq:
412
+ * statfile.ftype
413
+ *
414
+ * Returns the file type. This method is identical to the core Ruby method
415
+ * except that it returns "door" if the file is a door file.
416
+ */
412
417
  static VALUE solaris_stat_ftype(VALUE self){
413
- int mode = FIX2INT(rb_funcall(self, rb_intern("mode"), 0, 0));
418
+ int mode = FIX2INT(rb_funcall(self, rb_intern("mode"), 0, 0));
414
419
 
415
- if(S_ISDOOR(mode))
416
- return rb_str_new2("door");
417
- else
418
- return rb_funcall(self, rb_intern("old_ftype"), 0, 0);
420
+ if(S_ISDOOR(mode))
421
+ return rb_str_new2("door");
422
+ else
423
+ return rb_funcall(self, rb_intern("old_ftype"), 0, 0);
419
424
  }
420
425
 
421
- /* call-seq:
422
- * File.door?(file)
426
+ /*
427
+ * call-seq:
428
+ * File.door?(file)
423
429
  *
424
430
  * Returns true if +file+ is a door file, false otherwise.
425
431
  */
426
432
  static VALUE solaris_file_is_door(VALUE klass, VALUE v_file){
427
- VALUE v_stat = rb_funcall(rb_cStat, rb_intern("new"), 1, v_file);
428
- return solaris_stat_is_door(v_stat);
433
+ VALUE v_stat = rb_funcall(rb_cStat, rb_intern("new"), 1, v_file);
434
+ return solaris_stat_is_door(v_stat);
429
435
  }
430
436
 
431
- /* call-seq:
432
- * File.ftype(file)
437
+ /*
438
+ * call-seq:
439
+ * File.ftype(file)
433
440
  *
434
441
  * The File.ftype method was modified so that 'door' is returned if the
435
442
  * +file+ is a door file.
436
443
  */
437
444
  static VALUE solaris_file_ftype(VALUE klass, VALUE v_file){
438
- VALUE v_stat = rb_funcall(rb_cStat, rb_intern("new"), 1, v_file);
439
- return solaris_stat_ftype(v_stat);
445
+ VALUE v_stat = rb_funcall(rb_cStat, rb_intern("new"), 1, v_file);
446
+ return solaris_stat_ftype(v_stat);
440
447
  }
441
448
 
442
449
  /*
443
450
  * Adds ACL support for the File class on Solaris
444
451
  */
445
452
  void Init_file(){
446
- /* Error raised if an error occurs when reading or writing ACL properties */
447
- cSolarisFileError = rb_define_class_under(rb_cFile, "SolarisError",
448
- rb_eStandardError
449
- );
450
-
451
- /* Class Methods */
452
- rb_define_singleton_method(rb_cFile, "acl_count", acl_count, 1);
453
- rb_define_singleton_method(rb_cFile, "acl_read", acl_read, 1);
454
- rb_define_singleton_method(rb_cFile, "acl_read_text", acl_read_text, 1);
455
- rb_define_singleton_method(rb_cFile, "acl_write_text", acl_write_text, 2);
456
- rb_define_singleton_method(rb_cFile, "trivial?", acl_is_trivial, 1);
457
- rb_define_singleton_method(rb_cFile, "realpath", solaris_realpath, 1);
458
- rb_define_singleton_method(rb_cFile, "resolvepath", solaris_resolvepath, 1);
459
- rb_define_singleton_method(rb_cFile, "door?", solaris_file_is_door, 1);
460
- rb_define_singleton_method(rb_cFile, "ftype", solaris_file_ftype, 1);
461
-
462
- /* File Instance Methods */
463
- rb_define_method(rb_cFile, "acl_count", acl_icount, 0);
464
- rb_define_method(rb_cFile, "acl_read", acl_iread, 0);
465
- rb_define_method(rb_cFile, "acl_read_text", acl_iread_text, 0);
466
- rb_define_method(rb_cFile, "acl_write_text", acl_iwrite_text, 1);
467
- rb_define_method(rb_cFile, "trivial?", acl_itrivial, 0);
468
-
469
- /* File::Stat Instance Methods */
470
- rb_define_alias(rb_cStat, "old_ftype", "ftype");
471
- rb_define_method(rb_cStat, "door?", solaris_stat_is_door, 0);
472
- rb_define_method(rb_cStat, "ftype", solaris_stat_ftype, 0);
473
-
474
- /* Structs */
475
- sACLStruct = rb_struct_define("ACLStruct",
476
- "acl_type", "acl_id", "acl_perm", NULL
477
- );
478
-
479
- /* 0.3.5: The version of the solaris-file library */
480
- rb_define_const(rb_cFile, "SOLARIS_VERSION", rb_str_new2(SOLARIS_VERSION));
453
+ /* Error raised if an error occurs when reading or writing ACL properties */
454
+ cSolarisFileError = rb_define_class_under(
455
+ rb_cFile,
456
+ "SolarisError",
457
+ rb_eStandardError
458
+ );
459
+
460
+ // Singleton Methods
461
+
462
+ rb_define_singleton_method(rb_cFile, "acl_count", acl_count, 1);
463
+ rb_define_singleton_method(rb_cFile, "acl_read", acl_read, 1);
464
+ rb_define_singleton_method(rb_cFile, "acl_read_text", acl_read_text, 1);
465
+ rb_define_singleton_method(rb_cFile, "acl_write_text", acl_write_text, 2);
466
+ rb_define_singleton_method(rb_cFile, "door?", solaris_file_is_door, 1);
467
+ rb_define_singleton_method(rb_cFile, "ftype", solaris_file_ftype, 1);
468
+ rb_define_singleton_method(rb_cFile, "realpath", solaris_realpath, 1);
469
+ rb_define_singleton_method(rb_cFile, "resolvepath", solaris_resolvepath, 1);
470
+ rb_define_singleton_method(rb_cFile, "trivial?", acl_is_trivial, 1);
471
+
472
+ // File Instance Methods
473
+
474
+ rb_define_method(rb_cFile, "acl_count", acl_icount, 0);
475
+ rb_define_method(rb_cFile, "acl_read", acl_iread, 0);
476
+ rb_define_method(rb_cFile, "acl_read_text", acl_iread_text, 0);
477
+ rb_define_method(rb_cFile, "acl_write_text", acl_iwrite_text, 1);
478
+ rb_define_method(rb_cFile, "trivial?", acl_itrivial, 0);
479
+
480
+ // File::Stat Instance Methods
481
+
482
+ rb_define_alias(rb_cStat, "old_ftype", "ftype");
483
+ rb_define_method(rb_cStat, "door?", solaris_stat_is_door, 0);
484
+ rb_define_method(rb_cStat, "ftype", solaris_stat_ftype, 0);
485
+
486
+ // Structs
487
+
488
+ sACLStruct = rb_struct_define("ACLStruct",
489
+ "acl_type", "acl_id", "acl_perm", NULL
490
+ );
491
+
492
+ /* 0.3.5: The version of the solaris-file library */
493
+ rb_define_const(rb_cFile, "SOLARIS_VERSION", rb_str_new2(SOLARIS_VERSION));
481
494
  }