static int set_unix_lock( struct fd *fd, file_pos_t start, file_pos_t end, int type )
{
struct flock fl;
+ int lock_fd;
if (!fd->fs_locks) return 1; /* no fs locks possible for this fd */
for (;;)
if (!fl.l_len) {
TRACEL(stderr, "LEN is NULL!!!!!!!!!!");
}
- if (fcntl( inode_get_lock_fd( fd->inode ), F_SETLK, &fl ) != -1) return 1;
+ lock_fd = inode_get_lock_fd( fd->inode );
+ if (lock_fd == -1) lock_fd = fd->unix_fd;
+ if (fcntl( lock_fd, F_SETLK, &fl ) != -1) return 1;
/* perror("Etersoft warning (some error during lock):"); */
switch(errno)
{
unsigned int existing_sharing = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE;
unsigned int existing_access = 0;
struct list *ptr;
+ int lock_fd;
/* if access mode is 0, sharing mode is ignored */
if (!access) sharing = existing_sharing;
}
/* Etersoft: Set existing modes from special lock region state, get cifs status */
if (etersoft_sharing_set_test_fd)
- etersoft_sharing_set_test_fd( inode_get_lock_fd( fd->inode ) );
+ {
+ lock_fd = inode_get_lock_fd( fd->inode );
+ if (lock_fd == -1 && (access & FILE_UNIX_READ_ACCESS) &&
+ (access & FILE_UNIX_WRITE_ACCESS))
+ lock_fd = fd->unix_fd;
+ etersoft_sharing_set_test_fd( lock_fd );
+ }
if (etersoft_sharing_pre)
fd->cifs = etersoft_sharing_pre(fd->unix_fd, fd->access, fd->sharing,
&existing_access, &existing_sharing);
fd->closed = closed_fd;
list_add_head( &inode->open, &fd->inode_entry );
- if (inode_get_lock_fd( inode ) == -1)
+ if (rw_mode != O_RDWR && inode_get_lock_fd( inode ) == -1)
{
lock_fd = open( name, O_RDWR );
inode_set_lock_fd( inode, lock_fd );