| 1 |
root |
1.1 |
#!/usr/bin/perl |
| 2 |
|
|
|
| 3 |
|
|
while (<DATA>) { |
| 4 |
|
|
/^(\S+)\s+(\S+)\s+\((.*)\)$/ |
| 5 |
|
|
or (/^\s*$/ and next) |
| 6 |
|
|
or die "$_: parse error\n"; |
| 7 |
|
|
|
| 8 |
|
|
my ($ret, $name, $args) = ($1, $2, $3); |
| 9 |
|
|
my @args = split /\s*,\s*/, $args; |
| 10 |
|
|
|
| 11 |
|
|
# $ret MUST be int, or something that is < 0 on error |
| 12 |
|
|
|
| 13 |
|
|
my @cargs = map { $_ eq "path" ? "const char *" : $_ } @args; |
| 14 |
|
|
my $cargs = join ", ", @cargs; |
| 15 |
|
|
|
| 16 |
|
|
print "\nstatic $ret (*orig_$name)($cargs);\n"; |
| 17 |
|
|
print "\nextern \"C\" $ret ($name) (", (join ", ", map "$cargs[$_] a$_", 0..$#args), ")\n"; |
| 18 |
|
|
print "{\n"; |
| 19 |
|
|
for (0..$#args) { |
| 20 |
|
|
if ($args[$_] eq "path") { |
| 21 |
root |
1.3 |
#print " const char *orig_a$_ = a$_;\n"; |
| 22 |
root |
1.1 |
print " if (toolong (a$_))\n";# |
| 23 |
|
|
print " a$_ = shorten (a$_);\n"; |
| 24 |
|
|
print "\n"; |
| 25 |
|
|
} |
| 26 |
|
|
} |
| 27 |
root |
1.3 |
if ($name eq "readlink") { |
| 28 |
|
|
print " MAGIC_READLINK (a0, a1, a2);\n\n"; |
| 29 |
|
|
} elsif ($name eq "readlinkat") { |
| 30 |
|
|
print " MAGIC_READLINK (a1, a2, a3);\n\n"; |
| 31 |
|
|
} |
| 32 |
root |
1.1 |
print " if (!orig_$name)\n"; |
| 33 |
|
|
print " orig_$name = ($ret (*)($cargs))dlsym (RTLD_NEXT, \"$name\");\n"; |
| 34 |
|
|
print "\n"; |
| 35 |
|
|
print " return orig_$name (", (join ", ", map "a$_", 0..$#args), ");\n"; |
| 36 |
|
|
print "}\n"; |
| 37 |
|
|
} |
| 38 |
|
|
|
| 39 |
|
|
__END__ |
| 40 |
|
|
int open (path, int, mode_t) |
| 41 |
|
|
int creat (path, mode_t) |
| 42 |
|
|
int openat (int, path, int, mode_t) |
| 43 |
|
|
int open64 (path, int, mode_t) |
| 44 |
|
|
int openat64 (int, path, int, mode_t) |
| 45 |
|
|
int unlink (path) |
| 46 |
|
|
int unlinkat (int, path, int) |
| 47 |
root |
1.3 |
int chdir (path) |
| 48 |
root |
1.1 |
int mkdir (path, mode_t) |
| 49 |
|
|
int mkdirat (int, path, mode_t) |
| 50 |
root |
1.3 |
int rmdir (path) |
| 51 |
root |
1.1 |
ssize_t readlink (path, char *, size_t) |
| 52 |
|
|
ssize_t readlinkat (int, path, char *, size_t) |
| 53 |
root |
1.3 |
int mknod (path, mode_t, dev_t) |
| 54 |
|
|
int mknodat (int, path, mode_t, dev_t) |
| 55 |
root |
1.1 |
int stat (path, struct stat *) |
| 56 |
|
|
int lstat (path, struct stat *) |
| 57 |
|
|
int fstatat (int, path, struct stat *, int) |
| 58 |
|
|
int stat64 (path, struct stat64 *) |
| 59 |
|
|
int lstat64 (path, struct stat64 *) |
| 60 |
|
|
int fstatat64 (int, path, struct stat64 *, int) |
| 61 |
root |
1.3 |
int statx (int, path, int, unsigned int, struct statx *) |
| 62 |
root |
1.1 |
int rename (path, path) |
| 63 |
|
|
int renameat (int, path, int, path) |
| 64 |
|
|
int renameat2 (int, path, int, path, unsigned int) |
| 65 |
root |
1.3 |
int access (path, int) |
| 66 |
|
|
int faccessat (int, path, int, int) |
| 67 |
|
|
int chmod (path, mode_t) |
| 68 |
|
|
int fchmodat (int, path, mode_t, int) |
| 69 |
|
|
int chown (path, uid_t, gid_t) |
| 70 |
|
|
int lchown (path, uid_t, gid_t) |
| 71 |
|
|
int fchownat (int, path, uid_t, gid_t, int) |
| 72 |
|
|
int utime (path, const struct utimebuf *) |
| 73 |
|
|
int utimes (path, const struct timeval *) |
| 74 |
|
|
int futimesat (int, path, const struct timeval *) |
| 75 |
|
|
int utimensat (int, path, const struct timespec *, int) |
| 76 |
|
|
int symlink (path, path) |
| 77 |
|
|
int symlinkat (path, int, path) |
| 78 |
|
|
int link (path, path) |
| 79 |
|
|
int linkat (int, path, int, path, int) |
| 80 |
|
|
int truncate (path, off_t) |
| 81 |
|
|
int truncate64 (path, off64_t) |
| 82 |
|
|
|