> there. But other useful ones are missing. File.chmod and File.chown are > there, but the l-prefixed syscalls like File.lchmod and File.lchown are > missing. patch below. (note: lchmod() doesn't seem to be a Posix call; plus, i've never seen a symlink that's not precisely 0777) ----------------8<--------cut-here--------8<---------------- Index: file.c =================================================================== RCS file: /home/cvs/ruby/file.c,v retrieving revision 1.40 diff -u -r1.40 file.c --- file.c 2000/10/17 18:13:55 1.40 +++ file.c 2000/11/12 06:51:31 @@ -954,6 +954,7 @@ struct chown_args { int owner, group; + int symlink_p; }; static void @@ -961,7 +962,11 @@ const char *path; struct chown_args *args; { - if (chown(path, args->owner, args->group) < 0) + int result = args->symlink_p ? + lchown(path, args->owner, args->group) : + chown (path, args->owner, args->group); + + if (result < 0) rb_sys_fail(path); } @@ -972,25 +977,27 @@ { VALUE o, g, rest; struct chown_args arg; - int n; - rb_secure(2); rb_scan_args(argc, argv, "2*", &o, &g, &rest); - if (NIL_P(o)) { - arg.owner = -1; - } - else { - arg.owner = NUM2INT(o); - } - if (NIL_P(g)) { - arg.group = -1; - } - else { - arg.group = NUM2INT(g); - } + arg.owner = NIL_P(o) ? -1 : NUM2INT(o); + arg.group = NIL_P(g) ? -1 : NUM2INT(g); + arg.symlink_p = 0; + return INT2FIX(apply2files(chown_internal, rest, &arg)); +} - n = apply2files(chown_internal, rest, &arg); - return INT2FIX(n); +static VALUE +rb_file_s_lchown(argc, argv) + int argc; + VALUE *argv; +{ + VALUE o, g, rest; + struct chown_args arg; + rb_secure(2); + rb_scan_args(argc, argv, "2*", &o, &g, &rest); + arg.owner = NIL_P(o) ? -1 : NUM2INT(o); + arg.group = NIL_P(g) ? -1 : NUM2INT(g); + arg.symlink_p = 1; + return INT2FIX(apply2files(chown_internal, rest, &arg)); } static VALUE @@ -2202,6 +2209,7 @@ rb_define_singleton_method(rb_cFile, "utime", rb_file_s_utime, -1); rb_define_singleton_method(rb_cFile, "chmod", rb_file_s_chmod, -1); rb_define_singleton_method(rb_cFile, "chown", rb_file_s_chown, -1); + rb_define_singleton_method(rb_cFile, "lchown",rb_file_s_lchown,-1); rb_define_singleton_method(rb_cFile, "link", rb_file_s_link, 2); rb_define_singleton_method(rb_cFile, "symlink", rb_file_s_symlink, 2);