Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 18 Nov 2002 20:19:30 -0800
From:      Terry Lambert <tlambert2@mindspring.com>
To:        "Clark C. Evans" <cce@clarkevans.com>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: cd9660 and fcntl (shared locks)
Message-ID:  <3DD9BBD2.E622B74F@mindspring.com>
References:  <20021119032023.GA54980@doublegemini.com>

next in thread | previous in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.
--------------A92E3CA1A58A73776799BC8D
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

"Clark C. Evans" wrote:
> When I open a file mounted via cd9660 as O_RDONLY and then flock(fd,LOCK_SH)
> it returns invalid argument; is there a reason why the cd-rom file
> system can't just return success here, make flock a no-op that is always
> successful?  There are many cases where you want general code to use
> shared locks on files opened for reading to make sure that it doesn't
> get changed during the read.  This general code should be useable on
> file systems mounted read only.
> 
> Thoughts?  Is there an easy patch?

FreeBSD implements advisory locking wrong; I've tried to get it
fixed several times, but no one is interested.

It looks like someone started to add suport, but then didn't, and
perpetuated the implementation problem.

Here is a patch which finishes adding add advisory locking support
to isofs (wrong way to do it, but only way to do it without changing
VOP_ADVLOCK semantics).

-- Terry
--------------A92E3CA1A58A73776799BC8D
Content-Type: text/plain; charset=us-ascii;
 name="cd9660.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="cd9660.diff"

Index: isofs/cd9660/cd9660_vnops.c
===================================================================
RCS file: /cvs/src/sys/isofs/cd9660/cd9660_vnops.c,v
retrieving revision 1.80
diff -c -r1.80 cd9660_vnops.c
*** isofs/cd9660/cd9660_vnops.c	28 Sep 2002 17:14:52 -0000	1.80
--- isofs/cd9660/cd9660_vnops.c	19 Nov 2002 00:13:27 -0000
***************
*** 53,58 ****
--- 53,59 ----
  #include <sys/dirent.h>
  #include <sys/unistd.h>
  #include <sys/filio.h>
+ #include <sys/lockf.h>
  
  #include <vm/vm.h>
  #include <vm/vnode_pager.h>
***************
*** 64,69 ****
--- 65,71 ----
  
  static int cd9660_setattr(struct vop_setattr_args *);
  static int cd9660_access(struct vop_access_args *);
+ static int cd9660_advlock(struct vop_advlock_args *);
  static int cd9660_getattr(struct vop_getattr_args *);
  static int cd9660_ioctl(struct vop_ioctl_args *);
  static int cd9660_pathconf(struct vop_pathconf_args *);
***************
*** 776,787 ****
--- 778,808 ----
  }
  
  /*
+  * Advisory record locking support
+  */
+ static int
+ cd9660_advlock(ap)
+ 	struct vop_advlock_args /* {
+ 		struct vnode *a_vp;
+ 		caddr_t  a_id;
+ 		int  a_op;
+ 		struct flock *a_fl;
+ 		int  a_flags;
+ 	} */ *ap;
+ {
+ 	struct iso_node *ip = VTOI(ap->a_vp);
+ 
+ 	return (lf_advlock(ap, &(ip->i_lockf), ip->i_size));
+ }
+ 
+ /*
   * Global vfs data structures for cd9660
   */
  vop_t **cd9660_vnodeop_p;
  static struct vnodeopv_entry_desc cd9660_vnodeop_entries[] = {
  	{ &vop_default_desc,		(vop_t *) vop_defaultop },
  	{ &vop_access_desc,		(vop_t *) cd9660_access },
+ 	{ &vop_advlock_desc,		(vop_t *) cd9660_advlock },
  	{ &vop_bmap_desc,		(vop_t *) cd9660_bmap },
  	{ &vop_cachedlookup_desc,	(vop_t *) cd9660_lookup },
  	{ &vop_getattr_desc,		(vop_t *) cd9660_getattr },

--------------A92E3CA1A58A73776799BC8D--


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3DD9BBD2.E622B74F>