From b6d141c71cf3c3f3301e18c6d5dfdcc2a30d5b32 Mon Sep 17 00:00:00 2001 From: jmmv Date: Thu, 29 Sep 2005 19:48:21 +0000 Subject: [PATCH] Implement the tmpfs_advlock operation. Makes "user-level" file locking work (aka lockf(3)). --- sys/fs/tmpfs/tmpfs.h | 5 ++++- sys/fs/tmpfs/tmpfs_vnops.c | 19 +++++++++++++++++-- sys/fs/tmpfs/tmpfs_vnops.h | 4 ++-- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/sys/fs/tmpfs/tmpfs.h b/sys/fs/tmpfs/tmpfs.h index 75fde0c93566..6f5916512780 100644 --- a/sys/fs/tmpfs/tmpfs.h +++ b/sys/fs/tmpfs/tmpfs.h @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs.h,v 1.7 2005/09/28 23:42:14 yamt Exp $ */ +/* $NetBSD: tmpfs.h,v 1.8 2005/09/29 19:48:21 jmmv Exp $ */ /* * Copyright (c) 2005 The NetBSD Foundation, Inc. @@ -145,6 +145,9 @@ struct tmpfs_node { struct timespec tn_birthtime; unsigned long tn_gen; + /* Head of byte-level lock list (used by tmpfs_advlock). */ + struct lockf * tn_lockf; + /* As there is a single vnode for each active file within the * system, care has to be taken to avoid allocating more than one * vnode per file. In order to do this, a bidirectional association diff --git a/sys/fs/tmpfs/tmpfs_vnops.c b/sys/fs/tmpfs/tmpfs_vnops.c index b91998c35204..ca6373447487 100644 --- a/sys/fs/tmpfs/tmpfs_vnops.c +++ b/sys/fs/tmpfs/tmpfs_vnops.c @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_vnops.c,v 1.14 2005/09/28 23:42:14 yamt Exp $ */ +/* $NetBSD: tmpfs_vnops.c,v 1.15 2005/09/29 19:48:21 jmmv Exp $ */ /* * Copyright (c) 2005 The NetBSD Foundation, Inc. @@ -42,7 +42,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.14 2005/09/28 23:42:14 yamt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.15 2005/09/29 19:48:21 jmmv Exp $"); #include #include @@ -55,6 +55,7 @@ __KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.14 2005/09/28 23:42:14 yamt Exp $" #include #include #include +#include #include @@ -1349,6 +1350,20 @@ tmpfs_pathconf(void *v) /* --------------------------------------------------------------------- */ +int +tmpfs_advlock(void *v) +{ + struct vnode *vp = ((struct vop_advlock_args *)v)->a_vp; + + struct tmpfs_node *node; + + node = VP_TO_TMPFS_NODE(vp); + + return lf_advlock(v, &node->tn_lockf, node->tn_size); +} + +/* --------------------------------------------------------------------- */ + int tmpfs_truncate(void *v) { diff --git a/sys/fs/tmpfs/tmpfs_vnops.h b/sys/fs/tmpfs/tmpfs_vnops.h index 2ec530255ef3..7281cda5878c 100644 --- a/sys/fs/tmpfs/tmpfs_vnops.h +++ b/sys/fs/tmpfs/tmpfs_vnops.h @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_vnops.h,v 1.4 2005/09/23 15:36:15 jmmv Exp $ */ +/* $NetBSD: tmpfs_vnops.h,v 1.5 2005/09/29 19:48:21 jmmv Exp $ */ /* * Copyright (c) 2005 The NetBSD Foundation, Inc. @@ -90,7 +90,7 @@ int tmpfs_reclaim (void *); int tmpfs_print (void *); int tmpfs_pathconf (void *); #define tmpfs_islocked genfs_islocked -#define tmpfs_advlock genfs_eopnotsupp +int tmpfs_advlock (void *); #define tmpfs_blkatoff genfs_eopnotsupp #define tmpfs_valloc genfs_eopnotsupp #define tmpfs_reallocblks genfs_eopnotsupp