Bugzilla – Attachment 210952 Details for
Bug 384481
Can't lock file on NFS from openSUSE-11.0
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
IDP Log In
|
Forgot Password
Testcase.
test-lock.c (text/x-c++src), 1.52 KB, created by
Petr Mladek
on 2008-04-28 19:08:31 UTC
(
hide
)
Description:
Testcase.
Filename:
MIME Type:
Creator:
Petr Mladek
Created:
2008-04-28 19:08:31 UTC
Size:
1.52 KB
patch
obsolete
>#include <stdio.h> >#include <stdlib.h> >#include <fcntl.h> >#include <sys/stat.h> > >#define OPEN_WRITE_FLAGS ( O_RDWR ) >#define OPEN_CREATE_FLAGS ( O_CREAT | O_EXCL | O_RDWR ) > > >int main ( int argc, char *argv[] ) >{ > struct flock aflock; > int fd; > int mode = S_IRUSR | S_IRGRP | S_IROTH; > int flags = O_RDONLY; > int ret; > > if (argc != 2) > { > fprintf (stderr, "Please, enter a writable file as the argument\n"); > exit(1); > } > > // locking the complete file > aflock.l_type = F_WRLCK; > aflock.l_whence = SEEK_SET; > aflock.l_start = 0; > aflock.l_len = 0; > > mode |= S_IWUSR | S_IWGRP | S_IWOTH; > flags = OPEN_WRITE_FLAGS; > > // open the file > fd = open( argv[1], flags, mode ); > > if ( fd >= 0 ) > { > printf ("Open succeeded: %s\n", argv[1]); > // lock the file > if ( -1 == fcntl( fd, F_SETLK, &aflock ) ) > { >// perror("locking:"); > fprintf (stderr, "Error: locking failed\n" ); > exit(1); > } > else > printf ("Lock succeeded: %s\n", argv[1]); > > } > else > { > fprintf (stderr, "Error: can't open file: %s for writing\n", argv[1]); > exit (1); > } > > > // release the file lock > aflock.l_type = F_UNLCK; > aflock.l_whence = SEEK_SET; > aflock.l_start = 0; > aflock.l_len = 0; > > if( -1 == fcntl( fd, F_SETLK, &aflock ) ) > { >// perror("locking:"); > fprintf (stderr, "Error: unlock failed\n" ); > } > else > printf ("Unlock succeeded: %s\n", argv[1]); > > > if( close (fd) == 0) > printf ("Close succeeded: %s\n", argv[1]); > > return 0; >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
Actions:
View
Attachments on
bug 384481
: 210952 |
210953
|
210954
|
210955
|
211089
|
212522