Skip to content

Commit

Permalink
build: Add more assertions that fcntl locking works 64-bit
Browse files Browse the repository at this point in the history
  • Loading branch information
abartlet committed Apr 5, 2012
1 parent 22d9450 commit 0732311
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions tests/fcntl_lock.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ int main(int argc, char *argv[])

lock.l_type = F_WRLCK;
lock.l_whence = SEEK_SET;
lock.l_start = 0;
lock.l_start = 0x100000000LL;
lock.l_len = 4;
lock.l_pid = getpid();

Expand Down Expand Up @@ -92,16 +92,27 @@ int main(int argc, char *argv[])
lock.l_type = F_WRLCK;
lock.l_whence = SEEK_SET;
lock.l_start = 0;
lock.l_len = 4;
lock.l_len = 0x100000004LL;
lock.l_pid = getpid();

/* set a 4 byte write lock */
fcntl(fd,F_SETLK,&lock);
/* set a 100000004 byte write lock, should conflict with the above */
ret = fcntl(fd,F_SETLK,&lock);

sys_waitpid(pid, &status, 0);

unlink(DATA);

if (ret != 0) {
fprintf(stderr,"ERROR: failed to lock %s (errno=%d)\n",
DATA, (int)errno);
exit(1);
}

if (lock.l_len < 0x100000004LL) {
fprintf(stderr,"ERROR: settign lock overflowed\n");
exit(1);
}

#if defined(WIFEXITED) && defined(WEXITSTATUS)
if(WIFEXITED(status)) {
status = WEXITSTATUS(status);
Expand Down

0 comments on commit 0732311

Please sign in to comment.