mirror of
https://github.com/samba-team/samba.git
synced 2024-12-28 07:21:54 +03:00
- added pread pread64 pwrite pwrite64 and open64
- fixed utime() for null tbuf
(This used to be commit 9047bf59b4
)
This commit is contained in:
parent
5d14f89324
commit
92b21b3e82
@ -177,6 +177,37 @@
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef HAVE__OPEN64
|
||||
#define real_open64(fn,fl,m) (_open64(fn,fl,m))
|
||||
#elif HAVE___OPEN64
|
||||
#define real_open64(fn,fl,m) (__open64(fn,fl,m))
|
||||
#endif
|
||||
|
||||
#ifdef HAVE__PREAD
|
||||
#define real_pread(fd,buf,size,ofs) (_pread(fd,buf,size,ofs))
|
||||
#elif HAVE___PREAD
|
||||
#define real_pread(fd,buf,size,ofs) (__pread(fd,buf,size,ofs))
|
||||
#endif
|
||||
|
||||
#ifdef HAVE__PREAD64
|
||||
#define real_pread64(fd,buf,size,ofs) (_pread64(fd,buf,size,ofs))
|
||||
#elif HAVE___PREAD64
|
||||
#define real_pread64(fd,buf,size,ofs) (__pread64(fd,buf,size,ofs))
|
||||
#endif
|
||||
|
||||
#ifdef HAVE__PWRITE
|
||||
#define real_pwrite(fd,buf,size,ofs) (_pwrite(fd,buf,size,ofs))
|
||||
#elif HAVE___PWRITE
|
||||
#define real_pwrite(fd,buf,size,ofs) (__pwrite(fd,buf,size,ofs))
|
||||
#endif
|
||||
|
||||
#ifdef HAVE__PWRITE64
|
||||
#define real_pwrite64(fd,buf,size,ofs) (_pwrite64(fd,buf,size,ofs))
|
||||
#elif HAVE___PWRITE64
|
||||
#define real_pwrite64(fd,buf,size,ofs) (__pwrite64(fd,buf,size,ofs))
|
||||
#endif
|
||||
|
||||
|
||||
#define real_readlink(fn,buf,len) (syscall(SYS_readlink, (fn), (buf), (len)))
|
||||
#define real_rename(fn1, fn2) (syscall(SYS_rename, (fn1), (fn2)))
|
||||
#define real_symlink(fn1, fn2) (syscall(SYS_symlink, (fn1), (fn2)))
|
||||
|
@ -606,6 +606,38 @@ int smbw_open(const char *fname, int flags, mode_t mode)
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************
|
||||
a wrapper for pread()
|
||||
*******************************************************/
|
||||
ssize_t smbw_pread(int fd, void *buf, size_t count, off_t ofs)
|
||||
{
|
||||
struct smbw_file *file;
|
||||
int ret;
|
||||
|
||||
DEBUG(4,("%s %d\n",
|
||||
__FUNCTION__, (int)count));
|
||||
|
||||
smbw_busy++;
|
||||
|
||||
file = smbw_file(fd);
|
||||
if (!file) {
|
||||
errno = EBADF;
|
||||
smbw_busy--;
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = cli_read(&file->srv->cli, file->f->cli_fd, buf, ofs, count);
|
||||
|
||||
if (ret == -1) {
|
||||
errno = smbw_errno(&file->srv->cli);
|
||||
smbw_busy--;
|
||||
return -1;
|
||||
}
|
||||
|
||||
smbw_busy--;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*****************************************************
|
||||
a wrapper for read()
|
||||
*******************************************************/
|
||||
@ -626,7 +658,8 @@ ssize_t smbw_read(int fd, void *buf, size_t count)
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = cli_read(&file->srv->cli, file->f->cli_fd, buf, file->f->offset, count);
|
||||
ret = cli_read(&file->srv->cli, file->f->cli_fd, buf,
|
||||
file->f->offset, count);
|
||||
|
||||
if (ret == -1) {
|
||||
errno = smbw_errno(&file->srv->cli);
|
||||
@ -640,6 +673,8 @@ ssize_t smbw_read(int fd, void *buf, size_t count)
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*****************************************************
|
||||
a wrapper for write()
|
||||
*******************************************************/
|
||||
@ -674,6 +709,38 @@ ssize_t smbw_write(int fd, void *buf, size_t count)
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*****************************************************
|
||||
a wrapper for pwrite()
|
||||
*******************************************************/
|
||||
ssize_t smbw_pwrite(int fd, void *buf, size_t count, off_t ofs)
|
||||
{
|
||||
struct smbw_file *file;
|
||||
int ret;
|
||||
|
||||
DEBUG(4,("%s\n", __FUNCTION__));
|
||||
|
||||
smbw_busy++;
|
||||
|
||||
file = smbw_file(fd);
|
||||
if (!file) {
|
||||
DEBUG(3,("bad fd in read\n"));
|
||||
errno = EBADF;
|
||||
smbw_busy--;
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = cli_write(&file->srv->cli, file->f->cli_fd, buf, ofs, count);
|
||||
|
||||
if (ret == -1) {
|
||||
errno = smbw_errno(&file->srv->cli);
|
||||
smbw_busy--;
|
||||
return -1;
|
||||
}
|
||||
|
||||
smbw_busy--;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*****************************************************
|
||||
a wrapper for close()
|
||||
*******************************************************/
|
||||
@ -877,7 +944,7 @@ int smbw_utime(const char *fname, void *buf)
|
||||
pstring path;
|
||||
uint32 mode;
|
||||
|
||||
DEBUG(4,("%s (%s)\n", __FUNCTION__, fname));
|
||||
DEBUG(4,("%s (%s, 0x%x)\n", __FUNCTION__, fname, (unsigned)buf));
|
||||
|
||||
if (!fname) {
|
||||
errno = EINVAL;
|
||||
@ -903,7 +970,8 @@ int smbw_utime(const char *fname, void *buf)
|
||||
goto failed;
|
||||
}
|
||||
|
||||
if (!cli_setatr(&srv->cli, path, mode, tbuf->modtime)) {
|
||||
if (!cli_setatr(&srv->cli, path, mode,
|
||||
tbuf?tbuf->modtime:time(NULL))) {
|
||||
errno = smbw_errno(&srv->cli);
|
||||
goto failed;
|
||||
}
|
||||
|
@ -37,6 +37,61 @@ __asm__(".globl __open; __open = open");
|
||||
return real_open(name, flags, mode);
|
||||
}
|
||||
|
||||
#ifdef HAVE_OPEN64
|
||||
int open64(const char *name, int flags, mode_t mode)
|
||||
{
|
||||
if (smbw_path(name)) {
|
||||
return smbw_open(name, flags, mode);
|
||||
}
|
||||
|
||||
return real_open64(name, flags, mode);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PREAD
|
||||
ssize_t pread(int fd, void *buf, size_t size, off_t ofs)
|
||||
{
|
||||
if (smbw_fd(fd)) {
|
||||
return smbw_pread(fd, buf, size, ofs);
|
||||
}
|
||||
|
||||
return real_pread(fd, buf, size, ofs);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PREAD64
|
||||
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);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PWRITE
|
||||
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);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PWRITE64
|
||||
ssize_t pwrite64(int fd, 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);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef HAVE___CHDIR
|
||||
__asm__(".globl __chdir; __chdir = chdir");
|
||||
@ -628,6 +683,11 @@ __asm__(".globl _write; _write = write");
|
||||
{
|
||||
return open(path, O_WRONLY|O_CREAT|O_TRUNC, mode);
|
||||
}
|
||||
|
||||
int creat64(const char *path, mode_t mode)
|
||||
{
|
||||
return open64(path, O_WRONLY|O_CREAT|O_TRUNC, mode);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STAT64
|
||||
|
Loading…
Reference in New Issue
Block a user