Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/fs/hfs KNF, no functional changes intended.



details:   https://anonhg.NetBSD.org/src/rev/b0422fc1c329
branches:  trunk
changeset: 761760:b0422fc1c329
user:      christos <christos%NetBSD.org@localhost>
date:      Mon Feb 07 02:06:20 2011 +0000

description:
KNF, no functional changes intended.

diffstat:

 sys/fs/hfs/hfs_vnops.c |  225 ++++++++++++++++++++++++------------------------
 1 files changed, 114 insertions(+), 111 deletions(-)

diffs (truncated from 503 to 300 lines):

diff -r 1a950dba32aa -r b0422fc1c329 sys/fs/hfs/hfs_vnops.c
--- a/sys/fs/hfs/hfs_vnops.c    Mon Feb 07 01:37:12 2011 +0000
+++ b/sys/fs/hfs/hfs_vnops.c    Mon Feb 07 02:06:20 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: hfs_vnops.c,v 1.18 2010/06/24 13:03:09 hannken Exp $   */
+/*     $NetBSD: hfs_vnops.c,v 1.19 2011/02/07 02:06:20 christos Exp $  */
 
 /*-
  * Copyright (c) 2005, 2007 The NetBSD Foundation, Inc.
@@ -101,7 +101,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hfs_vnops.c,v 1.18 2010/06/24 13:03:09 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hfs_vnops.c,v 1.19 2011/02/07 02:06:20 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ipsec.h"
@@ -131,18 +131,24 @@
 
 #include <miscfs/genfs/genfs.h>
 
-int    hfs_vop_lookup          (void *);
-int    hfs_vop_open            (void *);
-int    hfs_vop_close           (void *);
-int    hfs_vop_access          (void *);
-int    hfs_vop_getattr (void *);
-int    hfs_vop_setattr (void *);
-int    hfs_vop_bmap            (void *);
-int    hfs_vop_read            (void *);
-int    hfs_vop_readdir (void *);
-int    hfs_vop_readlink        (void *);
-int    hfs_vop_reclaim (void *);
-int    hfs_vop_print           (void *);
+int    hfs_vop_lookup(void *);
+int    hfs_vop_open(void *);
+int    hfs_vop_close(void *);
+int    hfs_vop_access(void *);
+int    hfs_vop_getattr(void *);
+int    hfs_vop_setattr(void *);
+int    hfs_vop_bmap(void *);
+int    hfs_vop_read(void *);
+int    hfs_vop_readdir(void *);
+int    hfs_vop_readlink(void *);
+int    hfs_vop_reclaim(void *);
+int    hfs_vop_print(void *);
+
+#ifdef HFS_DEBUG
+#define DPRINTF(a) printf a
+#else
+#define DPRINTF(a)
+#endif
 
 
 int (**hfs_vnodeop_p) (void *);
@@ -155,8 +161,8 @@
        { &vop_open_desc, hfs_vop_open },               /* open */
        { &vop_close_desc, hfs_vop_close },             /* close */
        { &vop_access_desc, hfs_vop_access },           /* access */
-       { &vop_getattr_desc, hfs_vop_getattr }, /* getattr */
-       { &vop_setattr_desc, hfs_vop_setattr }, /* setattr */
+       { &vop_getattr_desc, hfs_vop_getattr },         /* getattr */
+       { &vop_setattr_desc, hfs_vop_setattr },         /* setattr */
        { &vop_read_desc, hfs_vop_read },               /* read */
        { &vop_write_desc, genfs_eopnotsupp },          /* write */
        { &vop_ioctl_desc, genfs_eopnotsupp },          /* ioctl */
@@ -173,11 +179,11 @@
        { &vop_mkdir_desc, genfs_eopnotsupp },          /* mkdir */
        { &vop_rmdir_desc, genfs_eopnotsupp },          /* rmdir */
        { &vop_symlink_desc, genfs_eopnotsupp },        /* symlink */
-       { &vop_readdir_desc, hfs_vop_readdir }, /* readdir */
+       { &vop_readdir_desc, hfs_vop_readdir },         /* readdir */
        { &vop_readlink_desc, hfs_vop_readlink },       /* readlink */
        { &vop_abortop_desc, genfs_abortop },           /* abortop */
        { &vop_inactive_desc, genfs_eopnotsupp },       /* inactive */
-       { &vop_reclaim_desc, hfs_vop_reclaim }, /* reclaim */
+       { &vop_reclaim_desc, hfs_vop_reclaim },         /* reclaim */
        { &vop_lock_desc, genfs_lock },                 /* lock */
        { &vop_unlock_desc, genfs_unlock },             /* unlock */
        { &vop_bmap_desc, hfs_vop_bmap },               /* bmap */
@@ -209,8 +215,8 @@
        { &vop_open_desc, spec_open },                  /* open */
        { &vop_close_desc, spec_close },                /* close */
        { &vop_access_desc, hfs_vop_access },           /* access */
-       { &vop_getattr_desc, hfs_vop_getattr }, /* getattr */
-       { &vop_setattr_desc, hfs_vop_setattr }, /* setattr */
+       { &vop_getattr_desc, hfs_vop_getattr },         /* getattr */
+       { &vop_setattr_desc, hfs_vop_setattr },         /* setattr */
        { &vop_read_desc, spec_read },                  /* read */
        { &vop_write_desc, spec_write },                /* write */
        { &vop_ioctl_desc, spec_ioctl },                /* ioctl */
@@ -231,7 +237,7 @@
        { &vop_readlink_desc, spec_readlink },          /* readlink */
        { &vop_abortop_desc, spec_abortop },            /* abortop */
        { &vop_inactive_desc, genfs_eopnotsupp },       /* inactive */
-       { &vop_reclaim_desc, hfs_vop_reclaim }, /* reclaim */
+       { &vop_reclaim_desc, hfs_vop_reclaim },         /* reclaim */
        { &vop_lock_desc, genfs_lock },                 /* lock */
        { &vop_unlock_desc, genfs_unlock },             /* unlock */
        { &vop_bmap_desc, spec_bmap },                  /* bmap */
@@ -333,11 +339,9 @@
        const char *pname;
        int error;
        int flags;
-       int result;                             /* result of libhfs operations */
+       int result;                     /* result of libhfs operations */
 
-#ifdef HFS_DEBUG
-       printf("VOP = hfs_vop_lookup()\n");
-#endif /* HFS_DEBUG */
+       DPRINTF(("VOP = hfs_vop_lookup()\n"));
 
        bp = NULL;
        cnp = ap->a_cnp;
@@ -372,28 +376,34 @@
         * we are looking for is known already.
         */
 /* XXX Cache disabled until we can make sure it works. */
-/*     if ((error = cache_lookup(vdp, vpp, cnp)) >= 0)
-               return error; */
+#if 0
+       if ((error = cache_lookup(vdp, vpp, cnp)) >= 0)
+               return error;
+#endif
 
 
-/*     if (cnp->cn_namelen == 1 && *pname == '.') {
+#if 0
+       if (cnp->cn_namelen == 1 && *pname == '.') {
                *vpp = vdp;
                vref(vdp);
-               return (0);
-       }*/
+               return 0;
+       }
+#endif
        
        pdp = vdp;
        if (flags & ISDOTDOT) {
-/*printf("DOTDOT ");*/
+               DPRINTF(("DOTDOT "));
                VOP_UNLOCK(pdp);        /* race to get the inode */
                error = VFS_VGET(vdp->v_mount, dp->h_parent, &tdp);
                vn_lock(pdp, LK_EXCLUSIVE | LK_RETRY);
                if (error != 0)
                        goto error;
                *vpp = tdp;
-/*     } else if (dp->h_rec.u.cnid == rec.file.u.cnid) {*/
+#if 0
+       } else if (dp->h_rec.u.cnid == rec.file.u.cnid) {
+#endif
        } else if (cnp->cn_namelen == 1 && pname[0] == '.') {
-/*printf("DOT ");*/
+               DPRINTF(("DOT "));
                vref(vdp);      /* we want ourself, ie "." */
                *vpp = vdp;
        } else {
@@ -406,17 +416,17 @@
                   and we have to handle overflow */
                unicn = malloc(cnp->cn_namelen*sizeof(unicn[0]), M_TEMP, M_WAITOK);
                len = utf8_to_utf16(unicn, cnp->cn_namelen,
-                                   cnp->cn_nameptr, cnp->cn_namelen, 0, NULL);
+                   cnp->cn_nameptr, cnp->cn_namelen, 0, NULL);
                /* XXX: check conversion errors? */
                if (hfslib_make_catalog_key(VTOH(vdp)->h_rec.u.cnid, len, unicn,
-                       &key) == 0) {
-/*printf("ERROR in hfslib_make_catalog_key\n");*/
+                   &key) == 0) {
+                       DPRINTF(("ERROR in hfslib_make_catalog_key\n"));
                        error = EINVAL;
                        goto error;
                }
                        
-               result = hfslib_find_catalog_record_with_key(&dp->h_hmp->hm_vol, &key,
-                       &rec, &cbargs);
+               result = hfslib_find_catalog_record_with_key(&dp->h_hmp->hm_vol,
+                   &key, &rec, &cbargs);
                if (result > 0) {
                        error = EINVAL;
                        goto error;
@@ -430,11 +440,10 @@
                }
 
                if (rec.file.user_info.file_type == HFS_HARD_LINK_FILE_TYPE
-                   && rec.file.user_info.file_creator
-                   == HFS_HFSLUS_CREATOR) {
+                   && rec.file.user_info.file_creator == HFS_HFSLUS_CREATOR) {
                        if (hfslib_get_hardlink(&dp->h_hmp->hm_vol,
-                                        rec.file.bsd.special.inode_num,
-                                        &rec, &cbargs) != 0) {
+                           rec.file.bsd.special.inode_num,
+                           &rec, &cbargs) != 0) {
                                error = EINVAL;
                                goto error;
                        }
@@ -455,13 +464,15 @@
                        goto error;
                *vpp = tdp;
        }
-/*printf("\n");*/
+       DPRINTF(("\n"));
        /*
         * Insert name into cache if appropriate.
         */
 /* XXX Cache disabled until we can make sure it works. */
-/*     if (cnp->cn_flags & MAKEENTRY)
-               cache_enter(vdp, *vpp, cnp);*/
+#if 0
+       if (cnp->cn_flags & MAKEENTRY)
+               cache_enter(vdp, *vpp, cnp);
+#endif
        
        error = 0;
 
@@ -484,14 +495,13 @@
        } */ *ap = v;
        struct hfsnode *hn = VTOH(ap->a_vp);
 #endif
-#ifdef HFS_DEBUG
-       printf("VOP = hfs_vop_open()\n");
-#endif /* HFS_DEBUG */
+       DPRINTF(("VOP = hfs_vop_open()\n"));
 
        /*
-        * XXX This is a good place to read and cache the file's extents to avoid
-        * XXX doing it upon every read/write. Must however keep the cache in sync
-        * XXX when the file grows/shrinks. (So would that go in vop_truncate?)
+        * XXX This is a good place to read and cache the file's extents to
+        * XXX avoid doing it upon every read/write. Must however keep the
+        * XXX cache in sync when the file grows/shrinks. (So would that go
+        * XXX in vop_truncate?)
         */
        
        return 0;
@@ -508,9 +518,7 @@
        } */ *ap = v;
        struct hfsnode *hn = VTOH(ap->a_vp);
 #endif
-#ifdef HFS_DEBUG
-       printf("VOP = hfs_vop_close()\n");
-#endif /* HFS_DEBUG */
+       DPRINTF(("VOP = hfs_vop_close()\n"));
 
        /* Release extents cache here. */
        
@@ -559,9 +567,7 @@
        struct vattr va;
        int error;
 
-#ifdef HFS_DEBUG
-       printf("VOP = hfs_vop_access()\n");
-#endif /* HFS_DEBUG */
+       DPRINTF(("VOP = hfs_vop_access()\n"));
 
        error = hfs_check_possible(ap->a_vp, ap->a_mode);
        if (error)
@@ -589,9 +595,7 @@
        hfs_bsd_data_t *bsd;
        hfs_fork_t     *fork;
 
-#ifdef HFS_DEBUG
-       printf("VOP = hfs_vop_getattr()\n");
-#endif /* HFS_DEBUG */
+       DPRINTF(("VOP = hfs_vop_getattr()\n"));
 
        vp = ap->a_vp;
        hp = VTOH(vp);
@@ -600,37 +604,39 @@
        vattr_null(vap);
 
        /*
-        * XXX Cannot trust permissions/modes/flags stored in an HFS+ catalog record
+        * XXX Cannot trust permissions/modes/flags stored in an HFS+ catalog
         * XXX record those values are not set on files created under Mac OS 9.
         */
        vap->va_type = ap->a_vp->v_type;
        if (hp->h_rec.u.rec_type == HFS_REC_FILE) {
+               hfs_file_record_t *f = &hp->h_rec.file;
                if (hp->h_fork == HFS_RSRCFORK)
-                       fork = &hp->h_rec.file.rsrc_fork;
+                       fork = &f->rsrc_fork;
                else
-                       fork = &hp->h_rec.file.data_fork;
-               vap->va_fileid = hp->h_rec.file.cnid;
-               bsd = &hp->h_rec.file.bsd;
+                       fork = &f->data_fork;
+               vap->va_fileid = f->cnid;
+               bsd = &f->bsd;
                vap->va_bytes = fork->total_blocks * HFS_BLOCKSIZE(vp);
                vap->va_size = fork->logical_size;
-               hfs_time_to_timespec(hp->h_rec.file.date_created, &vap->va_ctime);
-               hfs_time_to_timespec(hp->h_rec.file.date_content_mod, &vap->va_mtime);
-               hfs_time_to_timespec(hp->h_rec.file.date_accessed, &vap->va_atime);
+               hfs_time_to_timespec(f->date_created, &vap->va_ctime);
+               hfs_time_to_timespec(f->date_content_mod, &vap->va_mtime);
+               hfs_time_to_timespec(f->date_accessed, &vap->va_atime);
                vap->va_nlink = 1;
        }
        else if (hp->h_rec.u.rec_type == HFS_REC_FLDR) {
+               hfs_folder_record_t *f = &hp->h_rec.folder;



Home | Main Index | Thread Index | Old Index