[oi-dev] weird flock problem

Carsten Grzemba grzemba at contac-dt.de
Mon Nov 13 08:42:39 UTC 2017


I ran in a problem with error message on openindiana:

fcntl: Invalid argument

I wrot short test program:

#include <sys/file.h>
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>


int main() {
 struct flock64 l;
 FILE *fp;

 l.l_whence = SEEK_SET;
 l.l_start = 0;
 l.l_len = 0;
 l.l_sysid = 0;
 l.l_pid = 0;

 fp = fopen("flocktest.c", "r");
 if (fp == NULL) {
 perror("fopen");
 exit(1);
 }
 l.l_type = F_UNLCK;
 if (fcntl(fileno(fp), F_FLOCK, &l) != 0) {
 perror("fcntl");
 exit(1);
 }
 printf("flocktest.c locked\n");
 return 0;
}

This compiles on Openindiana without an error, but if it runs throws the error: Invalid argument (os error 22)

If I copy this on Openindiana compiled code to Smartos it runs correctly.

OI illumos version:
SunOS oi-sr 5.11 illumos-2ee1ed1ec5 i86pc i386 i86pc
Which is:
git show 2ee1ed1ec5
commit 2ee1ed1ec5dfdf07d2c92db58b11f630de2a6e87
Author: Dan McDonald <danmcd at joyent.com>
Date: Tue Sep 12 17:38:28 2017 -0400

Smartos illumos version:
SunOS smartos 5.11 joyent_20171026T003127Z i86pc i386 i86pc

The libc shows on both the same versions:

$ elfdump -v /lib/libc.so.1

Version Definition Section: .SUNW_version
 index version dependency
 [1] libc.so.1 [ BASE ]
 [2] ILLUMOS_0.24 ILLUMOS_0.23 
 [3] ILLUMOS_0.23 ILLUMOS_0.22 
..8<..

The error message points out that the problem is in kernel.

How can I get running the fcntl flock code on Openindiana? 
The kernel builds seems to be nearly the same, but not exactly. The F_FLOCK stuff was added much earlier.
<signaturebeforequotedtext></signaturebeforequotedtext><signatureafterquotedtext>-- 
Carsten

</signatureafterquotedtext>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://openindiana.org/pipermail/oi-dev/attachments/20171113/d9927e85/attachment-0004.html>


More information about the oi-dev mailing list