1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835
|
/*
Copyright (C) 2014 by Ronnie Sahlberg <ronniesahlberg@gmail.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#define _GNU_SOURCE
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <stdio.h>
#include <asm/fcntl.h>
#include <nfsc/libnfs.h>
#include <sys/syscall.h>
#include <dlfcn.h>
#define NFS_MAX_FD 255
static int debug = 0;
static int nfsuid = -1;
static int nfsgid = -1;
#ifndef discard_const
#define discard_const(ptr) ((void *)((intptr_t)(ptr)))
#endif
#define LD_NFS_DPRINTF(level, fmt, args...) \
do { \
if ((debug) >= level) { \
fprintf(stderr,"ld_nfs: "); \
fprintf(stderr, (fmt), ##args); \
fprintf(stderr,"\n"); \
} \
} while (0);
struct nfs_fd_list {
int is_nfs;
struct nfs_context *nfs;
struct nfsfh *fh;
/* so we can reopen and emulate dup2() */
const char *path;
int flags;
mode_t mode;
};
static struct nfs_fd_list nfs_fd_list[NFS_MAX_FD];
int (*real_open)(__const char *path, int flags, mode_t mode);
int open(const char *path, int flags, mode_t mode)
{
if (!strncmp(path, "nfs:", 4)) {
struct nfs_context *nfs;
struct nfs_url *url;
struct nfsfh *fh = NULL;
int ret, fd;
LD_NFS_DPRINTF(9, "open(%s, %x, %o)", path, flags, mode);
nfs = nfs_init_context();
if (nfs == NULL) {
LD_NFS_DPRINTF(1, "Failed to create context");
errno = ENOMEM;
return -1;
}
if (nfsuid >= 0)
nfs_set_uid(nfs, nfsuid);
if (nfsgid >= 0)
nfs_set_gid(nfs, nfsgid);
url = nfs_parse_url_full(nfs, path);
if (url == NULL) {
LD_NFS_DPRINTF(1, "Failed to parse URL: %s\n",
nfs_get_error(nfs));
nfs_destroy_context(nfs);
errno = EINVAL;
return -1;
}
if (nfs_mount(nfs, url->server, url->path) != 0) {
LD_NFS_DPRINTF(1, "Failed to mount nfs share : %s\n",
nfs_get_error(nfs));
nfs_destroy_url(url);
nfs_destroy_context(nfs);
errno = EINVAL;
return -1;
}
if (flags & O_CREAT) {
if ((ret = nfs_creat(nfs, url->file, mode, &fh)) != 0) {
LD_NFS_DPRINTF(1, "Failed to creat nfs file : "
"%s\n", nfs_get_error(nfs));
nfs_destroy_url(url);
nfs_destroy_context(nfs);
errno = -ret;
return -1;
}
} else {
if ((ret = nfs_open(nfs, url->file, flags, &fh)) != 0) {
LD_NFS_DPRINTF(1, "Failed to open nfs file : "
"%s\n", nfs_get_error(nfs));
nfs_destroy_url(url);
nfs_destroy_context(nfs);
errno = -ret;
return -1;
}
}
fd = nfs_get_fd(nfs);
if (fd >= NFS_MAX_FD) {
LD_NFS_DPRINTF(1, "Too many files open");
nfs_destroy_url(url);
nfs_destroy_context(nfs);
errno = ENFILE;
return -1;
}
nfs_fd_list[fd].is_nfs = 1;
nfs_fd_list[fd].nfs = nfs;
nfs_fd_list[fd].fh = fh;
nfs_fd_list[fd].path = strdup(path);
nfs_fd_list[fd].flags = flags;
nfs_fd_list[fd].mode = mode;
nfs_destroy_url(url);
LD_NFS_DPRINTF(9, "open(%s) == %d", path, fd);
return fd;
}
return real_open(path, flags, mode);
}
int open64(const char *path, int flags, mode_t mode)
{
return open(path, flags | O_LARGEFILE, mode);
}
int (*real_close)(int fd);
int close(int fd)
{
if (nfs_fd_list[fd].is_nfs == 1) {
int i;
LD_NFS_DPRINTF(9, "close(%d)", fd);
nfs_fd_list[fd].is_nfs = 0;
nfs_close(nfs_fd_list[fd].nfs, nfs_fd_list[fd].fh);
nfs_fd_list[fd].fh = NULL;
nfs_destroy_context(nfs_fd_list[fd].nfs);
nfs_fd_list[fd].nfs = NULL;
free(discard_const(nfs_fd_list[fd].path));
nfs_fd_list[fd].path = NULL;
return 0;
}
return real_close(fd);
}
ssize_t (*real_read)(int fd, void *buf, size_t count);
ssize_t read(int fd, void *buf, size_t count)
{
if (nfs_fd_list[fd].is_nfs == 1) {
int ret;
LD_NFS_DPRINTF(9, "read(fd:%d count:%d)", fd, (int)count);
if ((ret = nfs_read(nfs_fd_list[fd].nfs, nfs_fd_list[fd].fh,
count, buf)) < 0) {
errno = -ret;
return -1;
}
return ret;
}
return real_read(fd, buf, count);
}
ssize_t (*real_pread)(int fd, void *buf, size_t count, off_t offset);
ssize_t pread(int fd, void *buf, size_t count, off_t offset) {
if (nfs_fd_list[fd].is_nfs == 1) {
int ret;
LD_NFS_DPRINTF(9, "pread(fd:%d offset:%d count:%d)", fd,
(int)offset, (int)count);
if ((ret = nfs_pread(nfs_fd_list[fd].nfs, nfs_fd_list[fd].fh,
offset, count, buf)) < 0) {
errno = -ret;
return -1;
}
return ret;
}
return real_pread(fd, buf, count, offset);
}
ssize_t (*real_write)(int fd, const void *buf, size_t count);
ssize_t write(int fd, const void *buf, size_t count)
{
if (nfs_fd_list[fd].is_nfs == 1) {
int ret;
LD_NFS_DPRINTF(9, "write(fd:%d count:%d)", fd, (int)count);
if ((ret = nfs_write(nfs_fd_list[fd].nfs, nfs_fd_list[fd].fh,
count,
(char *)discard_const(buf))) < 0) {
errno = -ret;
return -1;
}
return ret;
}
return real_write(fd, buf, count);
}
ssize_t (*real_pwrite)(int fd, const void *buf, size_t count, off_t offset);
ssize_t pwrite(int fd, const void *buf, size_t count, off_t offset) {
if (nfs_fd_list[fd].is_nfs == 1) {
int ret;
LD_NFS_DPRINTF(9, "pwrite(fd:%d offset:%d count:%d)", fd,
(int)offset, (int)count);
if ((ret = nfs_pwrite(nfs_fd_list[fd].nfs, nfs_fd_list[fd].fh,
offset, count,
(char *)discard_const(buf))) < 0) {
errno = -ret;
return -1;
}
return ret;
}
return real_pwrite(fd, buf, count, offset);
}
int (*real_dup2)(int oldfd, int newfd);
int dup2(int oldfd, int newfd)
{
close(newfd);
if (nfs_fd_list[oldfd].is_nfs == 1) {
struct nfs_context *nfs;
struct nfs_url *url;
struct nfsfh *fh = NULL;
int ret, fd;
LD_NFS_DPRINTF(9, "dup2(%s:%d, %d)", nfs_fd_list[oldfd].path,
oldfd, newfd);
nfs = nfs_init_context();
if (nfs == NULL) {
LD_NFS_DPRINTF(1, "Failed to create context");
errno = ENOMEM;
return -1;
}
url = nfs_parse_url_full(nfs, nfs_fd_list[oldfd].path);
if (url == NULL) {
LD_NFS_DPRINTF(1, "Failed to parse URL: %s\n",
nfs_get_error(nfs));
nfs_destroy_context(nfs);
errno = EINVAL;
return -1;
}
if (nfs_mount(nfs, url->server, url->path) != 0) {
LD_NFS_DPRINTF(1, "Failed to mount nfs share : %s\n",
nfs_get_error(nfs));
nfs_destroy_url(url);
nfs_destroy_context(nfs);
errno = EINVAL;
return -1;
}
if ((ret = nfs_open(nfs, url->file, nfs_fd_list[oldfd].mode,
&fh)) != 0) {
LD_NFS_DPRINTF(1, "Failed to open nfs file : %s\n",
nfs_get_error(nfs));
nfs_destroy_url(url);
nfs_destroy_context(nfs);
errno = -ret;
return -1;
}
/* We could actually end on the right descriptor by chance */
if (nfs_get_fd(nfs) != newfd) {
if (real_dup2(nfs_get_fd(nfs), newfd) < 0) {
LD_NFS_DPRINTF(1, "Failed to dup2 file : %d",
errno);
return -1;
}
close(rpc_get_fd(nfs_get_rpc_context(nfs)));
rpc_set_fd(nfs_get_rpc_context(nfs), newfd);
}
fd = nfs_get_fd(nfs);
if (fd >= NFS_MAX_FD) {
LD_NFS_DPRINTF(1, "Too many files open");
nfs_destroy_url(url);
nfs_destroy_context(nfs);
errno = ENFILE;
return -1;
}
nfs_fd_list[fd].is_nfs = 1;
nfs_fd_list[fd].nfs = nfs;
nfs_fd_list[fd].fh = fh;
nfs_fd_list[fd].path = strdup(nfs_fd_list[oldfd].path);
nfs_fd_list[fd].flags = nfs_fd_list[oldfd].flags;
nfs_fd_list[fd].mode = nfs_fd_list[oldfd].mode;
nfs_destroy_url(url);
LD_NFS_DPRINTF(9, "dup2(%s) successful",
nfs_fd_list[oldfd].path);
return fd;
}
return real_dup2(oldfd, newfd);
}
int (*real_xstat)(int ver, __const char *path, struct stat *buf);
int __xstat(int ver, const char *path, struct stat *buf)
{
if (!strncmp(path, "nfs:", 4)) {
int fd, ret;
LD_NFS_DPRINTF(9, "__xstat(%s)", path);
fd = open(path, 0, 0);
if (fd == -1) {
return fd;
}
ret = __fxstat(ver, fd, buf);
close(fd);
return ret;
}
return real_xstat(ver, path, buf);
}
int (*real_xstat64)(int ver, __const char *path, struct stat64 *buf);
int __xstat64(int ver, const char *path, struct stat64 *buf)
{
if (!strncmp(path, "nfs:", 4)) {
int fd, ret;
LD_NFS_DPRINTF(9, "__xstat64(%s)", path);
fd = open(path, 0, 0);
if (fd == -1) {
return fd;
}
ret = __fxstat64(ver, fd, buf);
close(fd);
return ret;
}
return real_xstat64(ver, path, buf);
}
int (*real_lxstat)(int ver, __const char *path, struct stat *buf);
int __lxstat(int ver, const char *path, struct stat *buf)
{
if (!strncmp(path, "nfs:", 4)) {
int fd, ret;
LD_NFS_DPRINTF(9, "__lxstat(%s)", path);
fd = open(path, 0, 0);
if (fd == -1) {
return fd;
}
ret = __fxstat(ver, fd, buf);
close(fd);
return ret;
}
return real_lxstat(ver, path, buf);
}
int (*real_lxstat64)(int ver, __const char *path, struct stat64 *buf);
int __lxstat64(int ver, const char *path, struct stat64 *buf)
{
if (!strncmp(path, "nfs:", 4)) {
int fd, ret;
LD_NFS_DPRINTF(9, "__lxstat64(%s)", path);
fd = open(path, 0, 0);
if (fd == -1) {
return fd;
}
ret = __fxstat64(ver, fd, buf);
close(fd);
return ret;
}
return real_lxstat64(ver, path, buf);
}
int (*real_fxstat)(int ver, int fd, struct stat *buf);
int __fxstat(int ver, int fd, struct stat *buf)
{
if (nfs_fd_list[fd].is_nfs == 1) {
int ret;
struct nfs_stat_64 st64;
LD_NFS_DPRINTF(9, "__fxstat(%d)", fd);
if ((ret = nfs_fstat64(nfs_fd_list[fd].nfs, nfs_fd_list[fd].fh,
(void *)&st64)) < 0) {
errno = -ret;
return -1;
}
buf->st_dev = st64.nfs_dev;
buf->st_ino = st64.nfs_ino;
buf->st_mode = st64.nfs_mode;
buf->st_nlink = st64.nfs_nlink;
buf->st_uid = st64.nfs_uid;
buf->st_gid = st64.nfs_gid;
buf->st_rdev = st64.nfs_rdev;
buf->st_size = st64.nfs_size;
buf->st_blksize = st64.nfs_blksize;
buf->st_blocks = st64.nfs_blocks;
buf->st_atim.tv_sec = st64.nfs_atime;
buf->st_mtim.tv_sec = st64.nfs_mtime;
buf->st_ctim.tv_sec = st64.nfs_ctime;
LD_NFS_DPRINTF(9, "__fxstat(%d) success", fd);
return ret;
}
return real_fxstat(ver, fd, buf);
}
int (*real_fxstat64)(int ver, int fd, struct stat64 *buf);
int __fxstat64(int ver, int fd, struct stat64 *buf)
{
if (nfs_fd_list[fd].is_nfs == 1) {
int ret;
struct nfs_stat_64 st64;
LD_NFS_DPRINTF(9, "__fxstat64(%d)", fd);
if ((ret = nfs_fstat64(nfs_fd_list[fd].nfs, nfs_fd_list[fd].fh,
(void *)&st64)) < 0) {
errno = -ret;
return -1;
}
buf->st_dev = st64.nfs_dev;
buf->st_ino = st64.nfs_ino;
buf->st_mode = st64.nfs_mode;
buf->st_nlink = st64.nfs_nlink;
buf->st_uid = st64.nfs_uid;
buf->st_gid = st64.nfs_gid;
buf->st_rdev = st64.nfs_rdev;
buf->st_size = st64.nfs_size;
buf->st_blksize = st64.nfs_blksize;
buf->st_blocks = st64.nfs_blocks;
buf->st_atim.tv_sec = st64.nfs_atime;
buf->st_mtim.tv_sec = st64.nfs_mtime;
buf->st_ctim.tv_sec = st64.nfs_ctime;
LD_NFS_DPRINTF(9, "__fxstat64(%d) success", fd);
return ret;
}
return real_fxstat64(ver, fd, buf);
}
int (*real_fxstatat)(int ver, int fd, const char *path, struct stat *buf, int flag);
int __fxstatat(int ver, int fd, const char *path, struct stat *buf, int flag)
{
if (!strncmp(path, "nfs:", 4)) {
return __xstat(ver, path, buf);
}
return real_fxstatat(ver, fd, path, buf, flag);
}
int (*real_fxstatat64)(int ver, int fd, const char *path, struct stat64 *buf, int flag);
int __fxstatat64(int ver, int fd, const char *path, struct stat64 *buf, int flag)
{
if (!strncmp(path, "nfs:", 4)) {
return __xstat64(ver, path, buf);
}
return real_fxstatat64(ver, fd, path, buf, flag);
}
int (*real_fallocate)(int fd, int mode, off_t offset, off_t len);
int fallocate(int fd, int mode, off_t offset, off_t len)
{
if (nfs_fd_list[fd].is_nfs == 1) {
LD_NFS_DPRINTF(9, "fallocate(%d)", fd);
errno = EOPNOTSUPP;
return -1;
}
return real_fallocate(fd, mode, offset, len);
}
int (*real_ftruncate)(int fd, off_t len);
int ftruncate(int fd, off_t len)
{
if (nfs_fd_list[fd].is_nfs == 1) {
int ret;
LD_NFS_DPRINTF(9, "ftruncate(%d, %d)", fd, (int)len);
if ((ret = nfs_ftruncate(nfs_fd_list[fd].nfs,
nfs_fd_list[fd].fh,
len)) < 0) {
errno = -ret;
return -1;
}
return 0;
}
return real_ftruncate(fd, len);
}
int (*real_truncate)(const char *path, off_t len);
int truncate(const char *path, off_t len)
{
if (!strncmp(path, "nfs:", 4)) {
int fd, ret;
LD_NFS_DPRINTF(9, "truncate(%s, %d)", path, (int)len);
fd = open(path, 0, 0);
if (fd == -1) {
return fd;
}
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);
}
real_xstat64 = dlsym(RTLD_NEXT, "__xstat64");
if (real_xstat64 == NULL) {
LD_NFS_DPRINTF(0, "Failed to dlsym(__xstat64)");
}
real_lxstat = dlsym(RTLD_NEXT, "__lxstat");
if (real_lxstat == NULL) {
LD_NFS_DPRINTF(0, "Failed to dlsym(__lxstat)");
exit(10);
}
real_lxstat64 = dlsym(RTLD_NEXT, "__lxstat64");
if (real_lxstat64 == NULL) {
LD_NFS_DPRINTF(0, "Failed to dlsym(_lxstat64)");
exit(10);
}
real_fxstat = dlsym(RTLD_NEXT, "__fxstat");
if (real_fxstat == NULL) {
LD_NFS_DPRINTF(0, "Failed to dlsym(__fxstat)");
exit(10);
}
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);
}
}
|