Skip to content

Commit

Permalink
add lchown() , lmitime()
Browse files Browse the repository at this point in the history
donald committed Jul 1, 2016
1 parent 9869c77 commit 589affa
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions clusterd
Original file line number Diff line number Diff line change
@@ -511,6 +511,54 @@ sub udp_rx_amdtardata {
system '/sbin/make-automaps';
}

our ($machine,$SYS_lchown,$SYS_mknod,$lmtime_sub);
chomp($machine=`uname -m`);
if ($machine eq 'i686') {
$SYS_lchown=198; # __NR_lchown32 in /usr/include/asm/unistd.h
$SYS_mknod=14; # __NR_mknod
} elsif ($machine eq 'x86_64') {
$SYS_lchown=94; # __NR_lchown in /usr/include/asm-x86_64/unistd.h
$SYS_mknod=133; # __NR_mknod
} elsif ($machine eq 'alpha') {
$SYS_lchown=208; # SYS_lchown in /usr/include/syscall.h
$SYS_mknod=14; # SYS_mknod
} elsif ($machine eq 'amd64') {
$SYS_lchown=254; # SYS_lchown in /usr/include/syscall.h
$SYS_mknod=14; # SYS_mknod
} else {
warn "unknown machine type $machine: symlink ownership can't be set.\n";
warn "unknown machine type $machine: named pipes,character and block devices can't be created\n";
}
if ($machine eq 'x86_64') {
our $SYS_utimensat=280; # /usr/include/asm/unistd_64.h
our $AT_FDCWD=-100; # /usr/include/fcntl.h
our $UTIME_OMIT=(1<<30)-2; # /usr/include/bits/stat.h
our $AT_SYMLINK_NOFOLLOW=0x100; # /usr/include/fcntl.h

$lmtime_sub=sub {
my ($path,$mtime)=@_;
my $tsa=pack 'qqqq',0,$UTIME_OMIT,$mtime,0;
syscall($SYS_utimensat,$AT_FDCWD,$path,$tsa,$AT_SYMLINK_NOFOLLOW)==0 or return warn "$path: failed to lmtime: $!\n";
}
} else {
$lmtime_sub=sub {
my ($path,$mtime)=@_;
warn "$path: don't known how to change symlink mtime on target architecture\n";
}
}

sub lchown {
my ($uid,$gid,$path)=@_;
$SYS_lchown or return;
syscall($SYS_lchown,$path,$uid+0,$gid+0)==0 or return warn "$path: failed to lchown: $!\n";
}

sub lmtime {
my ($mtime,$path)=@_;
$lmtime_sub or return;
$lmtime_sub->($path,$mtime);
}

sub udp_rx_filedata {

# set rx_filedata_done as a side effect

0 comments on commit 589affa

Please sign in to comment.