static files_struct *irix_oplock_receive_message(struct kernel_oplocks *_ctx) { struct irix_oplocks_context *ctx = talloc_get_type(_ctx->private_data, struct irix_oplocks_context); oplock_stat_t os; char dummy; struct file_id fileid; files_struct *fsp; /* * TODO: is it correct to assume we only get one * oplock break, for each byte we read from the pipe? */ ctx->pending = false; /* * Read one byte of zero to clear the * kernel break notify message. */ if(read(ctx->read_fd, &dummy, 1) != 1) { DEBUG(0,("irix_oplock_receive_message: read of kernel " "notification failed. Error was %s.\n", strerror(errno) )); return NULL; } /* * Do a query to get the * device and inode of the file that has the break * request outstanding. */ if(sys_fcntl_ptr(ctx->read_fd, F_OPLKSTAT, &os) < 0) { DEBUG(0,("irix_oplock_receive_message: fcntl of kernel " "notification failed. Error was %s.\n", strerror(errno) )); if(errno == EAGAIN) { /* * Duplicate kernel break message - ignore. */ return NULL; } return NULL; } /* * We only have device and inode info here - we have to guess that this * is the first fsp open with this dev,ino pair. * * NOTE: this doesn't work if any VFS modules overloads * the file_id_create() hook! */ fileid = file_id_create_dev((SMB_DEV_T)os.os_dev, (SMB_INO_T)os.os_ino); if ((fsp = file_find_di_first(smbd_server_conn, fileid)) == NULL) { DEBUG(0,("irix_oplock_receive_message: unable to find open " "file with dev = %x, inode = %.0f\n", (unsigned int)os.os_dev, (double)os.os_ino )); return NULL; } DEBUG(5,("irix_oplock_receive_message: kernel oplock break request " "received for file_id %s gen_id = %ul", file_id_string_tos(&fsp->file_id), fsp->fh->gen_id )); return fsp; }
static files_struct *irix_oplock_receive_message(fd_set *fds) { extern int smb_read_error; oplock_stat_t os; char dummy; files_struct *fsp; /* Ensure we only get one call per select fd set. */ FD_CLR(oplock_pipe_read, fds); /* * Read one byte of zero to clear the * kernel break notify message. */ if(read(oplock_pipe_read, &dummy, 1) != 1) { DEBUG(0,("irix_oplock_receive_message: read of kernel " "notification failed. Error was %s.\n", strerror(errno) )); smb_read_error = READ_ERROR; return NULL; } /* * Do a query to get the * device and inode of the file that has the break * request outstanding. */ if(sys_fcntl_ptr(oplock_pipe_read, F_OPLKSTAT, &os) < 0) { DEBUG(0,("irix_oplock_receive_message: fcntl of kernel " "notification failed. Error was %s.\n", strerror(errno) )); if(errno == EAGAIN) { /* * Duplicate kernel break message - ignore. */ return NULL; } smb_read_error = READ_ERROR; return NULL; } /* * We only have device and inode info here - we have to guess that this * is the first fsp open with this dev,ino pair. */ if ((fsp = file_find_di_first((SMB_DEV_T)os.os_dev, (SMB_INO_T)os.os_ino)) == NULL) { DEBUG(0,("irix_oplock_receive_message: unable to find open " "file with dev = %x, inode = %.0f\n", (unsigned int)os.os_dev, (double)os.os_ino )); return NULL; } DEBUG(5,("irix_oplock_receive_message: kernel oplock break request " "received for dev = %x, inode = %.0f\n, file_id = %ul", (unsigned int)fsp->dev, (double)fsp->inode, fsp->fh->file_id )); return fsp; }