From 97c62fdc11714f4932eefba9677ecabd72b6bfd4 Mon Sep 17 00:00:00 2001
From: dd
Date: Sun, 25 Nov 2001 21:00:38 +0000
Subject: Address two minor issues: implement the _PC_NAME_MAX and _PC_PATH_MAX
pathconf() variables for directories, and set st_size and st_blocks (of
struct stat) for directories as appropriate. Note that st_size is always set
to DEV_BSIZE, since the size of the directories is not currently kept.
Reviewed by: phk, bde
---
sys/fs/devfs/devfs_vnops.c | 31 +++++++++++++++++++++++++++++--
1 file changed, 29 insertions(+), 2 deletions(-)
(limited to 'sys/fs')
diff --git a/sys/fs/devfs/devfs_vnops.c b/sys/fs/devfs/devfs_vnops.c
index 7b445a6..e3c27a5 100644
--- a/sys/fs/devfs/devfs_vnops.c
+++ b/sys/fs/devfs/devfs_vnops.c
@@ -55,6 +55,7 @@
#include
#include
#include
+#include
#include
#include
@@ -63,6 +64,7 @@ static int devfs_access __P((struct vop_access_args *ap));
static int devfs_getattr __P((struct vop_getattr_args *ap));
static int devfs_lookupx __P((struct vop_lookup_args *ap));
static int devfs_mknod __P((struct vop_mknod_args *ap));
+static int devfs_pathconf __P((struct vop_pathconf_args *ap));
static int devfs_print __P((struct vop_print_args *ap));
static int devfs_read __P((struct vop_read_args *ap));
static int devfs_readdir __P((struct vop_readdir_args *ap));
@@ -202,8 +204,12 @@ devfs_getattr(ap)
vap->va_mode = de->de_mode;
if (vp->v_type == VLNK)
vap->va_size = de->de_dirent->d_namlen;
+ else if (vp->v_type == VDIR)
+ vap->va_size = vap->va_bytes = DEV_BSIZE;
else
vap->va_size = 0;
+ if (vp->v_type != VDIR)
+ vap->va_bytes = 0;
vap->va_blocksize = DEV_BSIZE;
vap->va_type = vp->v_type;
@@ -234,7 +240,6 @@ devfs_getattr(ap)
}
vap->va_gen = 0;
vap->va_flags = 0;
- vap->va_bytes = 0;
vap->va_nlink = de->de_links;
vap->va_fileid = de->de_inode;
@@ -454,6 +459,28 @@ notfound:
}
+static int
+devfs_pathconf(ap)
+ struct vop_pathconf_args /* {
+ struct vnode *a_vp;
+ int a_name;
+ int *a_retval;
+ } */ *ap;
+{
+
+ switch (ap->a_name) {
+ case _PC_NAME_MAX:
+ *ap->a_retval = NAME_MAX;
+ return (0);
+ case _PC_PATH_MAX:
+ *ap->a_retval = PATH_MAX;
+ return (0);
+ default:
+ return (vop_stdpathconf(ap));
+ }
+ /* NOTREACHED */
+}
+
/* ARGSUSED */
static int
devfs_print(ap)
@@ -776,7 +803,7 @@ static struct vnodeopv_entry_desc devfs_vnodeop_entries[] = {
{ &vop_getattr_desc, (vop_t *) devfs_getattr },
{ &vop_lookup_desc, (vop_t *) devfs_lookup },
{ &vop_mknod_desc, (vop_t *) devfs_mknod },
- { &vop_pathconf_desc, (vop_t *) vop_stdpathconf },
+ { &vop_pathconf_desc, (vop_t *) devfs_pathconf },
{ &vop_print_desc, (vop_t *) devfs_print },
{ &vop_read_desc, (vop_t *) devfs_read },
{ &vop_readdir_desc, (vop_t *) devfs_readdir },
--
cgit v1.1