Bugtraq mailing list archives

fcntl() file locking under Solaris 2.4


From: matt () uts EDU AU (Jas)
Date: Wed, 22 Feb 1995 14:57:26 +1100 (EST)


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
P.S. i have posted patches for both pine and elm to the sun-managers list
-- 
#!/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



Current thread: