diff options
author | Jeremy Allison <jra@samba.org> | 2002-04-19 03:05:38 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2002-04-19 03:05:38 +0000 |
commit | b63be4e1abf419f68755c6b4def8d960c32e70cb (patch) | |
tree | 826d26feb65ef00455b8ba269a8d562f75fc1459 | |
parent | fc78c773f8216df1bbaa88d9007cf3f5df386e3d (diff) | |
download | samba-b63be4e1abf419f68755c6b4def8d960c32e70cb.tar.gz samba-b63be4e1abf419f68755c6b4def8d960c32e70cb.tar.bz2 samba-b63be4e1abf419f68755c6b4def8d960c32e70cb.zip |
Added sys_fcntl (not to be used everywhere). Added sys_read/sys_write
for transfer_file.
Jeremy.
(This used to be commit c7ff521bab838c070931f2b0ece4be3371fbcdbf)
-rw-r--r-- | source3/lib/system.c | 15 | ||||
-rw-r--r-- | source3/lib/util.c | 11 | ||||
-rw-r--r-- | source3/lib/util_file.c | 1 | ||||
-rw-r--r-- | source3/smbd/notify_kernel.c | 6 | ||||
-rw-r--r-- | source3/smbd/oplock_irix.c | 12 | ||||
-rw-r--r-- | source3/smbd/vfs-wrap.c | 4 |
6 files changed, 31 insertions, 18 deletions
diff --git a/source3/lib/system.c b/source3/lib/system.c index 7734328795..eaaa76743a 100644 --- a/source3/lib/system.c +++ b/source3/lib/system.c @@ -148,6 +148,21 @@ ssize_t sys_recvfrom(int s, void *buf, size_t len, int flags, struct sockaddr *f } /******************************************************************* +A fcntl wrapper that will deal with EINTR. +********************************************************************/ + +int sys_fcntl(int fd, int cmd, void *arg) +{ + int ret; + + do { + errno = 0; + ret = fcntl(fd, cmd, arg); + } while (ret == -1 && errno == EINTR); + return ret; +} + +/******************************************************************* A stat() wrapper that will deal with 64 bit filesizes. ********************************************************************/ diff --git a/source3/lib/util.c b/source3/lib/util.c index c524adaa7a..1ee1a9c06a 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -552,13 +552,13 @@ int set_blocking(int fd, BOOL set) #endif #endif - if((val = fcntl(fd, F_GETFL, 0)) == -1) + if((val = sys_fcntl(fd, F_GETFL, 0)) == -1) return -1; if(set) /* Turn blocking on - ie. clear nonblock flag */ val &= ~FLAG_TO_SET; else val |= FLAG_TO_SET; - return fcntl( fd, F_SETFL, val); + return sys_fcntl( fd, F_SETFL, val); #undef FLAG_TO_SET } @@ -620,7 +620,7 @@ ssize_t transfer_file_internal(int infd, int outfd, size_t n, ssize_t (*read_fn) SMB_OFF_T transfer_file(int infd,int outfd,SMB_OFF_T n) { - return (SMB_OFF_T)transfer_file_internal(infd, outfd, (size_t)n, read, write); + return (SMB_OFF_T)transfer_file_internal(infd, outfd, (size_t)n, sys_read, sys_write); } /******************************************************************* @@ -1353,10 +1353,7 @@ BOOL fcntl_lock(int fd, int op, SMB_OFF_T offset, SMB_OFF_T count, int type) lock.l_len = count; lock.l_pid = 0; - do { - errno = 0; - ret = fcntl(fd,op,&lock); - } while (ret == -1 && errno == EINTR); + ret = sys_fcntl(fd,op,&lock); if (ret == -1 && errno != 0) DEBUG(3,("fcntl_lock: fcntl lock gave errno %d (%s)\n",errno,strerror(errno))); diff --git a/source3/lib/util_file.c b/source3/lib/util_file.c index e80267f84b..fd3aeb99d9 100644 --- a/source3/lib/util_file.c +++ b/source3/lib/util_file.c @@ -51,6 +51,7 @@ BOOL do_file_lock(int fd, int waitsecs, int type) lock.l_pid = 0; alarm(waitsecs); + /* Note we must *NOT* use sys_fcntl here ! JRA */ ret = fcntl(fd, SMB_F_SETLKW, &lock); alarm(0); CatchSignal(SIGALRM, SIGNAL_CAST SIG_IGN); diff --git a/source3/smbd/notify_kernel.c b/source3/smbd/notify_kernel.c index 19ea41e195..e40b91443e 100644 --- a/source3/smbd/notify_kernel.c +++ b/source3/smbd/notify_kernel.c @@ -130,7 +130,7 @@ static void *kernel_register_notify(connection_struct *conn, char *path, uint32 return NULL; } - if (fcntl(fd, F_SETSIG, RT_SIGNAL_NOTIFY) == -1) { + if (sys_fcntl(fd, F_SETSIG, RT_SIGNAL_NOTIFY) == -1) { DEBUG(3,("Failed to set signal handler for change notify\n")); return NULL; } @@ -147,7 +147,7 @@ static void *kernel_register_notify(connection_struct *conn, char *path, uint32 if (flags & FILE_NOTIFY_CHANGE_EA) kernel_flags |= DN_ATTRIB; if (flags & FILE_NOTIFY_CHANGE_FILE_NAME) kernel_flags |= DN_RENAME|DN_DELETE; - if (fcntl(fd, F_NOTIFY, kernel_flags) == -1) { + if (sys_fcntl(fd, F_NOTIFY, kernel_flags) == -1) { DEBUG(3,("Failed to set async flag for change notify\n")); return NULL; } @@ -168,7 +168,7 @@ static BOOL kernel_notify_available(void) int fd, ret; fd = open("/tmp", O_RDONLY); if (fd == -1) return False; /* uggh! */ - ret = fcntl(fd, F_NOTIFY, 0); + ret = sys_fcntl(fd, F_NOTIFY, 0); close(fd); return ret == 0; } diff --git a/source3/smbd/oplock_irix.c b/source3/smbd/oplock_irix.c index 14f6de27c4..65ede6ef73 100644 --- a/source3/smbd/oplock_irix.c +++ b/source3/smbd/oplock_irix.c @@ -56,7 +56,7 @@ static BOOL irix_oplocks_available(void) unlink(tmpname); - if(fcntl(fd, F_OPLKREG, pfd[1]) == -1) { + if(sys_fcntl(fd, F_OPLKREG, pfd[1]) == -1) { DEBUG(0,("check_kernel_oplocks: Kernel oplocks are not available on this machine. \ Disabling kernel oplock support.\n" )); close(pfd[0]); @@ -65,7 +65,7 @@ Disabling kernel oplock support.\n" )); return False; } - if(fcntl(fd, F_OPLKACK, OP_REVOKE) < 0 ) { + if(sys_fcntl(fd, F_OPLKACK, OP_REVOKE) < 0 ) { DEBUG(0,("check_kernel_oplocks: Error when removing kernel oplock. Error was %s. \ Disabling kernel oplock support.\n", strerror(errno) )); close(pfd[0]); @@ -111,7 +111,7 @@ Error was %s.\n", strerror(errno) )); * request outstanding. */ - if(fcntl(oplock_pipe_read, F_OPLKSTAT, &os) < 0) { + if(sys_fcntl(oplock_pipe_read, F_OPLKSTAT, &os) < 0) { DEBUG(0,("receive_local_message: fcntl of kernel notification failed. \ Error was %s.\n", strerror(errno) )); if(errno == EAGAIN) { @@ -164,7 +164,7 @@ dev = %x, inode = %.0f\n, file_id = %ul", (unsigned int)fsp->dev, (double)fsp->i static BOOL irix_set_kernel_oplock(files_struct *fsp, int oplock_type) { - if (fcntl(fsp->fd, F_OPLKREG, oplock_pipe_write) == -1) { + if (sys_fcntl(fsp->fd, F_OPLKREG, oplock_pipe_write) == -1) { if(errno != EAGAIN) { DEBUG(0,("set_file_oplock: Unable to get kernel oplock on file %s, dev = %x, \ inode = %.0f, file_id = %ul. Error was %s\n", @@ -195,7 +195,7 @@ static void irix_release_kernel_oplock(files_struct *fsp) * Check and print out the current kernel * oplock state of this file. */ - int state = fcntl(fsp->fd, F_OPLKACK, -1); + int state = sys_fcntl(fsp->fd, F_OPLKACK, -1); dbgtext("release_kernel_oplock: file %s, dev = %x, inode = %.0f file_id = %ul, has kernel \ oplock state of %x.\n", fsp->fsp_name, (unsigned int)fsp->dev, (double)fsp->inode, fsp->file_id, state ); @@ -204,7 +204,7 @@ oplock state of %x.\n", fsp->fsp_name, (unsigned int)fsp->dev, /* * Remove the kernel oplock on this file. */ - if(fcntl(fsp->fd, F_OPLKACK, OP_REVOKE) < 0) { + if(sys_fcntl(fsp->fd, F_OPLKACK, OP_REVOKE) < 0) { if( DEBUGLVL( 0 )) { dbgtext("release_kernel_oplock: Error when removing kernel oplock on file " ); dbgtext("%s, dev = %x, inode = %.0f, file_id = %ul. Error was %s\n", diff --git a/source3/smbd/vfs-wrap.c b/source3/smbd/vfs-wrap.c index fadc435a2f..394086dc07 100644 --- a/source3/smbd/vfs-wrap.c +++ b/source3/smbd/vfs-wrap.c @@ -147,7 +147,7 @@ ssize_t vfswrap_read(files_struct *fsp, int fd, void *data, size_t n) ssize_t result; START_PROFILE_BYTES(syscall_read, n); - result = read(fd, data, n); + result = sys_read(fd, data, n); END_PROFILE(syscall_read); return result; } @@ -157,7 +157,7 @@ ssize_t vfswrap_write(files_struct *fsp, int fd, const void *data, size_t n) ssize_t result; START_PROFILE_BYTES(syscall_write, n); - result = write(fd, data, n); + result = sys_write(fd, data, n); END_PROFILE(syscall_write); return result; } |