From mboxrd@z Thu Jan 1 00:00:00 1970 Message-Id: <200406241343.i5ODhHX11030@zamenhof.cs.utwente.nl> To: Fans of the OS Plan 9 from Bell Labs <9fans@cse.psu.edu> Subject: Re: [9fans] plan9port (: flock) on sunos5.8? In-reply-to: Your message of "Thu, 24 Jun 2004 09:03:08 +0000." References: <200406232047.i5NKlLK16116@zamenhof.cs.utwente.nl> From: Axel Belinfante Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Thu, 24 Jun 2004 15:43:16 +0200 Topicbox-Message-UUID: abbd6f60-eacd-11e9-9e20-41e7f4b1d025 > > lib9/create.c needs/uses bsd-style flock which is not available by default, > > but accessable using /usr/usb/cc > i think that it is very difficult to use the sun flock(), without > breaking many things. > > what is the intended effect? perhaps another lock function (lockf(), > fcntl(), etc) can be used? > my plan9port is plan9-20040517.tar.gz ... I'm using the cvs access, and updated yesterday or so. Actually, the problem is rather limited: there are only two calls. (I posted here mainly because, as I wrote, I knew nothing about it). they are used to implement the OLOCK mode bit for create and open, in lib9/^(create open)^.c according to the sun man page, the compatibility flock builds on fcntl so I decided to just use fcntl directly. I added a #include to the list of includes and a struct flock lockdata variable to the routine (create or open), and then I replaced if(flock(fd, (rdwr==OREAD) ? LOCK_SH : LOCK_EX) < 0){ by lockdata.l_type = (rdwr==OREAD) ? F_RDLCK : F_WRLCK; lockdata.l_whence = SEEK_SET; lockdata.l_start = 0; lockdata.l_len = 0; if(fcntl(fd, F_SETLK, &lockdata) < 0){ which at least compiles ok, and as far as I could figure from the man pages should have the right effect. One other thing needs attention in this plan9port version: libip/eipfmt.c has the following definition that sun cc does not grok uchar prefixvals[256] = { [0x00] 0 | Isprefix, [0x80] 1 | Isprefix, [0xC0] 2 | Isprefix, [0xE0] 3 | Isprefix, [0xF0] 4 | Isprefix, [0xF8] 5 | Isprefix, [0xFC] 6 | Isprefix, [0xFE] 7 | Isprefix, [0xFF] 8 | Isprefix, }; I moved the initialization inside the eipfmt routine. for the rest of this plan9port version... compilation when fine, apart from some warnings: in libdraw/x11-init.c in XParseGeometry signed/unsigned int warning for &width and &height in cmd/9660/dump9660.c in convertnames a couple of (void*) casts where sun cc prefers (char* (*)(char*,char*)) in cmd/9660/unix.c a superflous `;' at the end of dirtoxdir furthermore: gview.c:173: warning: initializer does not fit or is out of range: -5592321 gview.c:174: warning: initializer does not fit or is out of range: -872414977 gview.c:175: warning: initializer does not fit or is out of range: -5635841 gview.c:177: warning: initializer does not fit or is out of range: -1431699201 gview.c:182: warning: initializer does not fit or is out of range: -1431633921 gview.c:184: warning: initializer does not fit or is out of range: -1728013825 gview.c:185: warning: initializer does not fit or is out of range: -1145324545 I do have some own hacks that I did not remove when updating from cvs, and I did not test (use) much yet, after compiling, but what I have tried works fine. Axel.