int dup2(int oldfd, int newfd) { if (smbw_fd(newfd)) { close(newfd); } if (smbw_fd(oldfd)) { return smbw_dup2(oldfd, newfd); } return real_dup2(oldfd, newfd); }
int dup2(int oldfd, int newfd) { check_init("dup2"); if (smbw_fd(newfd)) { (* smbw_libc.close)(newfd); } if (smbw_fd(oldfd)) { return smbw_dup2(oldfd, newfd); } return (* smbw_libc.dup2)(oldfd, newfd); }
static off64_t lseek64x(int fd, off64_t offset, int whence, off64_t (* f)(int, off64_t, int)) { off64_t ret; /* * We have left the definitions of the smbw_ functions undefined, * because types such as off_t can differ in meaning betweent his * function and smbw.c et al. Functions that return other than an * integer value, however, MUST have their return value defined. */ off64_t smbw_lseek(); if (smbw_fd(fd)) ret = smbw_lseek(fd, offset, whence); else ret = (* f)(fd, offset, whence); if (smbw_debug) { printf("lseek64x(%d, 0x%llx) returned 0x%llx\n", fd, (unsigned long long) offset, (unsigned long long) ret); } return ret; }
int getdents64(int fd, struct dirent64 *external, unsigned int count) { check_init("getdents64"); if (smbw_fd(fd)) { int i; struct SMBW_dirent *internal; int ret; int n; /* * LIMITATION: If they pass a count which is not a multiple of * the size of struct dirent, they will not get a partial * structure; we ignore the excess count. */ n = (count / sizeof(struct dirent64)); internal = malloc(sizeof(struct SMBW_dirent) * n); if (internal == NULL) { errno = ENOMEM; return -1; } ret = smbw_getdents(fd, internal, count); if (ret <= 0) return ret; ret = sizeof(struct dirent) * count; for (i = 0; count; i++, count--) dirent64_convert(&internal[i], &external[i]); return ret; } return (* smbw_libc.getdents64)(fd, external, count); }
offset_t llseek(int fd, offset_t ofs, int whence) { if (smbw_fd(fd)) { return lseek(fd, ofs, whence); } return real_llseek(fd, ofs, whence); }
static int closex(int fd, int (* f)(int fd)) { if (smbw_fd(fd)) { return smbw_close(fd); } return (* f)(fd); }
static int fcntlx(int fd, int cmd, long arg, int (* f)(int, int, long)) { if (smbw_fd(fd)) { return smbw_fcntl(fd, cmd, arg); } return (* f)(fd, cmd, arg); }
ssize_t pread64(int fd, void *buf, size_t size, off64_t ofs) { if (smbw_fd(fd)) { return smbw_pread(fd, buf, size, ofs); } return real_pread64(fd, buf, size, ofs); }
ssize_t pwrite64(int fd, const void *buf, size_t size, off64_t ofs) { if (smbw_fd(fd)) { return smbw_pwrite(fd, buf, size, ofs); } return real_pwrite64(fd, buf, size, ofs); }
off_t lseek(int fd, off_t offset, int whence) { if (smbw_fd(fd)) { return smbw_lseek(fd, offset, whence); } return real_lseek(fd, offset, whence); }
ssize_t read(int fd, void *buf, size_t count) { if (smbw_fd(fd)) { return smbw_read(fd, buf, count); } return real_read(fd, buf, count); }
int fcntl(int fd, int cmd, long arg) { if (smbw_fd(fd)) { return smbw_fcntl(fd, cmd, arg); } return real_fcntl(fd, cmd, arg); }
static ssize_t writex(int fd, void *buf, size_t count, ssize_t (* f)(int, void *, size_t)) { if (smbw_fd(fd)) { return smbw_write(fd, buf, count); } return (* f)(fd, buf, count); }
ssize_t pwrite(int fd, void *buf, size_t size, off_t ofs) { if (smbw_fd(fd)) { return smbw_pwrite(fd, buf, size, ofs); } return real_pwrite(fd, buf, size, ofs); }
int dup(int fd) { if (smbw_fd(fd)) { return smbw_dup(fd); } return real_dup(fd); }
int facl(int fd, int cmd, int nentries, void *aclbufp) { if (smbw_fd(fd)) { return smbw_facl(fd, cmd, nentries, aclbufp); } return real_facl(fd, cmd, nentries, aclbufp); }
ssize_t write(int fd, void *buf, size_t count) { if (smbw_fd(fd)) { return smbw_write(fd, buf, count); } return real_write(fd, buf, count); }
int getdents(int fd, void *dirp, unsigned int count) { if (smbw_fd(fd)) { return smbw_getdents(fd, dirp, count); } return real_getdents(fd, dirp, count); }
int fremovexattr(int fd, const char *name) { if (smbw_fd(fd)) { return smbw_fremovexattr(fd, name); } return (* smbw_libc.fremovexattr)(fd, name); }
int dup(int fd) { check_init("dup"); if (smbw_fd(fd)) { return smbw_dup(fd); } return (* smbw_libc.dup)(fd); }
ssize_t pwrite64(int fd, const void *buf, size_t size, off64_t ofs) { check_init("pwrite64"); if (smbw_fd(fd)) { return smbw_pwrite(fd, (void *) buf, size, (off_t) ofs); } return (* smbw_libc.pwrite64)(fd, (void *) buf, size, ofs); }
ssize_t pread64(int fd, void *buf, size_t size, off64_t ofs) { check_init("pread64"); if (smbw_fd(fd)) { return smbw_pread(fd, buf, size, (off_t) ofs); } return (* smbw_libc.pread64)(fd, buf, size, ofs); }
int flistxattr(int fd, char *list, size_t size) { if (smbw_fd(fd)) { return smbw_flistxattr(fd, list, size); } return (* smbw_libc.flistxattr)(fd, list, size); }
int fstat64(int fd, void *st64) { if (smbw_fd(fd)) { double xx[32]; int ret = fstat(fd, xx); stat64_convert(xx, st64); return ret; } return real_fstat64(fd, st64); }
int fchown(int fd, uid_t owner, gid_t group) { check_init("fchown"); if (smbw_fd(fd)) { /* Not yet implemented in libsmbclient */ return ENOTSUP; } return (* smbw_libc.fchown)(fd, owner, group); }
int _llseek(unsigned int fd, unsigned long offset_high, unsigned long offset_low, loff_t *result, unsigned int whence) { check_init("_llseek"); if (smbw_fd(fd)) { *result = lseek(fd, offset_low, whence); return (*result < 0 ? -1 : 0); } return (* smbw_libc._llseek)(fd, offset_high, offset_low, result, whence); }
int fchmod(int fd, mode_t mode) { check_init("fchmod"); if (smbw_fd(fd)) { /* Not yet implemented in libsmbclient */ return ENOTSUP; } return (* smbw_libc.fchmod)(fd, mode); }
int fgetxattr(int fd, const char *name, const void *value, size_t size) { if (smbw_fd(fd)) { return smbw_fgetxattr(fd, name, value, size); } return (* smbw_libc.fgetxattr)(fd, name, value, size); }
int fstat(int fd, void *st) { #if HAVE___LXSTAT return __fxstat(0, fd, st); #else if (smbw_fd(fd)) { return smbw_fstat(fd, st); } return real_fstat(fd, st); #endif }
int close(int fd) { if (smbw_fd(fd)) { return smbw_close(fd); } if (smbw_local_fd(fd)) { errno = EBADF; return -1; } return real_close(fd); }