Fix different args to sys_fcntl without going varargs....
authorJeremy Allison <jra@samba.org>
Fri, 19 Apr 2002 17:30:27 +0000 (17:30 +0000)
committerJeremy Allison <jra@samba.org>
Fri, 19 Apr 2002 17:30:27 +0000 (17:30 +0000)
Jeremy.
(This used to be commit 65742067e07195048edcee46dae95a58a4a50950)

source3/lib/system.c
source3/lib/util.c
source3/smbd/notify_kernel.c
source3/smbd/oplock_irix.c

index eaaa76743af227c4ebff823a4b20254b98ceda31..d9a4bbd83bbc21473c5bce2c1d36c2d40709656d 100644 (file)
@@ -151,7 +151,22 @@ 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 sys_fcntl_ptr(int fd, int cmd, void *arg)
+{
+       int ret;
+
+       do {
+               errno = 0;
+               ret = fcntl(fd, cmd, arg);
+       } while (ret == -1 && errno == EINTR);
+       return ret;
+}
+
+/*******************************************************************
+A fcntl wrapper that will deal with EINTR.
+********************************************************************/
+
+int sys_fcntl_long(int fd, int cmd, long arg)
 {
        int ret;
 
index 1ee1a9c06a5ee0017b7340ce660c46513cfe13c1..ea1670ea276507ae207795abd79a10098ce7536c 100644 (file)
@@ -552,13 +552,13 @@ int set_blocking(int fd, BOOL set)
 #endif
 #endif
 
-  if((val = sys_fcntl(fd, F_GETFL, 0)) == -1)
+  if((val = sys_fcntl_long(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 sys_fcntl( fd, F_SETFL, val);
+  return sys_fcntl_long( fd, F_SETFL, val);
 #undef FLAG_TO_SET
 }
 
@@ -1353,7 +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;
 
-  ret = sys_fcntl(fd,op,&lock);
+  ret = sys_fcntl_ptr(fd,op,&lock);
 
   if (ret == -1 && errno != 0)
     DEBUG(3,("fcntl_lock: fcntl lock gave errno %d (%s)\n",errno,strerror(errno)));
index e40b91443eb943e1d08e61a0f626ed1b9721005b..f4eac38a1b4672eea6183cd8e42a2497bd2d5aec 100644 (file)
@@ -130,7 +130,7 @@ static void *kernel_register_notify(connection_struct *conn, char *path, uint32
                return NULL;
        }
 
-       if (sys_fcntl(fd, F_SETSIG, RT_SIGNAL_NOTIFY) == -1) {
+       if (sys_fcntl_long(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 (sys_fcntl(fd, F_NOTIFY, kernel_flags) == -1) {
+       if (sys_fcntl_long(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 = sys_fcntl(fd, F_NOTIFY, 0);
+       ret = sys_fcntl_long(fd, F_NOTIFY, 0);
        close(fd);
        return ret == 0;
 }
index 65ede6ef73217da70ac9d2d1d7a23055289c8cfe..c712e7d3ec45a92ae9dc33371dae3deb32b1266d 100644 (file)
@@ -56,7 +56,7 @@ static BOOL irix_oplocks_available(void)
 
        unlink(tmpname);
 
-       if(sys_fcntl(fd, F_OPLKREG, pfd[1]) == -1) {
+       if(sys_fcntl_long(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(sys_fcntl(fd, F_OPLKACK, OP_REVOKE) < 0 ) {
+       if(sys_fcntl_long(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(sys_fcntl(oplock_pipe_read, F_OPLKSTAT, &os) < 0) {
+       if(sys_fcntl_ptr(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 (sys_fcntl(fsp->fd, F_OPLKREG, oplock_pipe_write) == -1) {
+       if (sys_fcntl_long(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 = sys_fcntl(fsp->fd, F_OPLKACK, -1);
+               int state = sys_fcntl_long(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(sys_fcntl(fsp->fd, F_OPLKACK, OP_REVOKE) < 0) {
+       if(sys_fcntl_long(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",