Skip to content
Snippets Groups Projects
Commit 11b73134 authored by rswindell's avatar rswindell
Browse files

lock() for Unix now sets the appropriate lock type (shareable or exclusive)...

lock() for Unix now sets the appropriate lock type (shareable or exclusive) based on how the file was initially opened.
parent b96b3809
No related branches found
No related tags found
No related merge requests found
...@@ -179,9 +179,16 @@ long SMBCALL filelength(int fd) ...@@ -179,9 +179,16 @@ long SMBCALL filelength(int fd)
/* Sets a lock on a portion of a file */ /* Sets a lock on a portion of a file */
int SMBCALL lock(int fd, long pos, int len) int SMBCALL lock(int fd, long pos, int len)
{ {
int flags;
struct flock alock; struct flock alock;
alock.l_type = F_WRLCK; // set a write lock to prevent all access if((flags=fcntl(fd,F_GETFL))<0)
return -1;
if(flags==O_RDONLY)
alock.l_type = F_RDLCK; // set read lock to prevent writes
else
alock.l_type = F_WRLCK; // set write lock to prevent all access
alock.l_whence = L_SET; // SEEK_SET alock.l_whence = L_SET; // SEEK_SET
alock.l_start = pos; alock.l_start = pos;
alock.l_len = len; alock.l_len = len;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment