Net-LibNFS
view release on metacpan or search on metacpan
libnfs/examples/ld_nfs.c view on Meta::CPAN
ret = ftruncate(fd, len);
close(fd);
return ret;
}
return real_truncate(path, len);
}
int (*real_fchmod)(int fd, mode_t mode);
int fchmod(int fd, mode_t mode)
{
if (nfs_fd_list[fd].is_nfs == 1) {
int ret;
LD_NFS_DPRINTF(9, "fchmod(%d, %o)", fd, (int)mode);
if ((ret = nfs_fchmod(nfs_fd_list[fd].nfs,
nfs_fd_list[fd].fh,
mode)) < 0) {
errno = -ret;
return -1;
}
return 0;
}
return real_fchmod(fd, mode);
}
int (*real_chmod)(const char *path, mode_t mode);
int chmod(const char *path, mode_t mode)
{
if (!strncmp(path, "nfs:", 4)) {
int fd, ret;
LD_NFS_DPRINTF(9, "chmod(%s, %o)", path, (int)mode);
fd = open(path, 0, 0);
if (fd == -1) {
return fd;
}
ret = fchmod(fd, mode);
close(fd);
return ret;
}
return real_chmod(path, mode);
}
int (*real_fchmodat)(int fd, const char *path, mode_t mode, int flags);
int fchmodat(int fd, const char *path, mode_t mode, int flags)
{
if (!strncmp(path, "nfs:", 4)) {
return chmod(path, mode);
}
return real_fchmodat(fd, path, mode, flags);
}
int (*real_fchown)(int fd, __uid_t uid, __gid_t gid);
int fchown(int fd, __uid_t uid, __gid_t gid)
{
if (nfs_fd_list[fd].is_nfs == 1) {
int ret;
LD_NFS_DPRINTF(9, "fchown(%d, %o, %o)", fd, (int)uid, (int)gid);
if ((ret = nfs_fchown(nfs_fd_list[fd].nfs,
nfs_fd_list[fd].fh,
uid, gid)) < 0) {
errno = -ret;
return -1;
}
return 0;
}
return real_fchown(fd, uid, gid);
}
int (*real_chown)(const char *path, __uid_t uid, __gid_t gid);
int chown(const char *path, __uid_t uid, __gid_t gid)
{
if (!strncmp(path, "nfs:", 4)) {
int fd, ret;
LD_NFS_DPRINTF(9, "chown(%s, %o, %o)", path, (int)uid, (int)gid);
fd = open(path, 0, 0);
if (fd == -1) {
return fd;
}
ret = fchown(fd, uid, gid);
close(fd);
return ret;
}
return real_chown(path, uid, gid);
}
int (*real_fchownat)(int fd, const char *path, __uid_t uid, __gid_t gid, int flags);
int fchownat(int fd, const char *path, uid_t uid, gid_t gid, int flags)
{
if (!strncmp(path, "nfs:", 4)) {
return chown(path, uid, gid);
}
return real_fchownat(fd, path, uid, gid, flags);
}
static void __attribute__((constructor)) _init(void)
{
int i;
if (getenv("LD_NFS_DEBUG") != NULL) {
debug = atoi(getenv("LD_NFS_DEBUG"));
}
if (getenv("LD_NFS_UID") != NULL) {
nfsuid = atoi(getenv("LD_NFS_UID"));
}
if (getenv("LD_NFS_GID") != NULL) {
nfsgid = atoi(getenv("LD_NFS_GID"));
}
real_open = dlsym(RTLD_NEXT, "open");
if (real_open == NULL) {
LD_NFS_DPRINTF(0, "Failed to dlsym(open)");
exit(10);
}
real_close = dlsym(RTLD_NEXT, "close");
if (real_close == NULL) {
LD_NFS_DPRINTF(0, "Failed to dlsym(close)");
exit(10);
}
real_read = dlsym(RTLD_NEXT, "read");
if (real_read == NULL) {
LD_NFS_DPRINTF(0, "Failed to dlsym(read)");
exit(10);
}
real_pread = dlsym(RTLD_NEXT, "pread");
if (real_pread == NULL) {
LD_NFS_DPRINTF(0, "Failed to dlsym(pread)");
exit(10);
}
real_write = dlsym(RTLD_NEXT, "write");
if (real_write == NULL) {
LD_NFS_DPRINTF(0, "Failed to dlsym(write)");
exit(10);
}
real_pwrite = dlsym(RTLD_NEXT, "pwrite");
if (real_pwrite == NULL) {
LD_NFS_DPRINTF(0, "Failed to dlsym(pwrite)");
exit(10);
}
real_xstat = dlsym(RTLD_NEXT, "__xstat");
if (real_xstat == NULL) {
LD_NFS_DPRINTF(0, "Failed to dlsym(__xstat)");
exit(10);
}
libnfs/examples/ld_nfs.c view on Meta::CPAN
real_fxstat64 = dlsym(RTLD_NEXT, "__fxstat64");
if (real_fxstat64 == NULL) {
LD_NFS_DPRINTF(0, "Failed to dlsym(__fxstat64)");
exit(10);
}
real_fxstatat = dlsym(RTLD_NEXT, "__fxstatat");
if (real_fxstatat == NULL) {
LD_NFS_DPRINTF(0, "Failed to dlsym(__fxstatat)");
exit(10);
}
real_fxstatat64 = dlsym(RTLD_NEXT, "__fxstatat64");
if (real_fxstatat64 == NULL) {
LD_NFS_DPRINTF(0, "Failed to dlsym(__fxstatat64)");
exit(10);
}
real_fallocate = dlsym(RTLD_NEXT, "fallocate");
if (real_fallocate == NULL) {
LD_NFS_DPRINTF(0, "Failed to dlsym(fallocate)");
exit(10);
}
real_dup2 = dlsym(RTLD_NEXT, "dup2");
if (real_dup2 == NULL) {
LD_NFS_DPRINTF(0, "Failed to dlsym(dup2)");
exit(10);
}
real_truncate = dlsym(RTLD_NEXT, "truncate");
if (real_truncate == NULL) {
LD_NFS_DPRINTF(0, "Failed to dlsym(truncate)");
exit(10);
}
real_ftruncate = dlsym(RTLD_NEXT, "ftruncate");
if (real_ftruncate == NULL) {
LD_NFS_DPRINTF(0, "Failed to dlsym(ftruncate)");
exit(10);
}
real_chmod = dlsym(RTLD_NEXT, "chmod");
if (real_chmod == NULL) {
LD_NFS_DPRINTF(0, "Failed to dlsym(chmod)");
exit(10);
}
real_fchmod = dlsym(RTLD_NEXT, "fchmod");
if (real_fchmod == NULL) {
LD_NFS_DPRINTF(0, "Failed to dlsym(fchmod)");
exit(10);
}
real_fchmodat = dlsym(RTLD_NEXT, "fchmodat");
if (real_fchmodat == NULL) {
LD_NFS_DPRINTF(0, "Failed to dlsym(fchmodat)");
exit(10);
}
real_chown = dlsym(RTLD_NEXT, "chown");
if (real_chown == NULL) {
LD_NFS_DPRINTF(0, "Failed to dlsym(chown)");
exit(10);
}
real_fchown = dlsym(RTLD_NEXT, "fchown");
if (real_fchown == NULL) {
LD_NFS_DPRINTF(0, "Failed to dlsym(fchown)");
exit(10);
}
real_fchownat = dlsym(RTLD_NEXT, "fchownat");
if (real_fchownat == NULL) {
LD_NFS_DPRINTF(0, "Failed to dlsym(fchownat)");
exit(10);
}
}
( run in 0.801 second using v1.01-cache-2.11-cpan-71847e10f99 )