[1034] in bugtraq
Re: fcntl() file locking under Solaris 2.4
daemon@ATHENA.MIT.EDU (Jas (Matthew K))
Wed Feb 22 08:33:48 1995
From: matt@uts.EDU.AU (Jas (Matthew K))
To: bugtraq@fc.net (Bugtraq Mailing List)
Date: Wed, 22 Feb 1995 22:49:33 +1100 (EST)
In-Reply-To: <9502220357.AA00602@lordmuck.itd.uts.edu.au> from "Jas (Matthew K)" at Feb 22, 95 02:57:26 pm
Jas (Matthew K) wrote this...
>
> to all you coders out there be aware file locking behaves differently
> for NFS file systems under solaris 2.4... be warned doing a ufs file
> lock on a NFS file makes fcntl() hang.. it doesnt return an error, it
> hangs.
> anyway here is a snippet of code that does a work around..
>
> instead of
> fcntl(fd,F_SETLK,&info);
> try this..
> struct statvfs vfsbuf;
> cmd=F_SETLK;
> if(!fstatvfs(fd,&vfsbuf)&&!strcmp("nfs",vfsbuf.f_basetype))
> cmd=F_RSETLK;
> fcntl(fd,cmd,&info);
>
> hope this helps..
>
> Matt
ooops i goofed i just realised.. it should have been F_SETLKW and
F_RSETLKW, they do an atomic wait and set lock.. but a ufs lock will
never occur on a NFS fd, so the net effect is that
fcntl(nfsfd,F_SETLKW,&foo) will never return... :| rather agrivating..
i think it would be much better if it returned -1 EINVAL *shrug*
Matt
--
#!/bin/sh
echo '16i[q]sa[ln0=aln100%Pln100/snlbx]sbA0D3F204445524F42snlbxq'|dc;exit
Matthew Keenan Systems Programmer Information Technology Division
University of Technology Sydney Australia
It's nice to be in a position where people apologize because they
assume there's humor in your work, based on past experience,
but they're not sure where it is. -- Rob Pike