From owner-svn-soc-all@FreeBSD.ORG Sun Jul 8 10:55:26 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 0E6C2106564A for ; Sun, 8 Jul 2012 10:55:24 +0000 (UTC) (envelope-from oleksandr@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Sun, 08 Jul 2012 10:55:24 +0000 Date: Sun, 08 Jul 2012 10:55:24 +0000 From: oleksandr@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120708105524.0E6C2106564A@hub.freebsd.org> Cc: Subject: socsvn commit: r239110 - soc2012/oleksandr/udf-head/sys/fs/udf2 X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Jul 2012 10:55:26 -0000 Author: oleksandr Date: Sun Jul 8 10:55:22 2012 New Revision: 239110 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239110 Log: Add some debug printf and comments and check permissions Modified: soc2012/oleksandr/udf-head/sys/fs/udf2/udf_vnops.c Modified: soc2012/oleksandr/udf-head/sys/fs/udf2/udf_vnops.c ============================================================================== --- soc2012/oleksandr/udf-head/sys/fs/udf2/udf_vnops.c Sun Jul 8 09:55:00 2012 (r239109) +++ soc2012/oleksandr/udf-head/sys/fs/udf2/udf_vnops.c Sun Jul 8 10:55:22 2012 (r239110) @@ -252,7 +252,7 @@ error = uiomove(bp->b_data + on, n, uio); brelse(bp); - } while (error == 0 && uio->uio_resid > 0 && n != 0) + } while (error == 0 && uio->uio_resid > 0 && n != 0); #if 0 /* note access time unless not requested */ if (!(vp->v_mount->mnt_flag & MNT_NOATIME)) { @@ -761,26 +761,48 @@ ump = dir_node->ump; *vpp = NULL; + DPRINTF(LOOKUP, ("udf_cachedlookup callen\n")); + /* simplify/clarification flags */ nameiop = cnp->cn_nameiop; islastcn = cnp->cn_flags & ISLASTCN; mounted_ro = dvp->v_mount->mnt_flag & MNT_RDONLY; + /* check exec/dirread permissions first */ + error = VOP_ACCESS(dvp, VEXEC, cnp->cn_cred, curthread); + if (error) + return (error); + + DPRINTF(LOOKUP, ("\taccess ok\n")); + /* * If requesting a modify on the last path element on a read-only - * filingsystem, reject lookup; XXX why is this repeated in every FS ? + * filingsystem, reject lookup. */ if (islastcn && mounted_ro && (nameiop == DELETE || nameiop == RENAME)) return (EROFS); + DPRINTF(LOOKUP, ("\tlooking up cnp->cn_nameptr '%s'\n", cnp->cn_nameptr)); + + /* look in the namei cache; return 0 on success!! */ +#if 0 + error = cache_lookup(dvp, vpp, cnp); + if (error >= 0) + return error; + + DPRINTF(LOOKUP, ("\tNOT found in cache\n")); +#endif /* get directory filesize */ if (dir_node->fe) file_size = le64toh(dir_node->fe->inf_len); else file_size = le64toh(dir_node->efe->inf_len); - /* - * + /* + * If this is a LOOKUP and we've already partially searched through + * the directory, pick up where we left off and flag that the + * directory may need to be searched twice. For a full description, + * see /sys/fs/cd9660/cd9660_lookup.c:cd9660_lookup() */ if (nameiop != LOOKUP || dir_node->diroff == 0 || dir_node->diroff > file_size) { offset = 0; @@ -833,7 +855,11 @@ if (error) goto exit; + /* Did we have a match? */ if (id) { + /* + * Remember where this entry was if it's the final component. + */ if ((cnp->cn_flags & ISLASTCN) && cnp->cn_nameiop == LOOKUP) dir_node->diroff = offset; if (numpasses == 2) @@ -843,13 +869,16 @@ vn_vget_ino(dvp, id, cnp->cn_lkflags, &tdp); } else if (dir_node->hash_id == id) { - /* through a glass darkly... */ - VREF(dvp); + VREF(dvp); /* we want ourself, ie "." */ + /* + * When we lookup "." we still can be asked to lock it + * differently. + */ ltype = cnp->cn_lkflags & LK_TYPE_MASK; if (ltype != VOP_ISLOCKED(dvp)) { if (ltype == LK_EXCLUSIVE) vn_lock(dvp, LK_UPGRADE | LK_RETRY); - else + else /* if (ltype == LK_SHARED) */ vn_lock(dvp, LK_DOWNGRADE | LK_RETRY); } tdp = dvp; @@ -860,16 +889,19 @@ if (!error) { *vpp = tdp; + /* Put this entry in the cache */ if (cnp->cn_flags & MAKEENTRY) cache_enter(dvp, *vpp, cnp); } } else { + /* Name wasn't found on this pass. Do another pass? */ if (numpasses-- == 2) { offset = 0; goto lookuploop; } + /* Enter name into cache as non-existant */ if (cnp->cn_flags & MAKEENTRY) cache_enter(dvp, *vpp, cnp); @@ -883,18 +915,10 @@ exit: free(fid, M_UDFTEMP); free(unix_name, M_UDFTEMP); + + DPRINTFIF(LOOKUP, error, ("udf_cachedlookup returning error %d\n", error)); return (error); -#if 0 - not sure if anything like this would be needed. - if ((cnp->cn_namelen == 1) && (cnp->cn_nameptr[0] == '.')) { - DPRINTF(LOOKUP, ("\tlookup '.'\n")); - /* special case 1 '.' */ - vref(dvp); - *vpp = dvp; - /* done */ - } -#endif } /* --------------------------------------------------------------------- */ From owner-svn-soc-all@FreeBSD.ORG Sun Jul 8 20:52:00 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 293701065672 for ; Sun, 8 Jul 2012 20:51:58 +0000 (UTC) (envelope-from rudot@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Sun, 08 Jul 2012 20:51:58 +0000 Date: Sun, 08 Jul 2012 20:51:58 +0000 From: rudot@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120708205158.293701065672@hub.freebsd.org> Cc: Subject: socsvn commit: r239147 - soc2012/rudot/benchmarking/hw/buildworld/60pct X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Jul 2012 20:52:00 -0000 Author: rudot Date: Sun Jul 8 20:51:57 2012 New Revision: 239147 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239147 Log: 60% benchmark Added: soc2012/rudot/benchmarking/hw/buildworld/60pct/ soc2012/rudot/benchmarking/hw/buildworld/60pct/dataSorted.txt soc2012/rudot/benchmarking/hw/buildworld/60pct/plot.eps (contents, props changed) Added: soc2012/rudot/benchmarking/hw/buildworld/60pct/dataSorted.txt ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/rudot/benchmarking/hw/buildworld/60pct/dataSorted.txt Sun Jul 8 20:51:57 2012 (r239147) @@ -0,0 +1,340 @@ +0.2 26 +0.3 13 +0.4 18 +0.5 6 +0.6 13 +0.7 18 +0.8 10 +0.9 10 +1 7 +1.1 13 +1.2 5 +1.3 5 +1.4 10 +1.5 13 +1.6 5 +1.7 3 +1.8 8 +1.9 5 +2 3 +2.1 8 +2.2 8 +2.3 2 +2.4 5 +2.5 5 +2.6 6 +2.7 2 +2.8 5 +2.9 1 +3 10 +3.1 5 +3.2 2 +3.3 4 +3.4 1 +3.5 1 +3.6 5 +3.9 2 +4 5 +4.1 3 +4.2 1 +4.3 1 +4.6 2 +4.7 1 +4.9 1 +5 1 +5.1 6 +5.2 1 +5.3 2 +5.7 2 +5.8 1 +6 11 +6.1 3 +6.2 2 +6.6 1 +6.7 2 +6.9 1 +7 11 +7.1 2 +7.2 1 +7.5 1 +7.7 2 +7.8 1 +8 12 +8.1 1 +8.2 1 +8.8 1 +9 4 +9.1 2 +9.2 1 +9.3 1 +9.4 1 +9.7 3 +9.8 2 +10 4 +10.3 1 +10.5 1 +10.8 2 +11 6 +11.1 1 +12 7 +12.1 1 +13 1 +14 2 +14.7 1 +15 3 +16 1 +17 2 +18.2 1 +19 1 +21 1 +30 2 +31.8 1 +32.3 1 +32.6 1 +33.8 1 +33.9 1 +35 2 +35.1 1 +35.3 3 +35.4 1 +35.7 2 +35.9 4 +36.1 1 +36.3 1 +36.6 2 +36.8 2 +37.3 1 +37.4 1 +37.5 2 +37.7 1 +37.8 1 +37.9 1 +38.2 2 +38.4 1 +38.5 3 +39.2 1 +39.6 3 +39.7 1 +39.9 4 +40.1 1 +40.3 2 +40.4 1 +40.6 4 +40.7 1 +41 1 +41.1 1 +41.2 1 +41.3 1 +41.4 1 +41.8 2 +42 4 +42.2 3 +42.3 1 +42.4 4 +42.5 5 +42.7 1 +42.8 8 +42.9 1 +43 1 +43.1 6 +43.3 3 +43.4 4 +43.5 1 +43.6 1 +43.7 2 +43.8 3 +43.9 2 +44 2 +44.1 3 +44.3 1 +44.4 2 +44.5 5 +44.6 1 +44.7 4 +44.8 4 +44.9 4 +45 1 +45.1 1 +45.2 12 +45.3 2 +45.4 5 +45.5 13 +45.6 2 +45.7 17 +45.8 3 +45.9 8 +46.3 2 +46.4 4 +46.5 5 +46.6 6 +46.8 2 +46.9 3 +47 2 +47.2 1 +47.5 1 +47.6 6 +47.9 3 +48 3 +48.1 2 +48.2 1 +48.3 1 +48.4 4 +48.6 1 +48.7 4 +48.8 2 +48.9 3 +49 9 +49.1 2 +49.2 2 +49.3 1 +49.4 2 +49.5 2 +49.6 4 +49.7 4 +49.8 3 +49.9 1 +50.1 3 +50.2 7 +50.3 4 +50.4 3 +50.5 2 +50.6 4 +50.7 5 +50.8 3 +50.9 3 +51 2 +51.1 5 +51.2 5 +51.3 4 +51.4 3 +51.5 6 +51.6 4 +51.7 4 +51.8 7 +52 4 +52.1 1 +52.2 6 +52.3 7 +52.4 3 +52.5 7 +52.6 1 +52.7 3 +52.8 3 +52.9 9 +53 2 +53.1 2 +53.2 6 +53.3 6 +53.4 3 +53.6 2 +53.7 5 +53.8 4 +53.9 5 +54 7 +54.1 1 +54.2 8 +54.3 7 +54.4 6 +54.5 12 +54.6 7 +54.7 7 +54.8 2 +54.9 1 +55 4 +55.1 2 +55.2 5 +55.3 10 +55.4 3 +55.5 9 +55.6 4 +55.7 8 +55.8 6 +55.9 6 +56 7 +56.1 5 +56.2 5 +56.3 4 +56.4 10 +56.5 4 +56.6 6 +56.7 11 +56.8 6 +56.9 6 +57 4 +57.1 3 +57.2 5 +57.3 9 +57.4 10 +57.5 9 +57.6 8 +57.7 7 +57.8 7 +57.9 6 +58 8 +58.1 13 +58.2 5 +58.3 2 +58.4 8 +58.5 8 +58.6 7 +58.7 8 +58.8 10 +58.9 6 +59 4 +59.1 9 +59.2 19 +59.3 3 +59.4 6 +59.5 13 +59.6 4 +59.7 6 +59.8 8 +59.9 6 +60 8 +60.1 4 +60.2 5 +60.3 3 +60.4 7 +60.5 3 +60.6 3 +60.7 1 +60.8 1 +60.9 3 +61 4 +61.1 1 +61.2 1 +61.3 1 +61.5 1 +63.5 1 +64 1 +67 1 +67.4 1 +71 1 +72 2 +75 2 +78 1 +78.6 1 +82 1 +83 2 +86 1 +86.3 1 +89 1 +89.2 1 +90 1 +92 1 +93 2 +94 1 +95 2 +96 4 +97 11 +97.4 1 +98 4 +98.3 1 +99 5 +101 2 +102 1 +102.8 1 +107.2 1 +111.7 1 +113.5 1 +141.7 1 Added: soc2012/rudot/benchmarking/hw/buildworld/60pct/plot.eps ============================================================================== Binary file. No diff available. From owner-svn-soc-all@FreeBSD.ORG Mon Jul 9 16:14:52 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 79A991065670 for ; Mon, 9 Jul 2012 16:14:50 +0000 (UTC) (envelope-from aleek@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Mon, 09 Jul 2012 16:14:50 +0000 Date: Mon, 09 Jul 2012 16:14:50 +0000 From: aleek@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120709161450.79A991065670@hub.freebsd.org> Cc: Subject: socsvn commit: r239187 - in soc2012/aleek/beaglexm-armv6/sys: arm/conf arm/ti kern X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Jul 2012 16:14:52 -0000 Author: aleek Date: Mon Jul 9 16:14:50 2012 New Revision: 239187 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239187 Log: trying to find bug in mmc Modified: soc2012/aleek/beaglexm-armv6/sys/arm/conf/BEAGLEBOARD-XM soc2012/aleek/beaglexm-armv6/sys/arm/ti/ti_machdep.c soc2012/aleek/beaglexm-armv6/sys/arm/ti/ti_mmchs.c soc2012/aleek/beaglexm-armv6/sys/kern/init_main.c Modified: soc2012/aleek/beaglexm-armv6/sys/arm/conf/BEAGLEBOARD-XM ============================================================================== --- soc2012/aleek/beaglexm-armv6/sys/arm/conf/BEAGLEBOARD-XM Mon Jul 9 15:44:35 2012 (r239186) +++ soc2012/aleek/beaglexm-armv6/sys/arm/conf/BEAGLEBOARD-XM Mon Jul 9 16:14:50 2012 (r239187) @@ -59,8 +59,9 @@ options INVARIANT_SUPPORT #Extra sanity checks of internal structures, required by INVARIANTS #options WITNESS #Enable checks to detect deadlocks and cycles #options WITNESS_SKIPSPIN #Don't run witness on spinlocks for speed -#options DIAGNOSTIC -#options DEBUG +options DIAGNOSTIC +options DEBUG + # NFS support #options NFSCL @@ -81,7 +82,7 @@ device mmcsd # mmc/sd flash cards # Boot device is 2nd slice on MMC/SD card -options ROOTDEVNAME=\"ufs:mmcsd0s2\" +#options ROOTDEVNAME=\"msdosfs:mmcsd0s2\" # Console and misc @@ -127,7 +128,7 @@ options FDT_DTB_STATIC makeoptions FDT_DTS_FILE=beagleboardxm.dts -#options MD_ROOT -#options MD_ROOT_SIZE=8192 -#makeoptions MFS_IMAGE=/home/alek/beaglexm-armv6/arm.ramfs -#options ROOTDEVNAME=\"ufs:md0\" +options MD_ROOT +options MD_ROOT_SIZE=8192 +makeoptions MFS_IMAGE=/home/alek/beaglexm-armv6/arm.ramfs +options ROOTDEVNAME=\"ufs:md0\" Modified: soc2012/aleek/beaglexm-armv6/sys/arm/ti/ti_machdep.c ============================================================================== --- soc2012/aleek/beaglexm-armv6/sys/arm/ti/ti_machdep.c Mon Jul 9 15:44:35 2012 (r239186) +++ soc2012/aleek/beaglexm-armv6/sys/arm/ti/ti_machdep.c Mon Jul 9 16:14:50 2012 (r239187) @@ -334,7 +334,7 @@ u_int l1pagetable; int i = 0, j = 0; - arm_early_puts( "BeagleBoard-XM revC FreeBSD hababababa booting...\n" ); + arm_early_puts( "BeagleBoard-XM revC FreeBSD booting...\n" ); kmdp = NULL; lastaddr = 0; @@ -346,6 +346,8 @@ set_cpufuncs(); arm_early_puts( "done!\n" ); + bootverbose = 1; + /* * Mask metadata pointer: it is supposed to be on page boundary. If * the first argument (mdp) doesn't point to a valid address the Modified: soc2012/aleek/beaglexm-armv6/sys/arm/ti/ti_mmchs.c ============================================================================== --- soc2012/aleek/beaglexm-armv6/sys/arm/ti/ti_mmchs.c Mon Jul 9 15:44:35 2012 (r239186) +++ soc2012/aleek/beaglexm-armv6/sys/arm/ti/ti_mmchs.c Mon Jul 9 16:14:50 2012 (r239187) @@ -91,6 +91,7 @@ #include #include + #ifdef DEBUG #define ti_mmchs_dbg(sc, fmt, args...) \ device_printf((sc)->sc_dev, fmt, ## args); Modified: soc2012/aleek/beaglexm-armv6/sys/kern/init_main.c ============================================================================== --- soc2012/aleek/beaglexm-armv6/sys/kern/init_main.c Mon Jul 9 15:44:35 2012 (r239186) +++ soc2012/aleek/beaglexm-armv6/sys/kern/init_main.c Mon Jul 9 16:14:50 2012 (r239187) @@ -709,6 +709,7 @@ printf("start_init: trying %.*s\n", (int)(next - path), path); + printf( "%s:%d\n", __FUNCTION__, __LINE__ ); /* * Move out the boot flag argument. */ @@ -719,6 +720,7 @@ (void)subyte(--ucp, 's'); options = 1; } + printf( "%s:%d\n", __FUNCTION__, __LINE__ ); #ifdef notyet if (boothowto & RB_FASTBOOT) { (void)subyte(--ucp, 'f'); @@ -731,6 +733,7 @@ options = 1; #endif + printf( "%s:%d\n", __FUNCTION__, __LINE__ ); if (options == 0) (void)subyte(--ucp, '-'); (void)subyte(--ucp, '-'); /* leading hyphen */ @@ -744,6 +747,7 @@ (void)subyte(--ucp, *s); arg0 = ucp; + printf( "%s:%d\n", __FUNCTION__, __LINE__ ); /* * Move out the arg pointers. */ @@ -752,6 +756,7 @@ (void)suword((caddr_t)--uap, (long)(intptr_t)arg1); (void)suword((caddr_t)--uap, (long)(intptr_t)arg0); + printf( "%s:%d\n", __FUNCTION__, __LINE__ ); /* * Point at the arguments. */ @@ -759,6 +764,7 @@ args.argv = uap; args.envv = NULL; + printf( "%s:%d\n", __FUNCTION__, __LINE__ ); /* * Now try to exec the program. If can't for any reason * other than it doesn't exist, complain. @@ -770,9 +776,11 @@ mtx_unlock(&Giant); return; } + printf( "%s:%d\n", __FUNCTION__, __LINE__ ); if (error != ENOENT) printf("exec %.*s: error %d\n", (int)(next - path), path, error); + printf( "%s:%d\n", __FUNCTION__, __LINE__ ); } printf("init: not found in path %s\n", init_path); panic("no init"); From owner-svn-soc-all@FreeBSD.ORG Mon Jul 9 18:57:54 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 59D84106566B for ; Mon, 9 Jul 2012 18:57:53 +0000 (UTC) (envelope-from gmiller@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Mon, 09 Jul 2012 18:57:53 +0000 Date: Mon, 09 Jul 2012 18:57:53 +0000 From: gmiller@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120709185753.59D84106566B@hub.freebsd.org> Cc: Subject: socsvn commit: r239192 - in soc2012/gmiller/locking-head: . tools/regression/lib/libthr/lockprof X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Jul 2012 18:57:54 -0000 Author: gmiller Date: Mon Jul 9 18:57:52 2012 New Revision: 239192 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239192 Log: r239205@FreeBSD-dev: root | 2012-07-03 10:49:44 -0500 Add test for pthread_resetstatistics_np() and multithreaded tests for lock/unlock cycles. Modified: soc2012/gmiller/locking-head/ (props changed) soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/lock-cycle.c Modified: soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/lock-cycle.c ============================================================================== --- soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/lock-cycle.c Mon Jul 9 17:34:03 2012 (r239191) +++ soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/lock-cycle.c Mon Jul 9 18:57:52 2012 (r239192) @@ -46,6 +46,12 @@ pthread_join(thread2, NULL); } +void +reset_stats() +{ + pthread_resetstatistics_np(); +} + #define MAX_TESTS (100) int success_count = 0; @@ -121,6 +127,50 @@ void check_stats_multi(void) { + int record_count = 0; + struct pthread_statistics_np stats; + long tm; + + pthread_getstatistics_begin_np(&stats); + while (pthread_getstatistics_next_np(&stats)) { + record_count++; + } + pthread_getstatistics_end_np(&stats); + + check(record_count == 1); + + pthread_getstatistics_begin_np(&stats); + pthread_getstatistics_next_np(&stats); + pthread_getstatistics_end_np(&stats); + + check(strcmp(stats.file, "lock-cycle.c") == 0); + check(stats.line == 16); + + tm = stats.hold_max.tv_sec * 1000000L + stats.hold_max.tv_nsec / 1000; + check(tm >= 30); + + tm = stats.hold_time.tv_sec * 1000000L + + stats.hold_time.tv_nsec / 1000; + check(tm >= 30000); + + printf("count = %d\n", stats.acq_count); + + check(stats.acq_count == 3000); +} + +void +check_stats_reset(void) +{ + int record_count = 0; + struct pthread_statistics_np stats; + + pthread_getstatistics_begin_np(&stats); + while (pthread_getstatistics_next_np(&stats)) { + record_count++; + } + pthread_getstatistics_end_np(&stats); + + check(record_count == 0); } int @@ -129,6 +179,9 @@ lock_cycle(); check_stats_single(); + reset_stats(); + check_stats_reset(); + multi_cycle(); check_stats_multi(); From owner-svn-soc-all@FreeBSD.ORG Mon Jul 9 18:58:04 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 0A56D106567F for ; Mon, 9 Jul 2012 18:58:02 +0000 (UTC) (envelope-from gmiller@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Mon, 09 Jul 2012 18:58:02 +0000 Date: Mon, 09 Jul 2012 18:58:02 +0000 From: gmiller@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120709185803.0A56D106567F@hub.freebsd.org> Cc: Subject: socsvn commit: r239193 - in soc2012/gmiller/locking-head: . tools/regression/lib/libthr/lockprof X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Jul 2012 18:58:04 -0000 Author: gmiller Date: Mon Jul 9 18:58:02 2012 New Revision: 239193 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239193 Log: r239216@FreeBSD-dev: root | 2012-07-03 11:16:28 -0500 Add tests for conflict counts and total and maximum wait times for contested locks. Modified: soc2012/gmiller/locking-head/ (props changed) soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/lock-cycle.c Modified: soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/lock-cycle.c ============================================================================== --- soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/lock-cycle.c Mon Jul 9 18:57:52 2012 (r239192) +++ soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/lock-cycle.c Mon Jul 9 18:58:02 2012 (r239193) @@ -52,6 +52,35 @@ pthread_resetstatistics_np(); } +void * +conflict_thread_func(void *v) +{ + v = v; + + pthread_mutex_lock(&mutex); + + sleep(5); + + pthread_mutex_unlock(&mutex); + + return NULL; +} + +void +conflict_test() +{ + pthread_t thread1; + pthread_t thread2; + + pthread_resetstatistics_np(); + + pthread_create(&thread1, NULL, conflict_thread_func, NULL); + pthread_create(&thread2, NULL, conflict_thread_func, NULL); + + pthread_join(thread2, NULL); + pthread_join(thread1, NULL); +} + #define MAX_TESTS (100) int success_count = 0; @@ -173,6 +202,35 @@ check(record_count == 0); } +void +check_stats_conflict(void) +{ + int record_count = 0; + struct pthread_statistics_np stats; + long tm; + + pthread_getstatistics_begin_np(&stats); + while (pthread_getstatistics_next_np(&stats)) { + record_count++; + } + pthread_getstatistics_end_np(&stats); + + check(record_count == 1); + + pthread_getstatistics_begin_np(&stats); + pthread_getstatistics_next_np(&stats); + pthread_getstatistics_end_np(&stats); + + check(stats.contest_count == 1); + + tm = stats.wait_time.tv_sec * 1000000L + + stats.wait_time.tv_nsec / 1000; + check(tm > 0); + + tm = stats.wait_max.tv_sec * 1000000L + stats.wait_max.tv_nsec / 1000; + check(tm > 0); +} + int main(void) { @@ -185,6 +243,9 @@ multi_cycle(); check_stats_multi(); + conflict_test(); + check_stats_conflict(); + show_test_results(); return 0; From owner-svn-soc-all@FreeBSD.ORG Mon Jul 9 19:53:20 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id D7388106566C for ; Mon, 9 Jul 2012 19:53:17 +0000 (UTC) (envelope-from jhagewood@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Mon, 09 Jul 2012 19:53:17 +0000 Date: Mon, 09 Jul 2012 19:53:17 +0000 From: jhagewood@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120709195317.D7388106566C@hub.freebsd.org> Cc: Subject: socsvn commit: r239196 - soc2012/jhagewood/sdiff X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Jul 2012 19:53:20 -0000 Author: jhagewood Date: Mon Jul 9 19:53:17 2012 New Revision: 239196 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239196 Log: Modified: soc2012/jhagewood/sdiff/hagewood-sdiff.patch Modified: soc2012/jhagewood/sdiff/hagewood-sdiff.patch ============================================================================== --- soc2012/jhagewood/sdiff/hagewood-sdiff.patch Mon Jul 9 18:34:21 2012 (r239195) +++ soc2012/jhagewood/sdiff/hagewood-sdiff.patch Mon Jul 9 19:53:17 2012 (r239196) @@ -112,7 +112,7 @@ + diff -rupN jhagewood/sdiff/sdiff-orig/sdiff.c jhagewood/sdiff/sdiff/sdiff.c --- jhagewood/sdiff/sdiff-orig/sdiff.c 2012-07-07 19:37:22.000000000 -0400 -+++ jhagewood/sdiff/sdiff/sdiff.c 2012-07-07 19:58:11.000000000 -0400 ++++ jhagewood/sdiff/sdiff/sdiff.c 2012-07-09 19:53:05.000000000 -0400 @@ -5,6 +5,14 @@ * Public domain. */ From owner-svn-soc-all@FreeBSD.ORG Mon Jul 9 20:14:08 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id A1B1F106568B for ; Mon, 9 Jul 2012 20:14:06 +0000 (UTC) (envelope-from jhagewood@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Mon, 09 Jul 2012 20:14:06 +0000 Date: Mon, 09 Jul 2012 20:14:06 +0000 From: jhagewood@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120709201406.A1B1F106568B@hub.freebsd.org> Cc: Subject: socsvn commit: r239198 - in soc2012/jhagewood/sdiff: . sdiff X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Jul 2012 20:14:08 -0000 Author: jhagewood Date: Mon Jul 9 20:14:06 2012 New Revision: 239198 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239198 Log: Modified: soc2012/jhagewood/sdiff/TODO soc2012/jhagewood/sdiff/hagewood-sdiff.patch soc2012/jhagewood/sdiff/sdiff/sdiff.c Modified: soc2012/jhagewood/sdiff/TODO ============================================================================== --- soc2012/jhagewood/sdiff/TODO Mon Jul 9 19:27:48 2012 (r239197) +++ soc2012/jhagewood/sdiff/TODO Mon Jul 9 20:14:06 2012 (r239198) @@ -1,4 +1,4 @@ -Combine diff-spec args and pipe to diff INCOMPLETE +Combine diff-spec args and pipe to diff COMPLETE Fixed 'W' Test script COMPLETE Adapt code to FreeBSD style guidelines INCOMPLETE Fix --width output indention COMPLETE @@ -6,9 +6,10 @@ Add more information to man file. COMPLETE Fix sdiff to work with binary data INCOMPLETE - NOTES: +- In diff, 'w' is used for --ignore-all-spaces instead of 'W'. When 'W' is passed to sdiff, it must be passed to diff as 'w'. + - BUG: Right side of output is 2 spaces further than GNU sdiff's output. -FIX: In println(), change column width to width-1, take out extra space when it prints 'div' on no right column. Modified: soc2012/jhagewood/sdiff/hagewood-sdiff.patch ============================================================================== --- soc2012/jhagewood/sdiff/hagewood-sdiff.patch Mon Jul 9 19:27:48 2012 (r239197) +++ soc2012/jhagewood/sdiff/hagewood-sdiff.patch Mon Jul 9 20:14:06 2012 (r239198) @@ -112,7 +112,7 @@ + diff -rupN jhagewood/sdiff/sdiff-orig/sdiff.c jhagewood/sdiff/sdiff/sdiff.c --- jhagewood/sdiff/sdiff-orig/sdiff.c 2012-07-07 19:37:22.000000000 -0400 -+++ jhagewood/sdiff/sdiff/sdiff.c 2012-07-09 19:53:05.000000000 -0400 ++++ jhagewood/sdiff/sdiff/sdiff.c 2012-07-09 20:09:56.000000000 -0400 @@ -5,6 +5,14 @@ * Public domain. */ @@ -231,21 +231,28 @@ /* combine no-arg single switches */ case 'a': case 'B': -@@ -261,11 +290,11 @@ main(int argc, char **argv) +@@ -261,11 +290,17 @@ main(int argc, char **argv) case 'i': case 't': case 'H': + case 'W': for(popt = longopts; ch != popt->val && popt->name != NULL; popt++); - diffargv[1] = realloc( diffargv[1], sizeof(char) * strlen(diffargv[1]) + 2 ); +- sprintf(diffargv[1], "%s%c", diffargv[1], ch); + diffargv[1] = realloc(diffargv[1], sizeof(char) * strlen(diffargv[1]) + 2); - sprintf(diffargv[1], "%s%c", diffargv[1], ch); ++ /* ++ * In diff, the 'W' option is 'w' and the 'w' is 'W'. ++ */ ++ if (ch == 'W') ++ sprintf(diffargv[1], "%sw", diffargv[1]); ++ else ++ sprintf(diffargv[1], "%s%c", diffargv[1], ch); break; - case DIFFPROG_OPT: diffargv[0] = diffprog = optarg; break; -@@ -289,26 +318,23 @@ main(int argc, char **argv) +@@ -289,26 +324,23 @@ main(int argc, char **argv) if (errstr) errx(2, "width is %s: %s", errstr, optarg); break; @@ -277,7 +284,7 @@ /* no single switches were used */ if( strcmp( diffargv[1], "-" ) == 0 ) { -@@ -362,19 +388,19 @@ main(int argc, char **argv) +@@ -362,19 +394,19 @@ main(int argc, char **argv) /* Add NULL to end of array to indicate end of array. */ diffargv[diffargc++] = NULL; @@ -302,7 +309,7 @@ case 0: /* child */ /* We don't read from the pipe. */ -@@ -383,7 +409,6 @@ main(int argc, char **argv) +@@ -383,7 +415,6 @@ main(int argc, char **argv) err(2, "child could not duplicate descriptor"); /* Free unused descriptor. */ close(fd[1]); @@ -310,7 +317,7 @@ execvp(diffprog, diffargv); err(2, "could not execute diff: %s", diffprog); break; -@@ -461,6 +486,7 @@ main(int argc, char **argv) +@@ -461,6 +492,7 @@ main(int argc, char **argv) static void printcol(const char *s, size_t *col, const size_t col_max) { @@ -318,7 +325,7 @@ for (; *s && *col < col_max; ++s) { size_t new_col; -@@ -484,11 +510,9 @@ printcol(const char *s, size_t *col, con +@@ -484,11 +516,9 @@ printcol(const char *s, size_t *col, con return; *col = new_col; break; @@ -330,7 +337,7 @@ putchar(*s); } } -@@ -527,30 +551,24 @@ prompt(const char *s1, const char *s2) +@@ -527,30 +557,24 @@ prompt(const char *s1, const char *s2) /* Choose left column as-is. */ if (s1 != NULL) fprintf(outfp, "%s\n", s1); @@ -363,7 +370,7 @@ default: /* Interactive usage help. */ USAGE: -@@ -570,7 +588,7 @@ PROMPT: +@@ -570,7 +594,7 @@ PROMPT: * If there was no error, we received an EOF from stdin, so we * should quit. */ @@ -372,7 +379,7 @@ fclose(outfp); exit(0); } -@@ -1103,24 +1121,22 @@ printd(FILE *file1, size_t file1end) +@@ -1103,24 +1127,22 @@ printd(FILE *file1, size_t file1end) static void int_usage(void) { Modified: soc2012/jhagewood/sdiff/sdiff/sdiff.c ============================================================================== --- soc2012/jhagewood/sdiff/sdiff/sdiff.c Mon Jul 9 19:27:48 2012 (r239197) +++ soc2012/jhagewood/sdiff/sdiff/sdiff.c Mon Jul 9 20:14:06 2012 (r239198) @@ -293,7 +293,13 @@ case 'W': for(popt = longopts; ch != popt->val && popt->name != NULL; popt++); diffargv[1] = realloc(diffargv[1], sizeof(char) * strlen(diffargv[1]) + 2); - sprintf(diffargv[1], "%s%c", diffargv[1], ch); + /* + * In diff, the 'W' option is 'w' and the 'w' is 'W'. + */ + if (ch == 'W') + sprintf(diffargv[1], "%sw", diffargv[1]); + else + sprintf(diffargv[1], "%s%c", diffargv[1], ch); break; case DIFFPROG_OPT: diffargv[0] = diffprog = optarg; From owner-svn-soc-all@FreeBSD.ORG Tue Jul 10 11:21:05 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 4EA08106566C for ; Tue, 10 Jul 2012 11:21:03 +0000 (UTC) (envelope-from aleek@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Tue, 10 Jul 2012 11:21:03 +0000 Date: Tue, 10 Jul 2012 11:21:03 +0000 From: aleek@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120710112103.4EA08106566C@hub.freebsd.org> Cc: Subject: socsvn commit: r239237 - in soc2012/aleek/beaglexm-armv6/sys: arm/conf kern X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Jul 2012 11:21:05 -0000 Author: aleek Date: Tue Jul 10 11:21:02 2012 New Revision: 239237 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239237 Log: revering sys/kern/init_main.c. BeagleBoard-xM boots FreeBSD from SD card Modified: soc2012/aleek/beaglexm-armv6/sys/arm/conf/BEAGLEBOARD-XM soc2012/aleek/beaglexm-armv6/sys/kern/init_main.c Modified: soc2012/aleek/beaglexm-armv6/sys/arm/conf/BEAGLEBOARD-XM ============================================================================== --- soc2012/aleek/beaglexm-armv6/sys/arm/conf/BEAGLEBOARD-XM Tue Jul 10 08:31:28 2012 (r239236) +++ soc2012/aleek/beaglexm-armv6/sys/arm/conf/BEAGLEBOARD-XM Tue Jul 10 11:21:02 2012 (r239237) @@ -79,10 +79,10 @@ # MMC/SD/SDIO card slot support device mmc # mmc/sd bus -device mmcsd # mmc/sd flash cards +device mmcsd # mmc/sd flash cards # Boot device is 2nd slice on MMC/SD card -#options ROOTDEVNAME=\"msdosfs:mmcsd0s2\" +options ROOTDEVNAME=\"msdosfs:mmcsd0s2\" # Console and misc @@ -128,7 +128,7 @@ options FDT_DTB_STATIC makeoptions FDT_DTS_FILE=beagleboardxm.dts -options MD_ROOT -options MD_ROOT_SIZE=8192 -makeoptions MFS_IMAGE=/home/alek/beaglexm-armv6/arm.ramfs -options ROOTDEVNAME=\"ufs:md0\" +#options MD_ROOT +#options MD_ROOT_SIZE=8192 +#makeoptions MFS_IMAGE=/home/alek/beaglexm-armv6/arm.ramfs +#options ROOTDEVNAME=\"ufs:md0\" Modified: soc2012/aleek/beaglexm-armv6/sys/kern/init_main.c ============================================================================== --- soc2012/aleek/beaglexm-armv6/sys/kern/init_main.c Tue Jul 10 08:31:28 2012 (r239236) +++ soc2012/aleek/beaglexm-armv6/sys/kern/init_main.c Tue Jul 10 11:21:02 2012 (r239237) @@ -709,7 +709,6 @@ printf("start_init: trying %.*s\n", (int)(next - path), path); - printf( "%s:%d\n", __FUNCTION__, __LINE__ ); /* * Move out the boot flag argument. */ @@ -720,7 +719,6 @@ (void)subyte(--ucp, 's'); options = 1; } - printf( "%s:%d\n", __FUNCTION__, __LINE__ ); #ifdef notyet if (boothowto & RB_FASTBOOT) { (void)subyte(--ucp, 'f'); @@ -733,7 +731,6 @@ options = 1; #endif - printf( "%s:%d\n", __FUNCTION__, __LINE__ ); if (options == 0) (void)subyte(--ucp, '-'); (void)subyte(--ucp, '-'); /* leading hyphen */ @@ -747,7 +744,6 @@ (void)subyte(--ucp, *s); arg0 = ucp; - printf( "%s:%d\n", __FUNCTION__, __LINE__ ); /* * Move out the arg pointers. */ @@ -756,7 +752,6 @@ (void)suword((caddr_t)--uap, (long)(intptr_t)arg1); (void)suword((caddr_t)--uap, (long)(intptr_t)arg0); - printf( "%s:%d\n", __FUNCTION__, __LINE__ ); /* * Point at the arguments. */ @@ -764,7 +759,6 @@ args.argv = uap; args.envv = NULL; - printf( "%s:%d\n", __FUNCTION__, __LINE__ ); /* * Now try to exec the program. If can't for any reason * other than it doesn't exist, complain. @@ -776,11 +770,9 @@ mtx_unlock(&Giant); return; } - printf( "%s:%d\n", __FUNCTION__, __LINE__ ); if (error != ENOENT) printf("exec %.*s: error %d\n", (int)(next - path), path, error); - printf( "%s:%d\n", __FUNCTION__, __LINE__ ); } printf("init: not found in path %s\n", init_path); panic("no init"); From owner-svn-soc-all@FreeBSD.ORG Tue Jul 10 15:14:29 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 013F91065672 for ; Tue, 10 Jul 2012 15:14:27 +0000 (UTC) (envelope-from vchan@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Tue, 10 Jul 2012 15:14:26 +0000 Date: Tue, 10 Jul 2012 15:14:26 +0000 From: vchan@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120710151427.013F91065672@hub.freebsd.org> Cc: Subject: socsvn commit: r239240 - in soc2012/vchan: ggate gtcp/bwalex-tc-play X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Jul 2012 15:14:29 -0000 Author: vchan Date: Tue Jul 10 15:14:26 2012 New Revision: 239240 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239240 Log: debugged a few functions Deleted: soc2012/vchan/ggate/ Modified: soc2012/vchan/gtcp/bwalex-tc-play/tcplay.c Modified: soc2012/vchan/gtcp/bwalex-tc-play/tcplay.c ============================================================================== --- soc2012/vchan/gtcp/bwalex-tc-play/tcplay.c Tue Jul 10 14:21:25 2012 (r239239) +++ soc2012/vchan/gtcp/bwalex-tc-play/tcplay.c Tue Jul 10 15:14:26 2012 (r239240) @@ -29,9 +29,9 @@ #include -#if defined(__DragonFly__) +//#if defined(__DragonFly__) #include -#endif +//#endif #include #include @@ -47,7 +47,7 @@ //#include //#elif defined(__DragonFly__) //#include -//#include +#include #include #include @@ -110,19 +110,19 @@ { "SERPENT-128-XTS", "serpent-xts-plain", 32, 8 }, #endif { "AES-256-XTS", "aes-xts-plain", 64, 8 }, - { "TWOFISH-256-XTS", "twofish-xts-plain", 64, 8 }, - { "SERPENT-256-XTS", "serpent-xts-plain", 64, 8 }, + /*{ "TWOFISH-256-XTS", "twofish-xts-plain", 64, 8 }, + { "SERPENT-256-XTS", "serpent-xts-plain", 64, 8 },*/ { NULL, NULL, 0, 0 } }; const char *valid_cipher_chains[][MAX_CIPHER_CHAINS] = { { "AES-256-XTS", NULL }, - { "TWOFISH-256-XTS", NULL }, + /*{ "TWOFISH-256-XTS", NULL }, { "SERPENT-256-XTS", NULL }, { "AES-256-XTS", "TWOFISH-256-XTS", "SERPENT-256-XTS", NULL }, { "SERPENT-256-XTS", "TWOFISH-256-XTS", "AES-256-XTS", NULL }, #if 0 - /* It seems that all the two-way cascades are the other way round... */ + It seems that all the two-way cascades are the other way round... { "AES-256-XTS", "TWOFISH-256-XTS", NULL }, { "SERPENT-256-XTS", "AES-256-XTS", NULL }, { "TWOFISH-256-XTS", "SERPENT-256-XTS", NULL }, @@ -130,7 +130,7 @@ #endif { "TWOFISH-256-XTS", "AES-256-XTS", NULL }, { "AES-256-XTS", "SERPENT-256-XTS", NULL }, - { "SERPENT-256-XTS", "TWOFISH-256-XTS", NULL }, + { "SERPENT-256-XTS", "TWOFISH-256-XTS", NULL },*/ { NULL } }; @@ -926,7 +926,40 @@ return -1; } - +int +map_volume(const char *map_name, int sflag, + int interactive, time_t timeout) + +{ + + struct g_gate_ctl_create ggioc; + int fd; + + fd = open(map_name, g_gate_openflags(sflags) | O_DIRECT | O_FSYNC); + if (fd == -1) + err(EXIT_FAILURE, "Cannot open %s", map_name); + ggioc.gctl_version = G_GATE_VERSION; + ggioc.gctl_unit = unit; + ggioc.gctl_mediasize = g_gate_mediasize(fd); + if (sectorsize == 0) + sectorsize = g_gate_sectorsize(fd); + ggioc.gctl_sectorsize = sectorsize; + ggioc.gctl_timeout = timeout; + ggioc.gctl_flags = sflags; + ggioc.gctl_maxcount = 0; + strlcpy(ggioc.gctl_info, map_name, sizeof(ggioc.gctl_info)); + g_gate_ioctl(G_GATE_CMD_CREATE, &ggioc); + if (unit == -1) + printf("%s%u\n", G_GATE_PROVIDER_NAME, ggioc.gctl_unit); + unit = ggioc.gctl_unit; + g_gatel_serve(fd); +} + + if (interactive) + printf("All ok!\n"); + + return 0; +} /* int map_volume(const char *map_name, const char *device, int sflag, @@ -964,7 +997,7 @@ */ static -void +int dm_remove_device() { int ret = EINVAL; @@ -1169,7 +1202,7 @@ uu_stack[j-1]); #endif if ((uu_stack[j-1] == NULL) || - ((r = /*and here*/dm_remove_device(uu_stack[--j])) != 0)) { + ((r = dm_remove_device(uu_stack[--j])) != 0)) { tc_log(1, "Tried to unroll dm changes, " "giving up.\n"); break; @@ -1195,7 +1228,7 @@ char map[PATH_MAX]; int i, error; - if ((error = /*and here*/dm_remove_device(mapname)) != 0) { + if ((error = dm_remove_device(mapname)) != 0) { tc_log(1, "Could not remove mapping %s\n", mapname); return error; } From owner-svn-soc-all@FreeBSD.ORG Tue Jul 10 15:16:52 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 5D898106564A for ; Tue, 10 Jul 2012 15:16:50 +0000 (UTC) (envelope-from vchan@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Tue, 10 Jul 2012 15:16:50 +0000 Date: Tue, 10 Jul 2012 15:16:50 +0000 From: vchan@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120710151650.5D898106564A@hub.freebsd.org> Cc: Subject: socsvn commit: r239241 - in soc2012/vchan/ggate: . ggatec ggated ggatel shared X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Jul 2012 15:16:52 -0000 Author: vchan Date: Tue Jul 10 15:16:50 2012 New Revision: 239241 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239241 Log: added ggate back in Added: soc2012/vchan/ggate/ soc2012/vchan/ggate/Makefile soc2012/vchan/ggate/Makefile.inc soc2012/vchan/ggate/ggatec/ soc2012/vchan/ggate/ggatec/Makefile soc2012/vchan/ggate/ggatec/ggatec.8 soc2012/vchan/ggate/ggatec/ggatec.c soc2012/vchan/ggate/ggated/ soc2012/vchan/ggate/ggated/Makefile soc2012/vchan/ggate/ggated/ggated.8 soc2012/vchan/ggate/ggated/ggated.c soc2012/vchan/ggate/ggatel/ soc2012/vchan/ggate/ggatel/Makefile soc2012/vchan/ggate/ggatel/ggatel.8 soc2012/vchan/ggate/ggatel/ggatel.c soc2012/vchan/ggate/shared/ soc2012/vchan/ggate/shared/ggate.c soc2012/vchan/ggate/shared/ggate.h Added: soc2012/vchan/ggate/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/vchan/ggate/Makefile Tue Jul 10 15:16:50 2012 (r239241) @@ -0,0 +1,14 @@ +# $FreeBSD: release/9.0.0/sbin/ggate/Makefile 177714 2008-03-29 17:44:40Z ru $ + +.include + +SUBDIR= ${_ggatec} \ + ${_ggated} \ + ggatel + +.if ${MK_LIBTHR} != "no" +_ggatec= ggatec +_ggated= ggated +.endif + +.include Added: soc2012/vchan/ggate/Makefile.inc ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/vchan/ggate/Makefile.inc Tue Jul 10 15:16:50 2012 (r239241) @@ -0,0 +1,3 @@ +# $FreeBSD: release/9.0.0/sbin/ggate/Makefile.inc 198236 2009-10-19 16:00:24Z ru $ + +.include "../Makefile.inc" Added: soc2012/vchan/ggate/ggatec/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/vchan/ggate/ggatec/Makefile Tue Jul 10 15:16:50 2012 (r239241) @@ -0,0 +1,16 @@ +# $FreeBSD: release/9.0.0/sbin/ggate/ggatec/Makefile 168422 2007-04-06 11:19:48Z pjd $ + +.PATH: ${.CURDIR}/../shared + +PROG= ggatec +MAN= ggatec.8 +SRCS= ggatec.c ggate.c + +CFLAGS+= -DMAX_SEND_SIZE=32768 +CFLAGS+= -DLIBGEOM +CFLAGS+= -I${.CURDIR}/../shared + +DPADD= ${LIBGEOM} ${LIBSBUF} ${LIBBSDXML} ${LIBUTIL} ${LIBPTHREAD} +LDADD= -lgeom -lsbuf -lbsdxml -lutil -lpthread + +.include Added: soc2012/vchan/ggate/ggatec/ggatec.8 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/vchan/ggate/ggatec/ggatec.8 Tue Jul 10 15:16:50 2012 (r239241) @@ -0,0 +1,181 @@ +.\" Copyright (c) 2004 Pawel Jakub Dawidek +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" $FreeBSD: release/9.0.0/sbin/ggate/ggatec/ggatec.8 162395 2006-09-18 11:55:10Z ru $ +.\" +.Dd April 26, 2004 +.Dt GGATEC 8 +.Os +.Sh NAME +.Nm ggatec +.Nd "GEOM Gate network client and control utility" +.Sh SYNOPSIS +.Nm +.Cm create +.Op Fl n +.Op Fl v +.Op Fl o Cm ro | wo | rw +.Op Fl p Ar port +.Op Fl q Ar queue_size +.Op Fl R Ar rcvbuf +.Op Fl S Ar sndbuf +.Op Fl s Ar sectorsize +.Op Fl t Ar timeout +.Op Fl u Ar unit +.Ar host +.Ar path +.Nm +.Cm rescue +.Op Fl n +.Op Fl v +.Op Fl o Cm ro | wo | rw +.Op Fl p Ar port +.Op Fl R Ar rcvbuf +.Op Fl S Ar sndbuf +.Fl u Ar unit +.Ar host +.Ar path +.Nm +.Cm destroy +.Op Fl f +.Fl u Ar unit +.Nm +.Cm list +.Op Fl v +.Op Fl u Ar unit +.Sh DESCRIPTION +The +.Nm +utility is a network client for GEOM Gate class. +It is responsible for creation of +.Nm ggate +devices and forwarding I/O requests between +.Nm geom_gate.ko +kernel module and +.Xr ggated 8 +network daemon. +Available commands: +.Bl -tag -width ".Cm destroy" +.It Cm create +Connect to given +.Xr ggated 8 +daemon and create a +.Nm ggate +provider related to the given remote file or device. +.It Cm rescue +If +.Nm +process died/has been killed, you can save situation with this +command, which creates new connection to the +.Xr ggated 8 +daemon and will handle pending and future requests. +.It Cm destroy +Destroy the given +.Nm ggate +provider. +.It Cm list +List +.Nm ggate +providers. +.El +.Pp +Available options: +.Bl -tag -width ".Fl s Cm ro | wo | rw" +.It Fl f +Forcibly destroy +.Nm ggate +provider (cancels all pending requests). +.It Fl n +Do not use +.Dv TCP_NODELAY +option on TCP sockets. +.It Fl o Cm ro | wo | rw +Specify permission to use when opening the file or device: read-only +.Pq Cm ro , +write-only +.Pq Cm wo , +or read-write +.Pq Cm rw . +Default is +.Cm rw . +.It Fl p Ar port +Port to connect to on the remote host. +Default is 3080. +.It Fl q Ar queue_size +Number of pending I/O requests that can be queued before they will +start to be canceled. +Default is 1024. +.It Fl R Ar rcvbuf +Size of receive buffer to use. +Default is 131072 (128kB). +.It Fl S Ar sndbuf +Size of send buffer to use. +Default is 131072 (128kB). +.It Fl s Ar sectorsize +Sector size for +.Nm ggate +provider. +If not specified, it is taken from device, or set to 512 bytes for files. +.It Fl t Ar timeout +Number of seconds to wait before an I/O request will be canceled. +0 means no timeout. +Default is 0. +.It Fl u Ar unit +Unit number to use. +.It Fl v +Do not fork, run in foreground and print debug informations on standard +output. +.It Ar host +Remote host to connect to. +.It Ar path +Path to a regular file or device. +.El +.Sh EXIT STATUS +Exit status is 0 on success, or 1 if the command fails. +To get details about the failure, +.Nm +should be called with the +.Fl v +option. +.Sh EXAMPLES +Make use of CD-ROM device from remote host. +.Bd -literal -offset indent +server# cat /etc/gg.exports +client RO /dev/acd0 +server# ggated + +client# ggatec create -o ro server /dev/acd0 +ggate0 +client# mount_cd9660 /dev/ggate0 /cdrom +.Ed +.Sh SEE ALSO +.Xr geom 4 , +.Xr ggated 8 , +.Xr ggatel 8 , +.Xr mount_cd9660 8 +.Sh AUTHORS +The +.Nm +utility as well as this manual page was written by +.An Pawel Jakub Dawidek Aq pjd@FreeBSD.org . Added: soc2012/vchan/ggate/ggatec/ggatec.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/vchan/ggate/ggatec/ggatec.c Tue Jul 10 15:16:50 2012 (r239241) @@ -0,0 +1,642 @@ +/*- + * Copyright (c) 2004 Pawel Jakub Dawidek + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD: release/9.0.0/sbin/ggate/ggatec/ggatec.c 204076 2010-02-18 23:16:19Z pjd $ + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include "ggate.h" + + +enum { UNSET, CREATE, DESTROY, LIST, RESCUE } action = UNSET; + +static const char *path = NULL; +static const char *host = NULL; +static int unit = G_GATE_UNIT_AUTO; +static unsigned flags = 0; +static int force = 0; +static unsigned queue_size = G_GATE_QUEUE_SIZE; +static unsigned port = G_GATE_PORT; +static off_t mediasize; +static unsigned sectorsize = 0; +static unsigned timeout = G_GATE_TIMEOUT; +static int sendfd, recvfd; +static uint32_t token; +static pthread_t sendtd, recvtd; +static int reconnect; + +static void +usage(void) +{ + + fprintf(stderr, "usage: %s create [-nv] [-o ] [-p port] " + "[-q queue_size] [-R rcvbuf] [-S sndbuf] [-s sectorsize] " + "[-t timeout] [-u unit] \n", getprogname()); + fprintf(stderr, " %s rescue [-nv] [-o ] [-p port] " + "[-R rcvbuf] [-S sndbuf] <-u unit> \n", getprogname()); + fprintf(stderr, " %s destroy [-f] <-u unit>\n", getprogname()); + fprintf(stderr, " %s list [-v] [-u unit]\n", getprogname()); + exit(EXIT_FAILURE); +} + +static void * +send_thread(void *arg __unused) +{ + struct g_gate_ctl_io ggio; + struct g_gate_hdr hdr; + char buf[MAXPHYS]; + ssize_t data; + int error; + + g_gate_log(LOG_NOTICE, "%s: started!", __func__); + + ggio.gctl_version = G_GATE_VERSION; + ggio.gctl_unit = unit; + ggio.gctl_data = buf; + + for (;;) { + ggio.gctl_length = sizeof(buf); + ggio.gctl_error = 0; + g_gate_ioctl(G_GATE_CMD_START, &ggio); + error = ggio.gctl_error; + switch (error) { + case 0: + break; + case ECANCELED: + if (reconnect) + break; + /* Exit gracefully. */ + g_gate_close_device(); + exit(EXIT_SUCCESS); +#if 0 + case ENOMEM: + /* Buffer too small. */ + ggio.gctl_data = realloc(ggio.gctl_data, + ggio.gctl_length); + if (ggio.gctl_data != NULL) { + bsize = ggio.gctl_length; + goto once_again; + } + /* FALLTHROUGH */ +#endif + case ENXIO: + default: + g_gate_xlog("ioctl(/dev/%s): %s.", G_GATE_CTL_NAME, + strerror(error)); + } + + if (reconnect) + break; + + switch (ggio.gctl_cmd) { + case BIO_READ: + hdr.gh_cmd = GGATE_CMD_READ; + break; + case BIO_WRITE: + hdr.gh_cmd = GGATE_CMD_WRITE; + break; + } + hdr.gh_seq = ggio.gctl_seq; + hdr.gh_offset = ggio.gctl_offset; + hdr.gh_length = ggio.gctl_length; + hdr.gh_error = 0; + g_gate_swap2n_hdr(&hdr); + + data = g_gate_send(sendfd, &hdr, sizeof(hdr), MSG_NOSIGNAL); + g_gate_log(LOG_DEBUG, "Sent hdr packet."); + g_gate_swap2h_hdr(&hdr); + if (reconnect) + break; + if (data != sizeof(hdr)) { + g_gate_log(LOG_ERR, "Lost connection 1."); + reconnect = 1; + pthread_kill(recvtd, SIGUSR1); + break; + } + + if (hdr.gh_cmd == GGATE_CMD_WRITE) { + data = g_gate_send(sendfd, ggio.gctl_data, + ggio.gctl_length, MSG_NOSIGNAL); + if (reconnect) + break; + if (data != ggio.gctl_length) { + g_gate_log(LOG_ERR, "Lost connection 2 (%zd != %zd).", data, (ssize_t)ggio.gctl_length); + reconnect = 1; + pthread_kill(recvtd, SIGUSR1); + break; + } + g_gate_log(LOG_DEBUG, "Sent %zd bytes (offset=%llu, " + "size=%u).", data, hdr.gh_offset, hdr.gh_length); + } + } + g_gate_log(LOG_DEBUG, "%s: Died.", __func__); + return (NULL); +} + +static void * +recv_thread(void *arg __unused) +{ + struct g_gate_ctl_io ggio; + struct g_gate_hdr hdr; + char buf[MAXPHYS]; + ssize_t data; + + g_gate_log(LOG_NOTICE, "%s: started!", __func__); + + ggio.gctl_version = G_GATE_VERSION; + ggio.gctl_unit = unit; + ggio.gctl_data = buf; + + for (;;) { + data = g_gate_recv(recvfd, &hdr, sizeof(hdr), MSG_WAITALL); + if (reconnect) + break; + g_gate_swap2h_hdr(&hdr); + if (data != sizeof(hdr)) { + if (data == -1 && errno == EAGAIN) + continue; + g_gate_log(LOG_ERR, "Lost connection 3."); + reconnect = 1; + pthread_kill(sendtd, SIGUSR1); + break; + } + g_gate_log(LOG_DEBUG, "Received hdr packet."); + + ggio.gctl_seq = hdr.gh_seq; + ggio.gctl_cmd = hdr.gh_cmd; + ggio.gctl_offset = hdr.gh_offset; + ggio.gctl_length = hdr.gh_length; + ggio.gctl_error = hdr.gh_error; + + if (ggio.gctl_error == 0 && ggio.gctl_cmd == GGATE_CMD_READ) { + data = g_gate_recv(recvfd, ggio.gctl_data, + ggio.gctl_length, MSG_WAITALL); + if (reconnect) + break; + g_gate_log(LOG_DEBUG, "Received data packet."); + if (data != ggio.gctl_length) { + g_gate_log(LOG_ERR, "Lost connection 4."); + reconnect = 1; + pthread_kill(sendtd, SIGUSR1); + break; + } + g_gate_log(LOG_DEBUG, "Received %d bytes (offset=%ju, " + "size=%zu).", data, (uintmax_t)hdr.gh_offset, + (size_t)hdr.gh_length); + } + + g_gate_ioctl(G_GATE_CMD_DONE, &ggio); + } + g_gate_log(LOG_DEBUG, "%s: Died.", __func__); + pthread_exit(NULL); +} + +static int +handshake(int dir) +{ + struct g_gate_version ver; + struct g_gate_cinit cinit; + struct g_gate_sinit sinit; + struct sockaddr_in serv; + int sfd; + + /* + * Do the network stuff. + */ + bzero(&serv, sizeof(serv)); + serv.sin_family = AF_INET; + serv.sin_addr.s_addr = g_gate_str2ip(host); + if (serv.sin_addr.s_addr == INADDR_NONE) { + g_gate_log(LOG_DEBUG, "Invalid IP/host name: %s.", host); + return (-1); + } + serv.sin_port = htons(port); + sfd = socket(AF_INET, SOCK_STREAM, 0); + if (sfd == -1) { + g_gate_log(LOG_DEBUG, "Cannot open socket: %s.", + strerror(errno)); + return (-1); + } + + g_gate_socket_settings(sfd); + + if (connect(sfd, (struct sockaddr *)&serv, sizeof(serv)) == -1) { + g_gate_log(LOG_DEBUG, "Cannot connect to server: %s.", + strerror(errno)); + close(sfd); + return (-1); + } + + g_gate_log(LOG_INFO, "Connected to the server: %s:%d.", host, port); + + /* + * Create and send version packet. + */ + g_gate_log(LOG_DEBUG, "Sending version packet."); + assert(strlen(GGATE_MAGIC) == sizeof(ver.gv_magic)); + bcopy(GGATE_MAGIC, ver.gv_magic, sizeof(ver.gv_magic)); + ver.gv_version = GGATE_VERSION; + ver.gv_error = 0; + g_gate_swap2n_version(&ver); + if (g_gate_send(sfd, &ver, sizeof(ver), MSG_NOSIGNAL) == -1) { + g_gate_log(LOG_DEBUG, "Error while sending version packet: %s.", + strerror(errno)); + close(sfd); + return (-1); + } + bzero(&ver, sizeof(ver)); + if (g_gate_recv(sfd, &ver, sizeof(ver), MSG_WAITALL) == -1) { + g_gate_log(LOG_DEBUG, "Error while receiving data: %s.", + strerror(errno)); + close(sfd); + return (-1); + } + if (ver.gv_error != 0) { + g_gate_log(LOG_DEBUG, "Version verification problem: %s.", + strerror(errno)); + close(sfd); + return (-1); + } + + /* + * Create and send initial packet. + */ + g_gate_log(LOG_DEBUG, "Sending initial packet."); + if (strlcpy(cinit.gc_path, path, sizeof(cinit.gc_path)) >= + sizeof(cinit.gc_path)) { + g_gate_log(LOG_DEBUG, "Path name too long."); + close(sfd); + return (-1); + } + cinit.gc_flags = flags | dir; + cinit.gc_token = token; + cinit.gc_nconn = 2; + g_gate_swap2n_cinit(&cinit); + if (g_gate_send(sfd, &cinit, sizeof(cinit), MSG_NOSIGNAL) == -1) { + g_gate_log(LOG_DEBUG, "Error while sending initial packet: %s.", + strerror(errno)); + close(sfd); + return (-1); + } + g_gate_swap2h_cinit(&cinit); + + /* + * Receiving initial packet from server. + */ + g_gate_log(LOG_DEBUG, "Receiving initial packet."); + if (g_gate_recv(sfd, &sinit, sizeof(sinit), MSG_WAITALL) == -1) { + g_gate_log(LOG_DEBUG, "Error while receiving data: %s.", + strerror(errno)); + close(sfd); + return (-1); + } + g_gate_swap2h_sinit(&sinit); + if (sinit.gs_error != 0) { + g_gate_log(LOG_DEBUG, "Error from server: %s.", + strerror(sinit.gs_error)); + close(sfd); + return (-1); + } + g_gate_log(LOG_DEBUG, "Received initial packet."); + + mediasize = sinit.gs_mediasize; + if (sectorsize == 0) + sectorsize = sinit.gs_sectorsize; + + return (sfd); +} + +static void +mydaemon(void) +{ + + if (g_gate_verbose > 0) + return; + if (daemon(0, 0) == 0) + return; + if (action == CREATE) + g_gate_destroy(unit, 1); + err(EXIT_FAILURE, "Cannot daemonize"); +} + +static int +g_gatec_connect(void) +{ + + token = arc4random(); + /* + * Our receive descriptor is connected to the send descriptor on the + * server side. + */ + recvfd = handshake(GGATE_FLAG_SEND); + if (recvfd == -1) + return (0); + /* + * Our send descriptor is connected to the receive descriptor on the + * server side. + */ + sendfd = handshake(GGATE_FLAG_RECV); + if (sendfd == -1) + return (0); + return (1); +} + +static void +g_gatec_start(void) +{ + int error; + + reconnect = 0; + error = pthread_create(&recvtd, NULL, recv_thread, NULL); + if (error != 0) { + g_gate_destroy(unit, 1); + g_gate_xlog("pthread_create(recv_thread): %s.", + strerror(error)); + } + sendtd = pthread_self(); + send_thread(NULL); + /* Disconnected. */ + close(sendfd); + close(recvfd); +} + +static void +signop(int sig __unused) +{ + + /* Do nothing. */ +} + +static void +g_gatec_loop(void) +{ + struct g_gate_ctl_cancel ggioc; + + signal(SIGUSR1, signop); + for (;;) { + g_gatec_start(); + g_gate_log(LOG_NOTICE, "Disconnected [%s %s]. Connecting...", + host, path); + while (!g_gatec_connect()) { + sleep(2); + g_gate_log(LOG_NOTICE, "Connecting [%s %s]...", host, + path); + } + ggioc.gctl_version = G_GATE_VERSION; + ggioc.gctl_unit = unit; + ggioc.gctl_seq = 0; + g_gate_ioctl(G_GATE_CMD_CANCEL, &ggioc); + } +} + +static void +g_gatec_create(void) +{ + struct g_gate_ctl_create ggioc; + + if (!g_gatec_connect()) + g_gate_xlog("Cannot connect: %s.", strerror(errno)); + + /* + * Ok, got both sockets, time to create provider. + */ + ggioc.gctl_version = G_GATE_VERSION; + ggioc.gctl_mediasize = mediasize; + ggioc.gctl_sectorsize = sectorsize; + ggioc.gctl_flags = flags; + ggioc.gctl_maxcount = queue_size; + ggioc.gctl_timeout = timeout; + ggioc.gctl_unit = unit; + snprintf(ggioc.gctl_info, sizeof(ggioc.gctl_info), "%s:%u %s", host, + port, path); + g_gate_ioctl(G_GATE_CMD_CREATE, &ggioc); + if (unit == -1) { + printf("%s%u\n", G_GATE_PROVIDER_NAME, ggioc.gctl_unit); + fflush(stdout); + } + unit = ggioc.gctl_unit; + + mydaemon(); + g_gatec_loop(); +} + +static void +g_gatec_rescue(void) +{ + struct g_gate_ctl_cancel ggioc; + + if (!g_gatec_connect()) + g_gate_xlog("Cannot connect: %s.", strerror(errno)); + + ggioc.gctl_version = G_GATE_VERSION; + ggioc.gctl_unit = unit; + ggioc.gctl_seq = 0; + g_gate_ioctl(G_GATE_CMD_CANCEL, &ggioc); + + mydaemon(); + g_gatec_loop(); +} + +int +main(int argc, char *argv[]) +{ + + if (argc < 2) + usage(); + if (strcasecmp(argv[1], "create") == 0) + action = CREATE; + else if (strcasecmp(argv[1], "destroy") == 0) + action = DESTROY; + else if (strcasecmp(argv[1], "list") == 0) + action = LIST; + else if (strcasecmp(argv[1], "rescue") == 0) + action = RESCUE; + else + usage(); + argc -= 1; + argv += 1; + for (;;) { + int ch; + + ch = getopt(argc, argv, "fno:p:q:R:S:s:t:u:v"); + if (ch == -1) + break; + switch (ch) { + case 'f': + if (action != DESTROY) + usage(); + force = 1; + break; + case 'n': + if (action != CREATE && action != RESCUE) + usage(); + nagle = 0; + break; + case 'o': + if (action != CREATE && action != RESCUE) + usage(); + if (strcasecmp("ro", optarg) == 0) + flags = G_GATE_FLAG_READONLY; + else if (strcasecmp("wo", optarg) == 0) + flags = G_GATE_FLAG_WRITEONLY; + else if (strcasecmp("rw", optarg) == 0) + flags = 0; + else { + errx(EXIT_FAILURE, + "Invalid argument for '-o' option."); + } + break; + case 'p': + if (action != CREATE && action != RESCUE) + usage(); + errno = 0; + port = strtoul(optarg, NULL, 10); + if (port == 0 && errno != 0) + errx(EXIT_FAILURE, "Invalid port."); + break; + case 'q': + if (action != CREATE) + usage(); + errno = 0; + queue_size = strtoul(optarg, NULL, 10); + if (queue_size == 0 && errno != 0) + errx(EXIT_FAILURE, "Invalid queue_size."); + break; + case 'R': + if (action != CREATE && action != RESCUE) + usage(); + errno = 0; + rcvbuf = strtoul(optarg, NULL, 10); + if (rcvbuf == 0 && errno != 0) + errx(EXIT_FAILURE, "Invalid rcvbuf."); + break; + case 'S': + if (action != CREATE && action != RESCUE) + usage(); + errno = 0; + sndbuf = strtoul(optarg, NULL, 10); + if (sndbuf == 0 && errno != 0) + errx(EXIT_FAILURE, "Invalid sndbuf."); + break; + case 's': + if (action != CREATE) + usage(); + errno = 0; + sectorsize = strtoul(optarg, NULL, 10); + if (sectorsize == 0 && errno != 0) + errx(EXIT_FAILURE, "Invalid sectorsize."); + break; + case 't': + if (action != CREATE) + usage(); + errno = 0; + timeout = strtoul(optarg, NULL, 10); + if (timeout == 0 && errno != 0) + errx(EXIT_FAILURE, "Invalid timeout."); + break; + case 'u': + errno = 0; + unit = strtol(optarg, NULL, 10); + if (unit == 0 && errno != 0) + errx(EXIT_FAILURE, "Invalid unit number."); + break; + case 'v': + if (action == DESTROY) + usage(); + g_gate_verbose++; + break; + default: + usage(); + } + } + argc -= optind; + argv += optind; + + switch (action) { + case CREATE: + if (argc != 2) + usage(); + g_gate_load_module(); + g_gate_open_device(); + host = argv[0]; + path = argv[1]; + g_gatec_create(); + break; + case DESTROY: + if (unit == -1) { + fprintf(stderr, "Required unit number.\n"); + usage(); + } + g_gate_verbose = 1; + g_gate_open_device(); + g_gate_destroy(unit, force); + break; + case LIST: + g_gate_list(unit, g_gate_verbose); + break; + case RESCUE: + if (argc != 2) + usage(); + if (unit == -1) { + fprintf(stderr, "Required unit number.\n"); + usage(); + } + g_gate_open_device(); + host = argv[0]; + path = argv[1]; + g_gatec_rescue(); + break; + case UNSET: + default: + usage(); + } + g_gate_close_device(); + exit(EXIT_SUCCESS); +} Added: soc2012/vchan/ggate/ggated/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/vchan/ggate/ggated/Makefile Tue Jul 10 15:16:50 2012 (r239241) @@ -0,0 +1,14 @@ +# $FreeBSD: release/9.0.0/sbin/ggate/ggated/Makefile 147887 2005-07-10 21:10:20Z pjd $ + +.PATH: ${.CURDIR}/../shared + +PROG= ggated +MAN= ggated.8 +SRCS= ggated.c ggate.c + +DPADD= ${LIBPTHREAD} +LDADD= -lpthread + +CFLAGS+= -I${.CURDIR}/../shared + +.include Added: soc2012/vchan/ggate/ggated/ggated.8 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/vchan/ggate/ggated/ggated.8 Tue Jul 10 15:16:50 2012 (r239241) @@ -0,0 +1,111 @@ +.\" Copyright (c) 2004 Pawel Jakub Dawidek +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" $FreeBSD: release/9.0.0/sbin/ggate/ggated/ggated.8 140415 2005-01-18 10:09:38Z ru $ +.\" +.Dd April 29, 2004 +.Dt GGATED 8 +.Os +.Sh NAME +.Nm ggated +.Nd "GEOM Gate network daemon" +.Sh SYNOPSIS +.Nm +.Op Fl h +.Op Fl n +.Op Fl v +.Op Fl a Ar address +.Op Fl p Ar port +.Op Fl R Ar rcvbuf +.Op Fl S Ar sndbuf +.Op Ar "exports file" +.Sh DESCRIPTION +The +.Nm +utility is a network server for GEOM Gate class. +It runs on a server machine to service GEOM Gate requests from workers +placed on a client machine. +Keep in mind, that connection between +.Xr ggatec 8 +and +.Nm +is not encrypted. +.Pp +Available options: +.Bl -tag -width ".Ar exports\ file" +.It Fl a Ar address +Specifies an IP address to bind to. +.It Fl h +Print available options. +.It Fl n +Do not use +.Dv TCP_NODELAY +option on TCP sockets. +.It Fl p Ar port +Port on which +.Nm +listens for connection. +Default is 3080. +.It Fl R Ar rcvbuf +Size of receive buffer to use. +Default is 131072 (128kB). +.It Fl S Ar sndbuf +Size of send buffer to use. +Default is 131072 (128kB). +.It Fl v +Do not fork, run in foreground and print debug informations on standard +output. +.It Ar "exports file" +An alternate location for the exports file. +.El +.Pp +The format of an exports file is as follows: +.Bd -literal -offset indent +1.2.3.4 RO /dev/acd0 +1.2.3.0/24 RW /tmp/test.img +hostname WO /tmp/image +.Ed +.Sh EXIT STATUS +Exit status is 0 on success, or 1 if the command fails. +To get details about the failure, +.Nm +should be called with the +.Fl v +option. +.Sh EXAMPLES +Export CD-ROM device and a file: +.Bd -literal -offset indent +# echo "1.2.3.0/24 RO /dev/acd0" > /etc/gg.exports +# echo "client RW /image" >> /etc/gg.exports +# ggated +.Ed +.Sh SEE ALSO +.Xr geom 4 , +.Xr ggatec 8 , +.Xr ggatel 8 +.Sh AUTHORS +The +.Nm *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-soc-all@FreeBSD.ORG Tue Jul 10 15:54:07 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 0A9CE106566B for ; Tue, 10 Jul 2012 15:54:05 +0000 (UTC) (envelope-from rudot@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Tue, 10 Jul 2012 15:54:05 +0000 Date: Tue, 10 Jul 2012 15:54:05 +0000 From: rudot@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120710155405.0A9CE106566B@hub.freebsd.org> Cc: Subject: socsvn commit: r239242 - in soc2012/rudot/sys: kern sys X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Jul 2012 15:54:07 -0000 Author: rudot Date: Tue Jul 10 15:54:04 2012 New Revision: 239242 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239242 Log: support any scheduler - 4bsd scheduler is handled as a special case Modified: soc2012/rudot/sys/kern/kern_racct.c soc2012/rudot/sys/sys/sched.h Modified: soc2012/rudot/sys/kern/kern_racct.c ============================================================================== --- soc2012/rudot/sys/kern/kern_racct.c Tue Jul 10 15:16:50 2012 (r239241) +++ soc2012/rudot/sys/kern/kern_racct.c Tue Jul 10 15:54:04 2012 (r239242) @@ -33,6 +33,7 @@ __FBSDID("$FreeBSD: src/sys/kern/kern_racct.c,v 1.18 2012/05/22 15:58:27 trasz Exp $"); #include "opt_kdtrace.h" +#include "opt_sched.h" #include #include @@ -48,7 +49,6 @@ #include #include #include -#include #include #include #include @@ -270,7 +270,10 @@ racct_getpcpu(struct proc *p) { u_int swtime; - fixpt_t p_pctcpu, pctcpu, pctcpu_next; +#ifdef SCHED_4BSD + fixpt_t pctcpu, pctcpu_next; +#endif + fixpt_t p_pctcpu; struct thread *td; swtime = (ticks - p->p_swtick) / hz; @@ -280,11 +283,15 @@ p_pctcpu = 0; FOREACH_THREAD_IN_PROC(p, td) { thread_lock(td); +#ifdef SCHED_4BSD pctcpu = sched_pctcpu(td); /* Count also the yet unfinished second. */ pctcpu_next = (pctcpu * ccpu_exp[1]) >> FSHIFT; pctcpu_next += sched_pctcpu_delta(td); p_pctcpu += max(pctcpu, pctcpu_next); +#else + p_pctcpu += sched_pctcpu(td); +#endif thread_unlock(td); } Modified: soc2012/rudot/sys/sys/sched.h ============================================================================== --- soc2012/rudot/sys/sys/sched.h Tue Jul 10 15:16:50 2012 (r239241) +++ soc2012/rudot/sys/sys/sched.h Tue Jul 10 15:54:04 2012 (r239242) @@ -104,8 +104,10 @@ void sched_wakeup(struct thread *td); void sched_preempt(struct thread *td); #ifdef RACCT +#ifdef SCHED_4BSD fixpt_t sched_pctcpu_delta(struct thread *td); #endif +#endif /* * Threads are moved on and off of run queues From owner-svn-soc-all@FreeBSD.ORG Tue Jul 10 17:32:54 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id A1C861065670 for ; Tue, 10 Jul 2012 17:32:52 +0000 (UTC) (envelope-from gpf@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Tue, 10 Jul 2012 17:32:52 +0000 Date: Tue, 10 Jul 2012 17:32:52 +0000 From: gpf@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120710173252.A1C861065670@hub.freebsd.org> Cc: Subject: socsvn commit: r239244 - in soc2012/gpf/pefs_kmod: sbin/pefs sys/fs/pefs X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Jul 2012 17:32:54 -0000 Author: gpf Date: Tue Jul 10 17:32:52 2012 New Revision: 239244 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239244 Log: take care of dynamic memory - free RB tree kept for hardlinks - new allocation function for struct file_header. moving all initialization code to this function really helps. - new function to free struct file_header - free global file header tailq - also fixing a few leaks in case of error here and there. Modified: soc2012/gpf/pefs_kmod/sbin/pefs/pefs_checksum.c soc2012/gpf/pefs_kmod/sbin/pefs/pefs_ctl.c soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_checksum.c Modified: soc2012/gpf/pefs_kmod/sbin/pefs/pefs_checksum.c ============================================================================== --- soc2012/gpf/pefs_kmod/sbin/pefs/pefs_checksum.c Tue Jul 10 15:02:29 2012 (r239243) +++ soc2012/gpf/pefs_kmod/sbin/pefs/pefs_checksum.c Tue Jul 10 17:32:52 2012 (r239244) @@ -57,7 +57,7 @@ #include "pefs_ctl.h" -//#define PEFS_INTEGRITY_DEBUG +#define PEFS_INTEGRITY_DEBUG #if defined (PEFS_INTEGRITY_DEBUG) #define dprintf(a) printf a #else @@ -199,9 +199,6 @@ size_t buf_len; struct checksum *csp; - TAILQ_INIT(&(fhp->checksums)); - fhp->nhashes = 0; - if ((flags & PEFS_UNMOUNTED) != 0 || (flags & PEFS_NOKEY) != 0) { buf = fhp->target_path; buf_len = strnlen(fhp->target_path, MAXPATHLEN + 1); @@ -272,8 +269,6 @@ if (fhp->target_path != NULL) return (pefs_compute_symlink_checksum(fhp, md, hash_len, flags)); - TAILQ_INIT(&(fhp->checksums)); - /* XXXgpf: what happens if file size > 2^64? */ if (fstat(fhp->fd, &sb) != 0) { warn("cannot stat file %s", fhp->path); @@ -295,7 +290,6 @@ } } - fhp->nhashes = 0; offset = 0; xsct.pxsct_offset = 0; while (resid > 0) { @@ -339,12 +333,14 @@ csp = malloc(sizeof(struct checksum)); if (csp == NULL) { pefs_warn("memory allocation error"); + EVP_MD_CTX_cleanup(&mdctx); return (PEFS_ERR_SYS); } csp->hash = malloc(hash_len); if (csp->hash == NULL) { pefs_warn("memory allocation error"); free(csp); + EVP_MD_CTX_cleanup(&mdctx); return (PEFS_ERR_SYS); } @@ -436,29 +432,62 @@ return (0); } +static struct file_header * +pefs_allocate_file_header(void) +{ + struct file_header *fhp; + + fhp = malloc(sizeof(struct file_header)); + if (fhp == NULL) { + pefs_warn("memory allocation error"); + return (NULL); + } + + fhp->nhashes = 0; + fhp->offset_to_checksums = 0; + fhp->file_id = 0; + fhp->fd = -1; + fhp->pfd = -1; + fhp->found = 0; + + fhp->target_path = NULL; + + fhp->path[0] = '\0'; + fhp->dirpath[0] = '\0'; + fhp->filename[0] = '\0'; + + TAILQ_INIT(&(fhp->checksums)); + + return (fhp); +} + +static void +pefs_free_file_header(struct file_header *fhp) +{ + struct checksum *csp, *tcsp; + if (fhp != NULL) { + TAILQ_FOREACH_SAFE(csp, &(fhp->checksums), checksum_entries, tcsp) { + TAILQ_REMOVE(&(fhp->checksums), csp, checksum_entries); + if (csp->hash != NULL) + free(csp->hash); + free(csp); + } + if (fhp->target_path != NULL) + free(fhp->target_path); + free(fhp); + } +} + static void pefs_free_hash_table(struct cuckoo_hash_table *chtp) { struct bucket *bp; - struct file_header *fhp; - struct checksum *csp, *tcsp; uint32_t i; if (chtp->buckets1 != NULL) { for (i = 0; i < chtp->size; i++) { bp = &chtp->buckets1[i]; - fhp = bp->fhp; - if (fhp != NULL) { - TAILQ_FOREACH_SAFE(csp, &(fhp->checksums), checksum_entries, tcsp) { - TAILQ_REMOVE(&(fhp->checksums), csp, checksum_entries); - if (csp->hash != NULL) - free(csp->hash); - free(csp); - } - if (fhp->target_path != NULL) - free(fhp->target_path); - free(fhp); - } + pefs_free_file_header(bp->fhp); } free(chtp->buckets1); } @@ -466,23 +495,23 @@ if (chtp->buckets2 != NULL) { for (i = 0; i < chtp->size; i++) { bp = &chtp->buckets2[i]; - fhp = bp->fhp; - if (fhp != NULL) { - TAILQ_FOREACH_SAFE(csp, &(fhp->checksums), checksum_entries, tcsp) { - TAILQ_REMOVE(&(fhp->checksums), csp, checksum_entries); - if (csp->hash != NULL) - free(csp->hash); - free(csp); - } - if (fhp->target_path != NULL) - free(fhp->target_path); - free(fhp); - } + pefs_free_file_header(bp->fhp); } free(chtp->buckets2); } } +static void +pefs_free_file_header_tail(struct file_header_head *fh_headp) +{ + struct file_header *fhp, *tfhp; + + TAILQ_FOREACH_SAFE(fhp, fh_headp, file_header_entries, tfhp) { + TAILQ_REMOVE(fh_headp, fhp, file_header_entries); + pefs_free_file_header(fhp); + } +} + static uint32_t pefs_hash1(struct cuckoo_hash_table *chtp, struct file_header *fhp) { @@ -830,6 +859,18 @@ return 0; } +static void +pefs_rb_free(struct hardlink_head *hlc_headp) +{ + struct hardlink_counter *cur, *next; + + for (cur = RB_MIN(hardlink_head, hlc_headp); cur != NULL; cur = next) { + next = RB_NEXT(hardlink_head, hlc_headp, cur); + RB_REMOVE(hardlink_head, hlc_headp, cur); + free(cur); + } +} + /* open a file and perform various semantic checks on it */ static int pefs_open_semantic_checks(struct file_header *fhp, struct statfs *fsp, struct hardlink_head *hlc_headp, int flags) @@ -842,10 +883,6 @@ size_t target_path_size; int nchars; - /* initialize file descriptors in case error occurs */ - fhp->fd = -1; - fhp->pfd = -1; - /* retrieve dirpath & filename */ strlcpy(dirbuf, fhp->path, sizeof(dirbuf)); strlcpy(namebuf, fhp->path, sizeof(namebuf)); @@ -873,8 +910,6 @@ } if (S_ISLNK(sb.st_mode) != 0) { - fhp->target_path = NULL; - fhp->pfd = open(fhp->dirpath, O_RDONLY); if (fhp->pfd < 0) { warn("cannot open %s", fhp->dirpath); @@ -931,8 +966,6 @@ } return (0); } - else - fhp->target_path = NULL; fhp->fd = open(fhp->path, O_RDONLY | O_NOFOLLOW); if (fhp->fd < 0) { @@ -997,9 +1030,8 @@ buf[strnlen(buf, sizeof(buf)) - 1] = '\0'; dprintf(("\nnext file entry=%s!\n", buf)); - fhp = malloc(sizeof(struct file_header)); + fhp = pefs_allocate_file_header(); if (fhp == NULL) { - warn("memory allocation error"); *error = PEFS_ERR_SYS; return (NULL); } @@ -1058,18 +1090,21 @@ error = pefs_open_semantic_checks(fhp, &fs, &hlc_head, 0); if (error != 0) { pefs_close_file(fhp); + pefs_free_file_header(fhp); return (error); } error = pefs_get_file_id(fhp, 0); if (error != 0) { pefs_close_file(fhp); + pefs_free_file_header(fhp); return (error); } error = pefs_compute_file_checksums(fhp, md, hash_len, 0); if (error != 0) { pefs_close_file(fhp); + pefs_free_file_header(fhp); return (error); } @@ -1083,7 +1118,7 @@ pefs_rb_print(&hlc_head); pefs_rb_warn(&hlc_head); - /* XXXgpf: [TODO] rb_free */ + pefs_rb_free(&hlc_head); error = pefs_allocate_hash_table(chtp, nfiles, PEFS_EXTEND); if (error != 0) @@ -1511,18 +1546,16 @@ int error; //dprintf(("bucket offset = %d\n", *buckets_offset)); - fhp = malloc(sizeof(struct file_header)); - if (fhp == NULL) { - pefs_warn("memory allocation error"); + fhp = pefs_allocate_file_header(); + if (fhp == NULL) return (PEFS_ERR_SYS); - } error = pefs_read_file_header(fdin, fhp, buckets_offset); if (error != 0) return (error); if (fhp->nhashes == 0) { - free(fhp); + pefs_free_file_header(fhp); fhp = NULL; } bp->fhp = fhp; @@ -1556,9 +1589,7 @@ TAILQ_INSERT_TAIL(&(fhp->checksums), csp, checksum_entries); } -/* - * XXXgpf: [TODO] comments - */ +/* Create in memory checksum database by reading .pefs.checksum file. */ static int pefs_read_checksum_file(int fdin, struct checksum_file_header *cfhp, struct cuckoo_hash_table *chtp) { @@ -1579,10 +1610,7 @@ fhp = bp->fhp; if (fhp != NULL) { - TAILQ_INIT(&(fhp->checksums)); hashes_offset = fhp->offset_to_checksums; - fhp->found = 0; - fhp->target_path = NULL; for (k = 0; k < fhp->nhashes; k++) { csp = malloc(sizeof(struct checksum)); @@ -1613,10 +1641,7 @@ fhp = bp->fhp; if (fhp != NULL) { - TAILQ_INIT(&(fhp->checksums)); hashes_offset = fhp->offset_to_checksums; - fhp->found = 0; - fhp->target_path = NULL; for (k = 0; k < fhp->nhashes; k++) { csp = malloc(sizeof(struct checksum)); @@ -1728,9 +1753,8 @@ /* FALLTHROUGH */ case DT_REG: case DT_LNK: - fhp = malloc(sizeof(struct file_header)); + fhp = pefs_allocate_file_header(); if (fhp == NULL) { - warn("memory allocation error"); closedir(dirp); return (PEFS_ERR_SYS); } @@ -1739,7 +1763,7 @@ error = pefs_open_semantic_checks(fhp, fsp, NULL, flags); if (error != 0) { closedir(dirp); - free(fhp); + pefs_free_file_header(fhp); return (error); } @@ -1747,14 +1771,14 @@ if (error != 0) { closedir(dirp); pefs_close_file(fhp); - free(fhp); + pefs_free_file_header(fhp); return (error); } indexfhp = pefs_cuckoo_lookup(chtp, fhp); if (indexfhp == NULL) { pefs_close_file(fhp); - free(fhp); + pefs_free_file_header(fhp); break; } indexfhp->found = 1; @@ -1763,7 +1787,7 @@ if (error != 0) { closedir(dirp); pefs_close_file(fhp); - free(fhp); + pefs_free_file_header(fhp); return (error); } @@ -1773,7 +1797,7 @@ warn("cannot stat file %s", fhp->path); closedir(dirp); pefs_close_file(fhp); - free(fhp); + pefs_free_file_header(fhp); return (PEFS_ERR_SYS); } @@ -1781,7 +1805,7 @@ if (error != 0) { closedir(dirp); pefs_close_file(fhp); - free(fhp); + pefs_free_file_header(fhp); return (error); } @@ -1916,8 +1940,8 @@ out: pefs_free_hash_table(&cht); - /* XXXgpf: [TODO] rb_free */ - /* XXXgpf: [TODO] fh_free */ + pefs_rb_free(&hlc_head); + pefs_free_file_header_tail(&fh_head); return (error); } Modified: soc2012/gpf/pefs_kmod/sbin/pefs/pefs_ctl.c ============================================================================== --- soc2012/gpf/pefs_kmod/sbin/pefs/pefs_ctl.c Tue Jul 10 15:02:29 2012 (r239243) +++ soc2012/gpf/pefs_kmod/sbin/pefs/pefs_ctl.c Tue Jul 10 17:32:52 2012 (r239244) @@ -1020,8 +1020,11 @@ * .pefs.checksum is created under $PWD. path should be a directory, * outside of target pefs filesystem. * - * When $command is run, filesystem must be mounted with pefs, and - * user must have supplied the key. + * When $command is run, filesystem must be mounted with pefs, and + * user must have supplied the necessary key(s). + * + * [TODO] a flag that allows $command to turn on immutable flags for + * every file that requires integrity checking. */ static int pefs_addchecksum(int argc, char *argv[]) @@ -1120,8 +1123,7 @@ * By default, pefs will assume that filesystem is mounted and user * has provided key. * - * Verifying the integrity of the checksum file itself via a signature - * remains a major TODO. + * [TODO] Verify the integrity of the checksum file itself via a signature. */ static int pefs_verify(int argc, char *argv[]) @@ -1172,6 +1174,10 @@ if ((flags & PEFS_UNMOUNTED) == 0) initfsroot(argc, argv, 0, fsroot, sizeof(fsroot)); else { + /* + * XXXgpf: should i also check that fsroot path belongs to + * a non pefs filesystem? + */ strlcpy(fsroot, argv[0], sizeof(fsroot)); if (stat(fsroot, &sb) != 0) { warn("cannot stat fs root: %s", fsroot); @@ -1196,6 +1202,8 @@ return (error); } +/* XXXgpf: [TODO] a command that returns the file id of a file (name MAC) */ + static void pefs_usage_alg(void) { Modified: soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_checksum.c ============================================================================== --- soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_checksum.c Tue Jul 10 15:02:29 2012 (r239243) +++ soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_checksum.c Tue Jul 10 17:32:52 2012 (r239244) @@ -79,6 +79,10 @@ start = &(pcs->pcs_table1[pos * PEFS_HT_CELL_SIZE]); p = start; + /* + * XXXgpf: [TODO] move the reading of a checksum index entry to a different function. + * Also, perhaps a macro to tell if an index entry is empty or not (nhashes == 0). + */ memcpy(&(target_pcie.pcie_nhashes), p, sizeof(target_pcie.pcie_nhashes)); target_pcie.pcie_nhashes = le32toh(target_pcie.pcie_nhashes); if (target_pcie.pcie_nhashes != 0) { From owner-svn-soc-all@FreeBSD.ORG Tue Jul 10 18:20:23 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id AFF931065670 for ; Tue, 10 Jul 2012 18:20:21 +0000 (UTC) (envelope-from gpf@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Tue, 10 Jul 2012 18:20:21 +0000 Date: Tue, 10 Jul 2012 18:20:21 +0000 From: gpf@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120710182021.AFF931065670@hub.freebsd.org> Cc: Subject: socsvn commit: r239245 - soc2012/gpf/pefs_kmod/sbin/pefs X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Jul 2012 18:20:23 -0000 Author: gpf Date: Tue Jul 10 18:20:20 2012 New Revision: 239245 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239245 Log: code refactoring for userland code (mostly stylistic changes) Modified: soc2012/gpf/pefs_kmod/sbin/pefs/pefs_checksum.c soc2012/gpf/pefs_kmod/sbin/pefs/pefs_ctl.h Modified: soc2012/gpf/pefs_kmod/sbin/pefs/pefs_checksum.c ============================================================================== --- soc2012/gpf/pefs_kmod/sbin/pefs/pefs_checksum.c Tue Jul 10 17:32:52 2012 (r239244) +++ soc2012/gpf/pefs_kmod/sbin/pefs/pefs_checksum.c Tue Jul 10 18:20:20 2012 (r239245) @@ -57,7 +57,7 @@ #include "pefs_ctl.h" -#define PEFS_INTEGRITY_DEBUG +//#define PEFS_INTEGRITY_DEBUG #if defined (PEFS_INTEGRITY_DEBUG) #define dprintf(a) printf a #else @@ -72,15 +72,21 @@ #define PEFS_HASH_BYTE_ALIGNMENT 512 #define PEFS_EXTRA_TABLE_SIZE 15 +/* tail that contains a single file's checksums */ TAILQ_HEAD(checksum_head, checksum); +/* tail that contains all file headers that require integrity checking */ TAILQ_HEAD(file_header_head, file_header); +/* tail for all the file_headers that refere to the same inode */ TAILQ_HEAD(hardlink_fh_head, file_header); +/* RB tree for hardlink counters */ RB_HEAD(hardlink_head, hardlink_counter); RB_PROTOTYPE(hardlink_head, hardlink_counter, hardlink_entries, pefs_rb_cmp); -#define PEFS_CFH_SIZE 16 /* on disk size of .pefs.checksum's unique file header */ -#define PEFS_FH_SIZE 16 /* on disk size of a single file header (also a bucket in cuckoo hashing) */ +/* on disk size of .pefs.checksum's unique file header */ +#define PEFS_CFH_SIZE 16 +/* on disk size of a single file header (also a bucket in cuckoo hashing) */ +#define PEFS_FH_SIZE 16 /* this struct is used to check if all hardlinks for a given inode are supplied by the user */ struct hardlink_counter { @@ -206,7 +212,8 @@ else { /* feed parent directory to ioctl() */ strlcpy(xsl.pxsl_filename, fhp->filename, sizeof(xsl.pxsl_filename)); - xsl.pxsl_namelen = strnlen(xsl.pxsl_filename, sizeof(xsl.pxsl_filename)); + xsl.pxsl_namelen = strnlen(xsl.pxsl_filename, + sizeof(xsl.pxsl_filename)); error = ioctl(fhp->pfd, PEFS_GETSLINKCTEXT, &xsl); if (error != 0) { @@ -216,7 +223,8 @@ dprintf(("read %d bytes from kernel\n\n", xsl.pxsl_slink_len)); dprintf(("printing contents of buf:")); - for (i=0; i < (int)xsl.pxsl_slink_len; i++) dprintf(("%c", xsl.pxsl_slink[i])); + for (i=0; i < (int)xsl.pxsl_slink_len; i++) + dprintf(("%c", xsl.pxsl_slink[i])); dprintf(("!\n")); buf = xsl.pxsl_slink; buf_len = xsl.pxsl_slink_len; @@ -378,16 +386,18 @@ } static int -pefs_allocate_hash_table(struct cuckoo_hash_table *chtp, uint32_t nelements, int alloc_flag) +pefs_allocate_hash_table(struct cuckoo_hash_table *chtp, uint32_t nelements, + int alloc_flag) { uint32_t i; if (alloc_flag == PEFS_EXTEND) { /* - * spending 15% more space for each table lowers the chance to fall into an - * infinite loop during cuckoo insertion to about 1.5%. + * spending 15% more space for each table lowers the chance to fall into + * an infinite loop during cuckoo insertion to about 1.5%. */ - chtp->size = pefs_next_prime(nelements + ((nelements * PEFS_EXTRA_TABLE_SIZE)/100)); + chtp->size = pefs_next_prime(nelements + + ((nelements * PEFS_EXTRA_TABLE_SIZE)/100)); chtp->nelements = nelements; if (chtp->size < chtp->nelements) { pefs_warn("numeric overflow while computing hash table size"); @@ -398,7 +408,7 @@ chtp->size = nelements; chtp->nelements = nelements; } - /* reallocate the hash tables in case of infinite loop during cuckoo insert */ + /* re-alloc the hash tables in case of infinite loop during cuckoo insert */ else if (alloc_flag == PEFS_REALLOC) { chtp->size = pefs_next_prime(chtp->size + 1); if (chtp->size < chtp->nelements) { @@ -527,7 +537,8 @@ { uint32_t nbucket; - nbucket = fnv_64_buf(&(fhp->file_id), sizeof(fhp->file_id), FNV1_64_INIT) % chtp->size; + nbucket = fnv_64_buf(&(fhp->file_id), sizeof(fhp->file_id), FNV1_64_INIT) % + chtp->size; dprintf(("hash2: goto bucket %d\n", nbucket)); return (nbucket); @@ -573,7 +584,7 @@ res = pefs_cuckoo_lookup(chtp, elem); if (res != NULL) { pefs_warn("file identifier collision detected between files: %s & %s", - res->path, elem->path); + res->path, elem->path); return (PEFS_ERR_EXIST); } @@ -619,7 +630,6 @@ fhp = chtp->buckets1[i].fhp; dprintf(("\nbucket %d with element: %d\n", i, fhp == NULL ? 0 : 1)); if (fhp != NULL) { - //dprintf(("\tpath=%s\tid = %llu\tnhashes = %d\n", fhp->path, fhp->file_id, fhp->nhashes)); dprintf(("\tid = %llu\tnhashes = %d\n", fhp->file_id, fhp->nhashes)); if (fhp->path[0] == '/') dprintf(("\tpath = %s\n", fhp->path)); @@ -637,7 +647,6 @@ fhp = chtp->buckets2[i].fhp; dprintf(("\nbucket %d with element: %d\n", i, fhp == NULL ? 0 : 1)); if (fhp != NULL) { - //dprintf(("\tpath=%s\tid = %llu\tnhashes = %d\n", fhp->path, fhp->file_id, fhp->nhashes)); dprintf(("\tid = %llu\tnhashes = %d\n", fhp->file_id, fhp->nhashes)); if (fhp->path[0] == '/') dprintf(("\tpath = %s\n", fhp->path)); @@ -683,7 +692,8 @@ r = pefs_name_pton(enc, enc_len, buf, buf_len); if (r <= 0) { - pefs_warn("failed to extract file id from encrypted filename: %s", fhp->filename); + pefs_warn("failed to extract file id from encrypted filename: %s", + fhp->filename); error = PEFS_ERR_GENERIC; } else { @@ -707,7 +717,8 @@ fhp->file_id = be64toh(temp); } else - pefs_warn("failed to fetch file id from kernel for filename: %s", fhp->filename); + pefs_warn("failed to fetch file id from kernel for filename: %s", + fhp->filename); return (error); } @@ -773,8 +784,8 @@ if (error == 0) { res = pefs_cuckoo_lookup(chtp, &targetfh); if (res == NULL) - pefs_warn("target file %s of symlink %s was not found in inputlist", - targetfh.path, fhp->path); + pefs_warn("target file %s of symlink %s was not " + "found in inputlist", targetfh.path, fhp->path); } pefs_close_file(&targetfh); } @@ -807,7 +818,8 @@ RB_FOREACH(hlcp, hardlink_head, hlc_headp) { if (hlcp->total_links > hlcp->links_found) { - pefs_warn("%d hard link(s) of total %d were found in input list for file with inode: %d", + pefs_warn("%d hard link(s) of total %d were found in input list " + "for file with inode: %d", hlcp->links_found, hlcp->total_links, hlcp->inode); i = 1; TAILQ_FOREACH(fhp, &(hlcp->file_headers), fh_hardlink_entries) { @@ -818,7 +830,8 @@ } static int -pefs_rb_insert(struct hardlink_head *hlc_headp, struct file_header *fhp, struct stat *sbp) +pefs_rb_insert(struct hardlink_head *hlc_headp, struct file_header *fhp, + struct stat *sbp) { struct hardlink_counter find, *res, *new_hlcp; @@ -873,7 +886,8 @@ /* open a file and perform various semantic checks on it */ static int -pefs_open_semantic_checks(struct file_header *fhp, struct statfs *fsp, struct hardlink_head *hlc_headp, int flags) +pefs_open_semantic_checks(struct file_header *fhp, struct statfs *fsp, + struct hardlink_head *hlc_headp, int flags) { char dirbuf[MAXPATHLEN + 1], namebuf[MAXNAMLEN + 1]; char sbuf[MAXPATHLEN + 1]; @@ -902,7 +916,8 @@ } strlcpy(fhp->filename, namep, sizeof(fhp->filename)); - dprintf(("path = %s!\ndirname = %s!\nbasename =%s!\n", fhp->path, fhp->dirpath, fhp->filename)); + dprintf(("path = %s!\ndirname = %s!\nbasename =%s!\n", fhp->path, + fhp->dirpath, fhp->filename)); if (lstat(fhp->path, &sb) != 0) { warn("cannot stat file %s", fhp->path); @@ -924,10 +939,10 @@ /* * Target_path can be used to tell if user has supplied target_file - * in input file-list, since symlinks are not traversed. User will have to - * provide fullpaths for both symlink & target file if he wants integrity - * checking for both. However, we will print warning messages in case - * target file is not provided in user supplied input list. + * in input file-list, since symlinks are not traversed. User will have + * to provide fullpaths for both symlink & target file if he wants + * integrity checking for both. However, we will print warning messages + * in case target file is not provided in user supplied input list. * * Target referes to the file immediately pointed to by our symlink, not * the final target of a possible symlink chain. @@ -941,13 +956,15 @@ sbuf[nchars] = '\0'; /* turn relative paths to absolute paths */ - if (sbuf[0] != '/' && (flags & PEFS_UNMOUNTED) == 0 && (flags & PEFS_NOKEY) == 0) - snprintf(fhp->target_path, target_path_size, "%s/%s", fhp->dirpath, sbuf); + if (sbuf[0] != '/' && (flags & PEFS_UNMOUNTED) == 0 && + (flags & PEFS_NOKEY) == 0) + snprintf(fhp->target_path, target_path_size, "%s/%s", + fhp->dirpath, sbuf); else strlcpy(fhp->target_path, sbuf, target_path_size); /* - * The only semantic check that is performed on target file is an attempt + * The only semantic check that's performed on target file is an attempt * to lstat() the file, in order to make sure the file exists. This is * intentional since target file is allowed to reside on a different * filesystem or in the same filesystem, but not be a regular file or a @@ -1047,17 +1064,19 @@ * the checksum file. * A) For each file entry: * A1) semantic checks: - * A1a) file should reside in pefs filesystem & file should be regular file. + * A1a) file should reside in pefs filesystem & file should be + * regular file or symbolic link. * A1b) if symlink, acquire and save the absolute path of the symlink's - * target. Try to lstat() the target but don't do anything else. - * A1c) If hardlink, save a reference to this file entry in our rb tree. - * rb-tree uses inodes as keys and is used in part C to print warnings. + * target. Try to lstat() the target but don't do anything else. + * A1c) If hardlink, save a reference to this file entry in our + * rb tree that uses i-node numbers as keys and is used in + * part 'C' to print warnings. * A1d) Open and store file descriptors to file & parent_directory. - * A2) the file_id is retrieved. + * A2) the file_id is retrieved. (filename MAC) * A3) list of checksums is computed for the file's 4k blocks. * A4) file entry is added to universal fh_head. - * B) Print warnings for hardlinks if the number of links found in inputlist isn't - * equal to the number of total inode links. + * B) Print warnings for hardlinks if the number of links found in inputlist + * isn't equal to the number of total inode links. * C) Hash tables are allocated. * D) Cuckoo insertion: * We try to populate our hash tables using the cuckoo algorithm. Should we fall @@ -1181,7 +1200,8 @@ return (PEFS_ERR_IO); } - bytes = write(fdout, &(cfhp->offset_to_hash_table), sizeof(cfhp->offset_to_hash_table)); + bytes = write(fdout, &(cfhp->offset_to_hash_table), + sizeof(cfhp->offset_to_hash_table)); if (bytes != sizeof(cfhp->offset_to_hash_table)) { warn("error writing to .pefs.checksum"); return (PEFS_ERR_IO); @@ -1198,7 +1218,8 @@ } static int -pefs_write_file_header(int fdout, struct file_header *fhp, uint32_t *buckets_offset) +pefs_write_file_header(int fdout, struct file_header *fhp, + uint32_t *buckets_offset) { uint64_t file_id; uint32_t nhashes, offset_to_checksums; @@ -1213,7 +1234,8 @@ (*buckets_offset)+= sizeof(nhashes); offset_to_checksums = htole32(fhp->offset_to_checksums); - bytes = pwrite(fdout, &offset_to_checksums, sizeof(offset_to_checksums), *buckets_offset); + bytes = pwrite(fdout, &offset_to_checksums, + sizeof(offset_to_checksums), *buckets_offset); if (bytes != sizeof(offset_to_checksums)) { warn("error writing to .pefs.checksum"); return (PEFS_ERR_IO); @@ -1240,8 +1262,9 @@ fhp = bp->fhp; if (fhp == NULL) { /* - * XXXgpf: empty files are not allowed so nhashes == 0 symbolizes an empty bucket. - * perhaps a bitmap would be better? or we could steal a bit from some data member? + * XXXgpf: empty files are not allowed so nhashes == 0 symbolizes + * an empty bucket. perhaps a bitmap would be better? or we could + * steal a bit from some data member? */ emptyfh.nhashes = 0; emptyfh.file_id = 0; @@ -1253,7 +1276,8 @@ } static int -pefs_write_hash(int fdout, struct checksum *csp, uint32_t *hashes_offset, uint8_t hash_len) +pefs_write_hash(int fdout, struct checksum *csp, uint32_t *hashes_offset, + uint8_t hash_len) { int bytes; @@ -1271,14 +1295,15 @@ * All data member writes are done separately so as to avoid alignment problems. * Writes are always in little endian byte order. * - * First 16 bytes of .pefs.checksum are filled with .pefs.checksum's file header. - * Right after this header lies the 'index' part of our database. This index is later - * kept in kernel memory. + * First 16 bytes of .pefs.checksum are filled with .pefs.checksum's file + * header. Right after this header lies the 'index' part of our database. + * This index is later kept in kernel memory. * * Index: - * Both hash tables of cuckoo algorithm are written to the file sequentially. The - * first hash table corresponds to hash1() and the second hash table to hash2(). - * Each bucket (cell) of a hash table contains at most one entry(=file_header). + * Both hash tables of cuckoo algorithm are written to the file sequentially. + * The first hash table corresponds to hash1() and the second hash table to + * hash2(). Each bucket (cell) of a hash table contains at most one + * entry(=file_header). * The size of an entry is 16 bytes. * * hash table entries end at the following offset: @@ -1287,11 +1312,12 @@ * Checksums: * The last part of .pefs.checksum is filled with the actual checksums. * The offset where the first checksum starts is a 512 aligned address. - * Each hash table file header entry contains an offset that points to the beginning - * of a chain of checksums for that particular file's 4k blocks. + * Each hash table file header entry contains an offset that points to the + * beginning of a chain of checksums for that particular file's 4k blocks. */ static int -pefs_write_checksum_file(int fdout, struct checksum_file_header *cfhp, struct cuckoo_hash_table *chtp) +pefs_write_checksum_file(int fdout, struct checksum_file_header *cfhp, + struct cuckoo_hash_table *chtp) { struct bucket *bp; struct checksum *csp; @@ -1310,7 +1336,8 @@ hashes_offset = buckets_offset; hashes_offset+= chtp->size * PEFS_FH_SIZE * 2; if (hashes_offset % PEFS_HASH_BYTE_ALIGNMENT != 0) - hashes_offset+= PEFS_HASH_BYTE_ALIGNMENT - (hashes_offset % PEFS_HASH_BYTE_ALIGNMENT); + hashes_offset+= PEFS_HASH_BYTE_ALIGNMENT - (hashes_offset % + PEFS_HASH_BYTE_ALIGNMENT); for (i = 0; i < chtp->size; i++) { bp = &chtp->buckets1[i]; @@ -1323,7 +1350,8 @@ fhp = bp->fhp; if (fhp != NULL) { TAILQ_FOREACH(csp, &(fhp->checksums), checksum_entries) { - error = pefs_write_hash(fdout, csp, &hashes_offset, cfhp->hash_len); + error = pefs_write_hash(fdout, csp, &hashes_offset, + cfhp->hash_len); if (error != 0) return (error); } @@ -1341,7 +1369,8 @@ fhp = bp->fhp; if (fhp != NULL) { TAILQ_FOREACH(csp, &(fhp->checksums), checksum_entries) { - error = pefs_write_hash(fdout, csp, &hashes_offset, cfhp->hash_len); + error = pefs_write_hash(fdout, csp, &hashes_offset, + cfhp->hash_len); if (error != 0) return (error); } @@ -1352,8 +1381,8 @@ } static void -pefs_init_checksum_file_header(struct checksum_file_header *cfhp, const char *algo, - uint8_t hash_len, struct cuckoo_hash_table *chtp) +pefs_init_checksum_file_header(struct checksum_file_header *cfhp, + const char *algo, uint8_t hash_len, struct cuckoo_hash_table *chtp) { cfhp->hash_len = hash_len; cfhp->hash_table_size = chtp->size; @@ -1363,8 +1392,8 @@ /* * If .pefs.checksum is created inside pefs mounted fs, then it will obtain an - * encrypted filename & encrypted data, which is unacceptable. User should create - * checksum file outside of filesystem and then copy it by hand. + * encrypted filename & encrypted data, which is unacceptable. User should + * create checksum file outside of filesystem and then copy it by hand. */ static int pefs_open_checksum_file(int *fdp, char *fsroot, char *csm_path) @@ -1403,12 +1432,14 @@ } /* - * An in memory database is created from entries in fpin. This database is later written - * to file ".pefs.checksum" which is created under csm_path. algo is used as a cryptographic - * hash function that produces checksums for 4k blocks of each file. + * An in memory database is created from entries in fpin. This database is + * later written to file ".pefs.checksum" which is created under csm_path. + * algo is used as a cryptographic hash function that produces checksums + * for 4k blocks of each file. */ int -pefs_create_checksum_file(FILE *fpin, char *fsroot, char *csm_path, const char *algo) +pefs_create_checksum_file(FILE *fpin, char *fsroot, char *csm_path, + const char *algo) { struct cuckoo_hash_table checksum_hash_table; struct checksum_file_header cfh; @@ -1480,7 +1511,8 @@ return (PEFS_ERR_IO); } - bytes = read(fdin, &(cfhp->offset_to_hash_table), sizeof(cfhp->offset_to_hash_table)); + bytes = read(fdin, &(cfhp->offset_to_hash_table), + sizeof(cfhp->offset_to_hash_table)); if (bytes != sizeof(cfhp->offset_to_hash_table)) { warn("error reading from .pefs.checksum"); return (PEFS_ERR_IO); @@ -1494,14 +1526,17 @@ cfhp->hash_table_size = le32toh(hash_table_size); dprintf(("+++printing checksum file header info+++\n")); - dprintf(("version %X\nhash_len %d\nhash_algo %s\n", cfhp->version, cfhp->hash_len, cfhp->hash_algo)); - dprintf(("offset to hash table %d\nhash table size %d\n", cfhp->offset_to_hash_table, cfhp->hash_table_size)); + dprintf(("version %X\nhash_len %d\nhash_algo %s\n", + cfhp->version, cfhp->hash_len, cfhp->hash_algo)); + dprintf(("offset to hash table %d\nhash table size %d\n", + cfhp->offset_to_hash_table, cfhp->hash_table_size)); return (0); } static int -pefs_read_file_header(int fdin, struct file_header *fhp, uint32_t *buckets_offset) +pefs_read_file_header(int fdin, struct file_header *fhp, + uint32_t *buckets_offset) { uint64_t file_id; uint32_t nhashes, offset_to_checksums; @@ -1515,7 +1550,8 @@ fhp->nhashes = le32toh(nhashes); (*buckets_offset)+= sizeof(nhashes); - bytes = pread(fdin, &offset_to_checksums, sizeof(offset_to_checksums), *buckets_offset); + bytes = pread(fdin, &offset_to_checksums, sizeof(offset_to_checksums), + *buckets_offset); if (bytes != sizeof(offset_to_checksums)) { warn("error reading from .pefs.checksum"); return (PEFS_ERR_IO); @@ -1533,7 +1569,8 @@ //dprintf(("\nfile header offset = %d\n", *fh_offset)); //dprintf(("\n++priting file header info++\n")); - //dprintf(("nhashes %d\noffset_to_checksums %u\n", fhp->nhashes, fhp->offset_to_checksums)); + //dprintf(("nhashes %d\noffset_to_checksums %u\n", + //fhp->nhashes, fhp->offset_to_checksums)); //dprintf(("file id %llu\n", fhp->file_id)); return (0); @@ -1566,7 +1603,8 @@ } static int -pefs_read_hash(int fdin, struct checksum *csp, uint32_t *hashes_offset, uint8_t hash_len) +pefs_read_hash(int fdin, struct checksum *csp, uint32_t *hashes_offset, + uint8_t hash_len) { int bytes; @@ -1591,7 +1629,8 @@ /* Create in memory checksum database by reading .pefs.checksum file. */ static int -pefs_read_checksum_file(int fdin, struct checksum_file_header *cfhp, struct cuckoo_hash_table *chtp) +pefs_read_checksum_file(int fdin, struct checksum_file_header *cfhp, + struct cuckoo_hash_table *chtp) { struct bucket *bp; struct checksum *csp; @@ -1624,7 +1663,8 @@ return (PEFS_ERR_SYS); } - error = pefs_read_hash(fdin, csp, &hashes_offset, cfhp->hash_len); + error = pefs_read_hash(fdin, csp, &hashes_offset, + cfhp->hash_len); if (error != 0) return (error); @@ -1655,7 +1695,8 @@ return (PEFS_ERR_SYS); } - error = pefs_read_hash(fdin, csp, &hashes_offset, cfhp->hash_len); + error = pefs_read_hash(fdin, csp, &hashes_offset, + cfhp->hash_len); if (error != 0) return (error); @@ -1668,7 +1709,8 @@ } static int -pefs_compare_checksums(struct file_header *fhp, struct file_header *indexfhp, uint8_t hash_len) +pefs_compare_checksums(struct file_header *fhp, struct file_header *indexfhp, + uint8_t hash_len) { struct checksum *csp1, *csp2; uint32_t i; @@ -1678,7 +1720,8 @@ error = 0; if (fhp->nhashes != indexfhp->nhashes) { - pefs_warn("number of hashes differ between on disk file and %s values for file %s: %u vs %u", + pefs_warn("number of hashes differ between on disk file and %s values " + "for file %s: %u vs %u", PEFS_FILE_CHECKSUM, fhp->path, fhp->nhashes, indexfhp->nhashes); error = PEFS_ERR_CHECKSUM; } @@ -1689,7 +1732,8 @@ while (csp1 != NULL && csp2 != NULL) { cmp = memcmp(csp1->hash, csp2->hash, hash_len); if (cmp != 0) { - pefs_warn("checksum no: %u differs between on disk file and %s values for file %s", + pefs_warn("checksum no: %u differs between on disk file and %s " + "values for file %s", i, PEFS_FILE_CHECKSUM, fhp->path); error = PEFS_ERR_CHECKSUM; } @@ -1702,12 +1746,13 @@ } /* - * Traverse the entire filesystem and for every regular file or symbolic link, look it up in - * .pefs.checksum index and verify its checksums. + * Traverse the entire filesystem and for every regular file or symbolic link, + * look it up in .pefs.checksum index and verify its checksums. */ static int -pefs_traverse_fs(struct cuckoo_hash_table *chtp, const EVP_MD *md, uint8_t hash_len, DIR *dirp, - char *path, struct statfs *fsp, struct hardlink_head *hlc_headp, struct file_header_head *fh_headp, +pefs_traverse_fs(struct cuckoo_hash_table *chtp, const EVP_MD *md, + uint8_t hash_len, DIR *dirp, char *path, struct statfs *fsp, + struct hardlink_head *hlc_headp, struct file_header_head *fh_headp, int flags, int *checksum_error) { char tmpath[MAXPATHLEN]; @@ -1721,8 +1766,10 @@ sdp = readdir(dirp); if (sdp != NULL) { /* XXXgpf: [TODO] Need to pay special attention to these files */ - if (strcmp(sdp->d_name, "..") == 0 || strcmp(sdp->d_name, ".") == 0 || - strcmp(sdp->d_name, ".pefs.db") == 0 || strcmp(sdp->d_name, ".pefs.conf") == 0 || + if (strcmp(sdp->d_name, "..") == 0 || + strcmp(sdp->d_name, ".") == 0 || + strcmp(sdp->d_name, ".pefs.db") == 0 || + strcmp(sdp->d_name, ".pefs.conf") == 0 || strcmp(sdp->d_name, ".pefs.checksum") == 0) continue; @@ -1737,7 +1784,7 @@ return (PEFS_ERR_SYS); } error = pefs_traverse_fs(chtp, md, hash_len, dirtmp, tmpath, - fsp, hlc_headp, fh_headp, flags, checksum_error); + fsp, hlc_headp, fh_headp, flags, checksum_error); if (error != 0) { closedir(dirp); return (PEFS_ERR_SYS); @@ -1745,10 +1792,11 @@ break; /* * Look up the file and verify its checksums. - * Total number of checksums should be the same and checksums should match. + * Total number of checksums should be the same and checksums + * should match. * Also, take notice of hardlinks & symlink warnings. - * After the traversal is done, we must have found all of our entries in the - * checksum file. + * After the traversal is done, we must have found all of our + * entries in the checksum file. */ /* FALLTHROUGH */ case DT_REG: @@ -1847,7 +1895,8 @@ fhp = chtp->buckets1[i].fhp; if (fhp != NULL) if (fhp->found != 1) { - pefs_warn("file with file id %llu was not found in filesystem but exists in %s", + pefs_warn("file with file id %llu was not found in " + "filesystem but exists in %s", fhp->file_id, PEFS_FILE_CHECKSUM); error = PEFS_ERR_NOENT; } @@ -1857,7 +1906,8 @@ fhp = chtp->buckets2[i].fhp; if (fhp != NULL) if (fhp->found != 1) { - pefs_warn("file with file id %llu was not found in filesystem but exists in %s", + pefs_warn("file with file id %llu was not found in " + "filesystem but exists in %s", fhp->file_id, PEFS_FILE_CHECKSUM); error = PEFS_ERR_NOENT; } @@ -1924,7 +1974,8 @@ goto out; } - error = pefs_traverse_fs(&cht, md, hash_len, dirp, fsroot, &fs, &hlc_head, &fh_head, flags, &checksum_error); + error = pefs_traverse_fs(&cht, md, hash_len, dirp, fsroot, &fs, &hlc_head, + &fh_head, flags, &checksum_error); if (error != 0) goto out; Modified: soc2012/gpf/pefs_kmod/sbin/pefs/pefs_ctl.h ============================================================================== --- soc2012/gpf/pefs_kmod/sbin/pefs/pefs_ctl.h Tue Jul 10 17:32:52 2012 (r239244) +++ soc2012/gpf/pefs_kmod/sbin/pefs/pefs_ctl.h Tue Jul 10 18:20:20 2012 (r239245) @@ -98,10 +98,12 @@ int pefs_key_decrypt(struct pefs_xkeyenc *xe, const struct pefs_xkey *xk_parent); uintmax_t pefs_keyid_as_int(char *keyid); -int pefs_create_checksum_file(FILE *fpin, char *fsroot, char *csm_path, const char *algo); +int pefs_create_checksum_file(FILE *fpin, char *fsroot, char *csm_path, + const char *algo); int pefs_verify_checksum(int fdin, char *fsroot, int flags); -int pefs_name_pton(char const *src, size_t srclen, u_char *target, size_t targsize); +int pefs_name_pton(char const *src, size_t srclen, u_char *target, + size_t targsize); const char * pefs_alg_name(struct pefs_xkey *xk); void pefs_alg_list(FILE *stream); From owner-svn-soc-all@FreeBSD.ORG Tue Jul 10 19:04:52 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 651301065676 for ; Tue, 10 Jul 2012 19:04:50 +0000 (UTC) (envelope-from oleksandr@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Tue, 10 Jul 2012 19:04:50 +0000 Date: Tue, 10 Jul 2012 19:04:50 +0000 From: oleksandr@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120710190450.651301065676@hub.freebsd.org> Cc: Subject: socsvn commit: r239248 - soc2012/oleksandr/udf-head/sys/fs/udf2 X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Jul 2012 19:04:52 -0000 Author: oleksandr Date: Tue Jul 10 19:04:49 2012 New Revision: 239248 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239248 Log: Add determine maximum number of blocks, some comments, debug sections and clean code Modified: soc2012/oleksandr/udf-head/sys/fs/udf2/udf_subr.c soc2012/oleksandr/udf-head/sys/fs/udf2/udf_vnops.c Modified: soc2012/oleksandr/udf-head/sys/fs/udf2/udf_subr.c ============================================================================== --- soc2012/oleksandr/udf-head/sys/fs/udf2/udf_subr.c Tue Jul 10 18:57:05 2012 (r239247) +++ soc2012/oleksandr/udf-head/sys/fs/udf2/udf_subr.c Tue Jul 10 19:04:49 2012 (r239248) @@ -2412,6 +2412,7 @@ l_ea = le32toh(node->fe->l_ea); eahdr = (struct extattrhdr_desc *) node->fe->data; } else { + KASSERT(node->efe, ("Extended File Entry is null")); l_ea = le32toh(node->efe->l_ea); eahdr = (struct extattrhdr_desc *) node->efe->data; } @@ -2430,6 +2431,8 @@ if (error) return (EINVAL); + DPRINTF(EXTATTR, ("Found %d bytes of extended attributes\n", l_ea)); + /* looking for Ecma-167 attributes? */ offset = sizeof(struct extattrhdr_desc); @@ -2449,16 +2452,22 @@ if (l_ea + offset >= sector_size - sizeof(struct extattr_entry)) return (EINVAL); + DPRINTF(EXTATTR, ("Starting at offset %d\n", offset)); + /* find our extended attribute */ l_ea -= offset; pos = (uint8_t *) eahdr + offset; while (l_ea >= sizeof(struct extattr_entry)) { + DPRINTF(EXTATTR, ("%d extended attr bytes left\n", l_ea)); attrhdr = (struct extattr_entry *) pos; implext = (struct impl_extattr_entry *) pos; /* get complete attribute length and check for roque values */ a_l = le32toh(attrhdr->a_l); + DPRINTF(EXTATTR, ("attribute %d:%d, len %d/%d\n", + le32toh(attrhdr->type), + attrhdr->subtype, a_l, l_ea)); if ((a_l == 0) || (a_l > l_ea)) return (EINVAL); @@ -2479,6 +2488,7 @@ * we need to check */ + DPRINTF(EXTATTR, ("named attribute %s\n", implext->imp_id.id)); if (strcmp(implext->imp_id.id, sattrname) == 0) { /* we have found our appl/implementation attribute */ *offsetp = offset; @@ -4350,7 +4360,7 @@ icbftype = fe->icbtag.file_type; icbflags = le16toh(fe->icbtag.flags); } else { - /*assert(udf_node->efe); */ + KASSERT(udf_node->efe, ("Extended File Entry is null")); udf_perm = le32toh(efe->perm); icbftype = efe->icbtag.file_type; icbflags = le16toh(efe->icbtag.flags); Modified: soc2012/oleksandr/udf-head/sys/fs/udf2/udf_vnops.c ============================================================================== --- soc2012/oleksandr/udf-head/sys/fs/udf2/udf_vnops.c Tue Jul 10 18:57:05 2012 (r239247) +++ soc2012/oleksandr/udf-head/sys/fs/udf2/udf_vnops.c Tue Jul 10 19:04:49 2012 (r239248) @@ -100,6 +100,8 @@ int udf_getanode(struct mount *mp, struct vnode **vpp) { + DPRINTF(CALL, ("udf_getanode called\n")); + return (getnewvnode("udf2", mp, &udf_vnodeops, vpp)); } @@ -214,6 +216,8 @@ int on, n, lbn; int error = 0; + DPRINTF(READ, ("udf_read called\n")); + /* can this happen? some filingsystems have this check */ if (uio->uio_offset < 0) return (EINVAL); @@ -226,10 +230,14 @@ panic("udf_read: type %d", vp->v_type); #endif + KASSERT(udf_node, ("udf_read: udf_node is null")); + KASSERT(udf_noed->fe || udf_node->efe, ("udf_read: Extended File Entry or File Entry is null")); + /* get file/directory filesize */ if (udf_node->fe) file_size = le64toh(udf_node->fe->inf_len); else + KASSERT(udf_node->efe, ("Extended File Entry is null")); file_size = le64toh(udf_node->efe->inf_len); /* read contents using buffercache */ @@ -454,10 +462,19 @@ else *ap->a_bnp = lsector * (udf_node->ump->discinfo.sector_size/DEV_BSIZE); - /* set runlength of maximum block size */ - if (ap->a_runp) - *ap->a_runp = 0; - + /* + * Determine maximum number of readahead blocks following the + * requested block. + */ + if (ap->a_runp) { + if (maxblks <= 1) + *ap->a_runp = 0; + else if (maxblks - 1 >= MAXBSIZE) + *ap->a_runp = MAXBSIZE - 1; + else + *ap->a_runp = maxblks - 1; + + } if (ap->a_runb) *ap->a_runb = 0; @@ -487,7 +504,7 @@ panic("udf_strategy: spec"); /* only filebuffers ought to be read/write by this, no descriptors */ - /* assert(bp->b_blkno >= 0);*/ + KASSERT(bp->b_blkno >= 0, ("udf_strategy: nonexistent physical block number")); /* get sector size */ lb_size = udf_node->ump->discinfo.sector_size; @@ -497,14 +514,14 @@ /* calculate length to fetch/store in sectors */ sectors = bp->b_bcount / lb_size; - /* assert(bp->b_count > 0); */ + KASSERT(bp->b_bcount > 0, ("udf_strategy: no valid bytes in buffer")); /* NEVER assume later that this buffer is already translated */ /* bp->b_lblkno = bp->b_blkno; */ /* check assertions: we OUGHT to always get multiples of this */ - /* assert(sectors * lb_size == bp->b_bcount); */ - + KASSERT(sectors * lb_size == bp->b_bcount, ("udf_strategy: wrong length + to fetch/store in sectors")); if (bp->b_blkno == bp->b_lblkno) { /* get logical block and run */ error = udf_bmap_translate(udf_node, bp->b_lblkno, &lsector, &maxblks); @@ -515,6 +532,10 @@ } } if (bp->b_iocmd & BIO_READ) { + DPRINTF(STRATEGY, ("\tread vp %p buf %p (blk no %llu)" + ", sector %d for %d sectors\n", + vp, bp, bp->b_blkno, from, sectors)); + if (lsector == UDF_TRANS_ZERO) { /* copy sezo sector */ memset(bp->b_data, 0, lb_size); @@ -535,6 +556,10 @@ BO_STRATEGY(bo, bp); } } else { + DPRINTF(STRATEGY, ("\twrite vp %p buf %p (blk no %llu)" + ", sector %d for %d sectors\n", + vp, bp, bp->b_blkno, from, sectors)); + return (ENOTSUP); } return (bp->b_error); @@ -591,7 +616,11 @@ dirent = malloc(sizeof(struct dirent), M_UDFTEMP, M_WAITOK | M_ZERO); if (ap->a_ncookies != NULL) { - /* is this the max number possible? */ + /* + * Guess how many entries are needed. If we run out, this + * function will be called again and thing will pick up + * were it left off. + */ ncookies = uio->uio_resid / 8; cookies = malloc(sizeof(u_long) * ncookies, M_UDFTEMP, M_WAITOK | M_ZERO); @@ -643,8 +672,11 @@ diroffset = uio->uio_offset; transoffset = diroffset; while (diroffset < file_size) { + DPRINTF(READDIR, ("\tread in fid stream\n")); /* transfer a new fid/dirent */ error = udf_read_fid_stream(vp, &diroffset, fid); + DPRINTFIF(READDIR, error, ("read error in read fid " + "stream : %d\n", error)); if (error) { printf("Read error in read fid: %d\n", error); break; @@ -698,6 +730,8 @@ continue; /* copy dirent to the caller */ + DPRINTF(READDIR, ("\tread dirent `%s', type %d\n", + dirent->d_name, dirent->d_type)); if (cookiesp) { /* if (++acookies >= ncookies) @@ -732,6 +766,17 @@ //*ap->a_cookies = cookies; } } + +#ifdef DEBUG + if (udf_verbose & UDF_DEBUG_READDIR) { + printf("returning offset %d\n", (uint32_t) uio->uio_offset); + if (ap->a_eofflag) + printf("returning EOF ? %d\n", *ap->a_eofflag); + if (error) + printf("readdir returning error %d\n", error); + } +#endif + free(dirent, M_UDFTEMP); return (error); @@ -936,12 +981,13 @@ struct timestamp *atime, *mtime, *attrtime, *creatime; struct udf_mount *ump = udf_node->ump; uint64_t filesize, blkssize; + uint32_t nlink, offset, a_l; + uint8_t *filedata; + uid_t uid; gid_t gid; int error; - uid_t uid; - uint32_t nlink; - uint32_t offset, a_l; - uint8_t *filedata; + + DPRINTF(CALL, ("udf_getattr called\n")); /* update times before we returning values */ #if 0 @@ -973,6 +1019,7 @@ creatime = &ft_extattr->times[0]; } } else { + KASSERT(udf_node->efe, ("Extended File Entry is null")); nlink = le16toh(efe->link_cnt); uid = (uid_t)le32toh(efe->uid); gid = (gid_t)le32toh(efe->gid); @@ -1253,10 +1300,11 @@ /* struct udf_mount *ump = udf_node->ump; */ /* kauth_cred_t cred = ap->a_cred; */ struct vattr *vap = ap->a_vap; - int error; + int error = 0; + + DPRINTF(CALL, ("udf_setattr called\n")); /* Abort if any unsettable attribute is given. */ - error = 0; if (vap->va_type != VNON || vap->va_nlink != VNOVAL || vap->va_fsid != VNOVAL || @@ -1274,12 +1322,15 @@ vap->va_bytes != VNOVAL) error = EINVAL; + DPRINTF(ATTR, ("setattr changing:\n")); if (error == 0 && (vap->va_flags != VNOVAL)) { + DPRINTF(ATTR, ("\tchflags\n")); return (EROFS); /* error = udf_chflags(vp, vap->va_flags, cred); */ } if (error == 0 && (vap->va_size != VNOVAL)) { + DPRINTF(ATTR, ("\tchsize\n")); if (vap->va_type == VDIR) return (EISDIR); if (vap->va_type == VLNK || vap->va_type == VREG) @@ -1288,11 +1339,13 @@ } if (error == 0 && (vap->va_uid != VNOVAL || vap->va_gid != VNOVAL)) { + DPRINTF(ATTR, ("\tchown\n")); return (EROFS); /* error = udf_chown(vp, vap->va_uid, vap->va_gid, cred); */ } if (error == 0 && (vap->va_mode != (mode_t)VNOVAL)) { + DPRINTF(ATTR, ("\tchmod\n")); return (EROFS); /* error = udf_chmod(vp, vap->va_mode, cred); */ } @@ -1303,9 +1356,10 @@ (vap->va_mtime.tv_sec != VNOVAL && vap->va_mtime.tv_nsec != VNOVAL)) ) { + DPRINTF(ATTR, ("\tchimes\n")); return (EROFS); -/* error = udf_chtimes(vp, &vap->va_atime, &vap->va_mtime, */ -/* &vap->va_birthtime, vap->va_vaflags, cred); */ +/* error = udf_chtimes(vp, &vap->va_atime, &vap->va_mtime, + &vap->va_birthtime, vap->va_vaflags, cred); */ } /* VN_KNOTE(vp, NOTE_ATTRIB); */ @@ -1322,6 +1376,8 @@ { uint32_t bits; + DPRINTF(CALL, ("udf_pathconf called\n")); + switch (ap->a_name) { case _PC_LINK_MAX: *ap->a_retval = (1<<16)-1; /* 16 bits */ @@ -1347,10 +1403,7 @@ case _PC_FILESIZEBITS: /* 64 bit file offsets -> 2+floor(2log(2^64-1)) = 2 + 63 = 65 */ bits = 64; /* XXX ought to deliver 65 */ -#if 0 - if (udf_node) - bits = 64 * vp->v_mount->mnt_dev_bshift; -#endif + *ap->a_retval = bits; return (0); } @@ -1364,11 +1417,11 @@ static int udf_open(struct vop_open_args *ap) { - struct udf_node *udf_node; + struct udf_node *udf_node = VTOI(ap->a_vp); off_t file_size; /* int flags; */ - udf_node = VTOI(ap->a_vp); + DPRINTF(CALL, ("udf_open called\n")); /* * Files marked append-only must be opened for appending. @@ -1427,16 +1480,15 @@ static int udf_access(struct vop_access_args *ap) { - struct vnode *vp; - struct udf_node *udf_node; - accmode_t accmode; + struct vnode *vp = ap->a_vp; + struct udf_node *udf_node = VTOI(vp); + accmode_t accmode = ap->a_accmode; gid_t gid; mode_t mode; uid_t uid; + /* int flags = 0; */ - vp = ap->a_vp; - udf_node = VTOI(vp); - accmode = ap->a_accmode; + DPRINTF(CALL, ("udf_access called\n")); /* check if we are allowed to write */ switch (vp->v_type) { @@ -1448,7 +1500,7 @@ * filingsystem and bomb out if we're trying to write. */ if ((accmode & VWRITE) && (vp->v_mount->mnt_flag & MNT_RDONLY)) - return (EROFS); /* check that this works */ + return (EROFS); break; case VBLK: case VCHR: @@ -1466,8 +1518,7 @@ /* noone may write immutable files */ /* TODO: get chflags(2) flags from extened attribute. */ -#if 0 - flags = 0; +#if 0 if ((mode & VWRITE) && (flags & IMMUTABLE)) return (EPERM); #endif @@ -1796,14 +1847,14 @@ struct vnode *vp = ap->a_vp; struct uio *uio = ap->a_uio; struct pathcomp pathcomp; - struct udf_node *udf_node; + struct udf_node *udf_node = VTOI(vp); int pathlen, targetlen, namelen, mntonnamelen, len, l_ci, filelen; int first, error; char *mntonname; uint8_t *pathbuf, *targetbuf, *tmpname; uint8_t *pathpos, *targetpos; - udf_node = VTOI(vp); + DPRINTF(CALL, ("udf_readlink called\n")); if (udf_node->efe) filelen = le64toh(udf_node->efe->inf_len); @@ -2407,9 +2458,13 @@ } #endif +/* + * File specific ioctls. + */ static int udf_ioctl(struct vop_ioctl_args *ap) { + printf("%s called\n", __func__); return (ENOTTY); } From owner-svn-soc-all@FreeBSD.ORG Tue Jul 10 19:21:11 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 0A6331065673 for ; Tue, 10 Jul 2012 19:21:09 +0000 (UTC) (envelope-from jhagewood@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Tue, 10 Jul 2012 19:21:09 +0000 Date: Tue, 10 Jul 2012 19:21:09 +0000 From: jhagewood@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120710192109.0A6331065673@hub.freebsd.org> Cc: Subject: socsvn commit: r239249 - in soc2012/jhagewood/sdiff: . sdiff X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Jul 2012 19:21:11 -0000 Author: jhagewood Date: Tue Jul 10 19:21:07 2012 New Revision: 239249 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239249 Log: Modified: soc2012/jhagewood/sdiff/hagewood-sdiff.patch soc2012/jhagewood/sdiff/sdiff/sdiff.c Modified: soc2012/jhagewood/sdiff/hagewood-sdiff.patch ============================================================================== --- soc2012/jhagewood/sdiff/hagewood-sdiff.patch Tue Jul 10 19:04:49 2012 (r239248) +++ soc2012/jhagewood/sdiff/hagewood-sdiff.patch Tue Jul 10 19:21:07 2012 (r239249) @@ -112,7 +112,7 @@ + diff -rupN jhagewood/sdiff/sdiff-orig/sdiff.c jhagewood/sdiff/sdiff/sdiff.c --- jhagewood/sdiff/sdiff-orig/sdiff.c 2012-07-07 19:37:22.000000000 -0400 -+++ jhagewood/sdiff/sdiff/sdiff.c 2012-07-09 20:09:56.000000000 -0400 ++++ jhagewood/sdiff/sdiff/sdiff.c 2012-07-10 19:20:43.000000000 -0400 @@ -5,6 +5,14 @@ * Public domain. */ @@ -166,7 +166,12 @@ /* pid from the diff parent (if applicable) */ DIFF_PID, -@@ -113,7 +121,7 @@ static struct option longopts[] = { +@@ -109,17 +117,17 @@ enum { + }; + + static struct option longopts[] = { +- /* options only processed in sdiff */ ++ /* options only processed in sdiff */ { "left-column", no_argument, NULL, LEFTC_OPT }, { "suppress-common-lines", no_argument, NULL, 's' }, { "width", required_argument, NULL, 'w' }, @@ -175,6 +180,13 @@ { "output", required_argument, NULL, 'o' }, { "diff-program", required_argument, NULL, DIFFPROG_OPT }, + { "pipe-fd", required_argument, NULL, PIPE_FD }, + { "diff-pid", required_argument, NULL, DIFF_PID }, +- ++ /* Options processed by diff. */ + { "ignore-file-name-case", no_argument, NULL, FCASE_IGNORE_OPT }, + { "no-ignore-file-name-case", no_argument, NULL, FCASE_SENSITIVE_OPT }, + { "strip-trailing-cr", no_argument, NULL, STRIPCR_OPT }, @@ -134,9 +142,35 @@ static struct option longopts[] = { { "ignore-case", no_argument, NULL, 'i' }, { "expand-tabs", no_argument, NULL, 't' }, Modified: soc2012/jhagewood/sdiff/sdiff/sdiff.c ============================================================================== --- soc2012/jhagewood/sdiff/sdiff/sdiff.c Tue Jul 10 19:04:49 2012 (r239248) +++ soc2012/jhagewood/sdiff/sdiff/sdiff.c Tue Jul 10 19:21:07 2012 (r239249) @@ -117,7 +117,7 @@ }; static struct option longopts[] = { - /* options only processed in sdiff */ + /* options only processed in sdiff */ { "left-column", no_argument, NULL, LEFTC_OPT }, { "suppress-common-lines", no_argument, NULL, 's' }, { "width", required_argument, NULL, 'w' }, @@ -127,7 +127,7 @@ { "pipe-fd", required_argument, NULL, PIPE_FD }, { "diff-pid", required_argument, NULL, DIFF_PID }, - + /* Options processed by diff. */ { "ignore-file-name-case", no_argument, NULL, FCASE_IGNORE_OPT }, { "no-ignore-file-name-case", no_argument, NULL, FCASE_SENSITIVE_OPT }, { "strip-trailing-cr", no_argument, NULL, STRIPCR_OPT }, From owner-svn-soc-all@FreeBSD.ORG Tue Jul 10 19:38:30 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 24356106564A for ; Tue, 10 Jul 2012 19:38:28 +0000 (UTC) (envelope-from jhagewood@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Tue, 10 Jul 2012 19:38:28 +0000 Date: Tue, 10 Jul 2012 19:38:28 +0000 From: jhagewood@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120710193828.24356106564A@hub.freebsd.org> Cc: Subject: socsvn commit: r239250 - in soc2012/jhagewood/sdiff: . sdiff X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Jul 2012 19:38:30 -0000 Author: jhagewood Date: Tue Jul 10 19:38:27 2012 New Revision: 239250 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239250 Log: Modified: soc2012/jhagewood/sdiff/hagewood-sdiff.patch soc2012/jhagewood/sdiff/sdiff/sdiff.c Modified: soc2012/jhagewood/sdiff/hagewood-sdiff.patch ============================================================================== --- soc2012/jhagewood/sdiff/hagewood-sdiff.patch Tue Jul 10 19:21:07 2012 (r239249) +++ soc2012/jhagewood/sdiff/hagewood-sdiff.patch Tue Jul 10 19:38:27 2012 (r239250) @@ -112,7 +112,7 @@ + diff -rupN jhagewood/sdiff/sdiff-orig/sdiff.c jhagewood/sdiff/sdiff/sdiff.c --- jhagewood/sdiff/sdiff-orig/sdiff.c 2012-07-07 19:37:22.000000000 -0400 -+++ jhagewood/sdiff/sdiff/sdiff.c 2012-07-10 19:20:43.000000000 -0400 ++++ jhagewood/sdiff/sdiff/sdiff.c 2012-07-10 19:38:25.000000000 -0400 @@ -5,6 +5,14 @@ * Public domain. */ @@ -264,7 +264,7 @@ case DIFFPROG_OPT: diffargv[0] = diffprog = optarg; break; -@@ -289,26 +324,23 @@ main(int argc, char **argv) +@@ -289,32 +324,27 @@ main(int argc, char **argv) if (errstr) errx(2, "width is %s: %s", errstr, optarg); break; @@ -294,9 +294,17 @@ - + /* no single switches were used */ - if( strcmp( diffargv[1], "-" ) == 0 ) - { -@@ -362,19 +394,19 @@ main(int argc, char **argv) +- if( strcmp( diffargv[1], "-" ) == 0 ) +- { ++ if (strcmp(diffargv[1], "-") == 0 ) { + int i; +- for(i=1; ileft); + free(diffp->right); + free(diffp); +@@ -1103,24 +1125,23 @@ printd(FILE *file1, size_t file1end) static void int_usage(void) { @@ -403,6 +419,7 @@ - "r | 2:\tchoose right diff\n" - "s:\tsilent mode--don't print identical lines\n" - "v:\tverbose mode--print identical lines\n" ++ + printf("%s", "e:\tedit blank diff\n", + "eb:\tedit both diffs concatenated\n", + "el:\tedit left diff\n", Modified: soc2012/jhagewood/sdiff/sdiff/sdiff.c ============================================================================== --- soc2012/jhagewood/sdiff/sdiff/sdiff.c Tue Jul 10 19:21:07 2012 (r239249) +++ soc2012/jhagewood/sdiff/sdiff/sdiff.c Tue Jul 10 19:38:27 2012 (r239250) @@ -342,11 +342,9 @@ } /* no single switches were used */ - if( strcmp( diffargv[1], "-" ) == 0 ) - { + if (strcmp(diffargv[1], "-") == 0 ) { int i; - for(i=1; ileft); free(diffp->right); free(diffp); @@ -1127,6 +1125,7 @@ static void int_usage(void) { + printf("%s", "e:\tedit blank diff\n", "eb:\tedit both diffs concatenated\n", "el:\tedit left diff\n", From owner-svn-soc-all@FreeBSD.ORG Tue Jul 10 21:27:18 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 71048106564A for ; Tue, 10 Jul 2012 21:27:16 +0000 (UTC) (envelope-from gmiller@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Tue, 10 Jul 2012 21:27:16 +0000 Date: Tue, 10 Jul 2012 21:27:16 +0000 From: gmiller@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120710212716.71048106564A@hub.freebsd.org> Cc: Subject: socsvn commit: r239256 - in soc2012/gmiller/locking-head: . include lib/libthr/thread lib/libwitness tools/regression/lib/libthr/lockprof X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Jul 2012 21:27:18 -0000 Author: gmiller Date: Tue Jul 10 21:27:15 2012 New Revision: 239256 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239256 Log: r239219@FreeBSD-dev: root | 2012-07-03 15:50:08 -0500 Begin implementation of LoR logging in libwitness. Rename lock profiling statistics *_np() functions for more consistent naming scheme: pthread_getstatistics_begin_np() -> pthread_statistics_begin_np() pthread_getstatistics_next_np() -> pthread_statistics_next_np() pthread_getstatistics_end_np() -> pthread_statistics_end_np() pthread_resetstatistics_np() -> pthread_statistics_reset_np() pthread_lockprof_enable_np() -> pthread_statistics_enable_np() pthread_lockprof_disable_np() -> pthread_statistics_disable_np() Added: soc2012/gmiller/locking-head/lib/libwitness/logs.c Modified: soc2012/gmiller/locking-head/ (props changed) soc2012/gmiller/locking-head/include/pthread_np.h soc2012/gmiller/locking-head/lib/libthr/thread/thr_profile.c soc2012/gmiller/locking-head/lib/libwitness/Makefile soc2012/gmiller/locking-head/lib/libwitness/lists.c soc2012/gmiller/locking-head/lib/libwitness/witness.h soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/lock-cycle.c Modified: soc2012/gmiller/locking-head/include/pthread_np.h ============================================================================== --- soc2012/gmiller/locking-head/include/pthread_np.h Tue Jul 10 20:59:35 2012 (r239255) +++ soc2012/gmiller/locking-head/include/pthread_np.h Tue Jul 10 21:27:15 2012 (r239256) @@ -37,6 +37,32 @@ /* * Non-POSIX type definitions: */ + +#ifdef LOCK_PROFILING + +#include + +struct _pthread_statistics_private; + +struct pthread_statistics_np { + struct _pthread_statistics_private *_pvt; + const char *file; + int line; + struct timespec wait_max; + struct timespec hold_max; + uintmax_t contest_count; + struct timespec wait_time; + struct timespec hold_time; + int acq_count; +}; + +#endif + +struct pthread_lock_order_np { + void *lock_first; + void *lock_second; +}; + typedef void (*pthread_switch_routine_t)(pthread_t, pthread_t); /* @@ -68,31 +94,19 @@ int pthread_switch_add_np(pthread_switch_routine_t); int pthread_switch_delete_np(pthread_switch_routine_t); int pthread_timedjoin_np(pthread_t, void **, const struct timespec *); +void pthread_lor_begin_np(struct pthread_lock_order_np *); +int pthread_lor_next_np(struct pthread_lock_order_np *); +void pthread_lor_end_np(struct pthread_lock_order_np *); +void pthread_lor_clear_np(void); #ifdef LOCK_PROFILING -#include - -struct _pthread_statistics_private; - -struct pthread_statistics_np { - struct _pthread_statistics_private *_pvt; - const char *file; - int line; - struct timespec wait_max; - struct timespec hold_max; - uintmax_t contest_count; - struct timespec wait_time; - struct timespec hold_time; - int acq_count; -}; - -void pthread_getstatistics_begin_np(struct pthread_statistics_np *); -int pthread_getstatistics_next_np(struct pthread_statistics_np *); -void pthread_getstatistics_end_np(struct pthread_statistics_np *); -void pthread_resetstatistics_np(void); -void pthread_lockprof_enable_np(void); -void pthread_lockprof_disable_np(void); +void pthread_statistics_begin_np(struct pthread_statistics_np *); +int pthread_statistics_next_np(struct pthread_statistics_np *); +void pthread_statistics_end_np(struct pthread_statistics_np *); +void pthread_statistics_reset_np(void); +void pthread_statistics_enable_np(void); +void pthread_statistics_disable_np(void); #endif Modified: soc2012/gmiller/locking-head/lib/libthr/thread/thr_profile.c ============================================================================== --- soc2012/gmiller/locking-head/lib/libthr/thread/thr_profile.c Tue Jul 10 20:59:35 2012 (r239255) +++ soc2012/gmiller/locking-head/lib/libthr/thread/thr_profile.c Tue Jul 10 21:27:15 2012 (r239256) @@ -284,7 +284,7 @@ } void -pthread_getstatistics_begin_np(struct pthread_statistics_np *stats) +pthread_statistics_begin_np(struct pthread_statistics_np *stats) { stats->_pvt = malloc(sizeof(struct _pthread_statistics_private)); stats->_pvt->hash = 0; @@ -292,13 +292,13 @@ } int -pthread_getstatistics_next_np(struct pthread_statistics_np *stats) +pthread_statistics_next_np(struct pthread_statistics_np *stats) { return (find_next_record(stats)); } void -pthread_getstatistics_end_np(struct pthread_statistics_np *stats) +pthread_statistics_end_np(struct pthread_statistics_np *stats) { if (stats->_pvt != NULL) { free(stats->_pvt); @@ -307,7 +307,7 @@ } void -pthread_resetstatistics_np() +pthread_statistics_reset_np() { struct pthread *curthread = _get_curthread(); u_int hash; @@ -334,13 +334,13 @@ } void -pthread_lockprof_enable_np() +pthread_statistics_enable_np() { lockprof_enabled = 1; } void -pthread_lockprof_disable_np() +pthread_statistics_disable_np() { lockprof_enabled = 0; } Modified: soc2012/gmiller/locking-head/lib/libwitness/Makefile ============================================================================== --- soc2012/gmiller/locking-head/lib/libwitness/Makefile Tue Jul 10 20:59:35 2012 (r239255) +++ soc2012/gmiller/locking-head/lib/libwitness/Makefile Tue Jul 10 21:27:15 2012 (r239256) @@ -4,7 +4,7 @@ LIB= witness SHLIB_MAJOR= 1 -SRCS= wrappers.c graph.c lists.c +SRCS= wrappers.c graph.c lists.c logs.c DPADD= ${LIBTHR} LDADD= -lthr Modified: soc2012/gmiller/locking-head/lib/libwitness/lists.c ============================================================================== --- soc2012/gmiller/locking-head/lib/libwitness/lists.c Tue Jul 10 20:59:35 2012 (r239255) +++ soc2012/gmiller/locking-head/lib/libwitness/lists.c Tue Jul 10 21:27:15 2012 (r239256) @@ -57,7 +57,7 @@ SLIST_INSERT_HEAD(&lock_head, entry, lock_next); if (next != NULL && insert_lock(entry, next) < 0) { - puts("LoR detected."); + log_reversal(entry, next); } printf("inserted lock %p\n", lock); Added: soc2012/gmiller/locking-head/lib/libwitness/logs.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/gmiller/locking-head/lib/libwitness/logs.c Tue Jul 10 21:27:15 2012 (r239256) @@ -0,0 +1,39 @@ +/*- + * Copyright (c) 2012 Greg Miller .. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + */ + +#include "witness.h" + +void +log_reversal(void *lock, void *previous) +{ + struct pthread_lock_order_np *entry; + + entry = malloc(sizeof(struct pthread_lock_order_np)); + entry->lock_first = previous; + entry->lock_second = lock; +} + Modified: soc2012/gmiller/locking-head/lib/libwitness/witness.h ============================================================================== --- soc2012/gmiller/locking-head/lib/libwitness/witness.h Tue Jul 10 20:59:35 2012 (r239255) +++ soc2012/gmiller/locking-head/lib/libwitness/witness.h Tue Jul 10 21:27:15 2012 (r239256) @@ -28,6 +28,7 @@ #include #include +#include #include #include @@ -48,3 +49,5 @@ void remove_lock(void *lock); int insert_lock(void *new_lock, void *previous); + +void log_reversal(void *lock, void *previous); Modified: soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/lock-cycle.c ============================================================================== --- soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/lock-cycle.c Tue Jul 10 20:59:35 2012 (r239255) +++ soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/lock-cycle.c Tue Jul 10 21:27:15 2012 (r239256) @@ -49,7 +49,7 @@ void reset_stats() { - pthread_resetstatistics_np(); + pthread_statistics_reset_np(); } void * @@ -72,7 +72,7 @@ pthread_t thread1; pthread_t thread2; - pthread_resetstatistics_np(); + pthread_statistics_reset_np(); pthread_create(&thread1, NULL, conflict_thread_func, NULL); pthread_create(&thread2, NULL, conflict_thread_func, NULL); @@ -122,17 +122,17 @@ struct pthread_statistics_np stats; long tm; - pthread_getstatistics_begin_np(&stats); - while (pthread_getstatistics_next_np(&stats)) { + pthread_statistics_begin_np(&stats); + while (pthread_statistics_next_np(&stats)) { record_count++; } - pthread_getstatistics_end_np(&stats); + pthread_statistics_end_np(&stats); check(record_count == 1); - pthread_getstatistics_begin_np(&stats); - pthread_getstatistics_next_np(&stats); - pthread_getstatistics_end_np(&stats); + pthread_statistics_begin_np(&stats); + pthread_statistics_next_np(&stats); + pthread_statistics_end_np(&stats); check(strcmp(stats.file, "lock-cycle.c") == 0); check(stats.line == 16); @@ -160,17 +160,17 @@ struct pthread_statistics_np stats; long tm; - pthread_getstatistics_begin_np(&stats); - while (pthread_getstatistics_next_np(&stats)) { + pthread_statistics_begin_np(&stats); + while (pthread_statistics_next_np(&stats)) { record_count++; } - pthread_getstatistics_end_np(&stats); + pthread_statistics_end_np(&stats); check(record_count == 1); - pthread_getstatistics_begin_np(&stats); - pthread_getstatistics_next_np(&stats); - pthread_getstatistics_end_np(&stats); + pthread_statistics_begin_np(&stats); + pthread_statistics_next_np(&stats); + pthread_statistics_end_np(&stats); check(strcmp(stats.file, "lock-cycle.c") == 0); check(stats.line == 16); @@ -193,11 +193,11 @@ int record_count = 0; struct pthread_statistics_np stats; - pthread_getstatistics_begin_np(&stats); - while (pthread_getstatistics_next_np(&stats)) { + pthread_statistics_begin_np(&stats); + while (pthread_statistics_next_np(&stats)) { record_count++; } - pthread_getstatistics_end_np(&stats); + pthread_statistics_end_np(&stats); check(record_count == 0); } @@ -209,17 +209,17 @@ struct pthread_statistics_np stats; long tm; - pthread_getstatistics_begin_np(&stats); - while (pthread_getstatistics_next_np(&stats)) { + pthread_statistics_begin_np(&stats); + while (pthread_statistics_next_np(&stats)) { record_count++; } - pthread_getstatistics_end_np(&stats); + pthread_statistics_end_np(&stats); check(record_count == 1); - pthread_getstatistics_begin_np(&stats); - pthread_getstatistics_next_np(&stats); - pthread_getstatistics_end_np(&stats); + pthread_statistics_begin_np(&stats); + pthread_statistics_next_np(&stats); + pthread_statistics_end_np(&stats); check(stats.contest_count == 1); From owner-svn-soc-all@FreeBSD.ORG Wed Jul 11 03:21:23 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 3EC891065670 for ; Wed, 11 Jul 2012 03:21:21 +0000 (UTC) (envelope-from syuu@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Wed, 11 Jul 2012 03:21:21 +0000 Date: Wed, 11 Jul 2012 03:21:21 +0000 From: syuu@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120711032121.3EC891065670@hub.freebsd.org> Cc: Subject: socsvn commit: r239263 - soc2012/syuu/bhyve-bios/usr.sbin/bhyve X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Jul 2012 03:21:23 -0000 Author: syuu Date: Wed Jul 11 03:21:20 2012 New Revision: 239263 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239263 Log: add bios_int16 Added: soc2012/syuu/bhyve-bios/usr.sbin/bhyve/bios_int16.c Modified: soc2012/syuu/bhyve-bios/usr.sbin/bhyve/Makefile soc2012/syuu/bhyve-bios/usr.sbin/bhyve/bios_int13.c soc2012/syuu/bhyve-bios/usr.sbin/bhyve/bios_int18.c soc2012/syuu/bhyve-bios/usr.sbin/bhyve/pci_virtio_block.c Modified: soc2012/syuu/bhyve-bios/usr.sbin/bhyve/Makefile ============================================================================== --- soc2012/syuu/bhyve-bios/usr.sbin/bhyve/Makefile Wed Jul 11 02:57:32 2012 (r239262) +++ soc2012/syuu/bhyve-bios/usr.sbin/bhyve/Makefile Wed Jul 11 03:21:20 2012 (r239263) @@ -8,7 +8,7 @@ SRCS+= instruction_emul.c mevent.c SRCS+= pci_emul.c pci_hostbridge.c pci_passthru.c pci_virtio_block.c SRCS+= pci_virtio_net.c pci_uart.c pit_8254.c post.c rtc.c uart.c xmsr.c -SRCS+= bios_call.c bios_int10.c bios_int13.c bios_int18.c +SRCS+= bios_call.c bios_int10.c bios_int13.c bios_int16.c bios_int18.c NO_MAN= Modified: soc2012/syuu/bhyve-bios/usr.sbin/bhyve/bios_int13.c ============================================================================== --- soc2012/syuu/bhyve-bios/usr.sbin/bhyve/bios_int13.c Wed Jul 11 02:57:32 2012 (r239262) +++ soc2012/syuu/bhyve-bios/usr.sbin/bhyve/bios_int13.c Wed Jul 11 03:21:20 2012 (r239263) @@ -36,22 +36,23 @@ #include #include #include +#include #include #include #include "bios_call.h" +#include "fbsdrun.h" -#define MAKEPTR(s, o) (((s) << 4) + (o)) - -extern int block_drive_c_fd; +/* XXX */ +#define SECTOR_SIZE 512 static int int13_handler(struct vmctx *ctx, int vcpu, int intno) { - uint64_t rax, rbx, rcx, rdx, es_base, rflags; - uint32_t es_limit, es_access; - uint16_t bx; + uint64_t rax, rbx, rcx, rdx, rsi, rflags, es_base, es_select, ds_base, ds_select; + uint32_t es_limit, es_access, ds_limit, ds_access; + uint16_t bx, ds16, es16, si; uint8_t al, ah, cl, ch, dl, dh; int error; @@ -67,29 +68,162 @@ if ((error = vm_get_register(ctx, vcpu, VM_REG_GUEST_RDX, &rdx)) != 0) goto done; + if ((error = vm_get_register(ctx, vcpu, VM_REG_GUEST_RSI, &rsi)) != 0) + goto done; + if ((error = vm_get_register(ctx, vcpu, VM_REG_GUEST_RFLAGS, &rflags)) != 0) goto done; + if ((error = vm_get_register(ctx, vcpu, VM_REG_GUEST_ES, &es_select)) != 0) + goto done; + + if ((error = vm_get_register(ctx, vcpu, VM_REG_GUEST_DS, &ds_select)) != 0) + goto done; + if ((error = vm_get_desc(ctx, vcpu, VM_REG_GUEST_ES, &es_base, &es_limit, &es_access)) != 0) goto done; + if ((error = vm_get_desc(ctx, vcpu, VM_REG_GUEST_DS, &ds_base, + &ds_limit, &ds_access)) != 0) + goto done; + al = (uint8_t)rax; ah = (uint8_t)(rax >> 8); bx = (uint16_t)rbx; cl = (uint8_t)rcx; ch = (uint8_t)(rcx >> 8); + dl = (uint8_t)rdx; + dh = (uint8_t)(rdx >> 8); + es16 = (uint16_t)es_base; + ds16 = (uint16_t)ds_base; + si = (uint16_t)rsi; - printf("%s rax=%lx ah=%x al=%x rbx=%lx bx=%x rcx=%lx ch=%x cl=%x rdx=%lx dh=%x dl=%x es_base=%lx es_limit=%x es_access=%x\n", - __func__, rax, ah, al, rbx, bx, rcx, ch, cl, rdx, dh, dl, es_base, es_limit, es_access); - + printf("int:13h ah:%xh", ah); switch (ah) { + case 0x00: + rflags &= ~0x1; + error = vm_set_register(ctx, vcpu, VM_REG_GUEST_RFLAGS, rflags); + printf(" rflags=%lx\n", rflags); + break; case 0x02: + { + unsigned int pos; + ssize_t siz; + int fd; + + /* XXX: pass fd from somewhere else */ + fd = open("diskdev", O_RDWR); + if (fd < 0) { + perror("open "); + goto fail02; + } + + /* cylinder */ + pos = ch * 2 * 18 * SECTOR_SIZE; + /* head */ + pos += dh * 18 * SECTOR_SIZE; + /* sector */ + pos += (cl - 1) * SECTOR_SIZE; + + printf(" cylinder=%x head=%x sector=%x addr=%x:%x count=%x\n", + ch, dh, cl, es16, bx, al); + siz = pread(fd, + paddr_guest2host((es16 << 4) + bx), + al * SECTOR_SIZE, pos); + if (siz < 0) { + perror("read "); + error = -1; + close(fd); + goto fail02; + } + rflags &= ~0x1; + error = vm_set_register(ctx, vcpu, VM_REG_GUEST_RFLAGS, rflags); + close(fd); + break; +fail02: + rflags |= 0x1; + vm_set_register(ctx, vcpu, VM_REG_GUEST_RFLAGS, rflags); + break; + } + case 0x08: + printf(" dl=%x rflags=%lx\n", dl, rflags); + if (dl == 0x80) { + if ((error = vm_set_register(ctx, vcpu, VM_REG_GUEST_RAX, 0)) != 0) + break; + if ((error = vm_set_register(ctx, vcpu, VM_REG_GUEST_RBX, 0x02)) != 0) + break; + if ((error = vm_set_register(ctx, vcpu, VM_REG_GUEST_RCX, 0xFFFF)) != 0) + break; + if ((error = vm_set_register(ctx, vcpu, VM_REG_GUEST_RDX, 0x0101)) != 0) + break; + + rflags &= ~0x1; + }else{ + rflags |= 0x1; + } + error = vm_set_register(ctx, vcpu, VM_REG_GUEST_RFLAGS, rflags); break; case 0x41: + printf(" bx=%x cx=%x rflags=%lx\n", bx, (uint32_t)rcx, rflags); + if (bx == 0x55aa) { + if ((error = vm_set_register(ctx, vcpu, VM_REG_GUEST_RBX, 0xaa55)) != 0) + break; + if ((error = vm_set_register(ctx, vcpu, VM_REG_GUEST_RCX, cl | 0x01)) != 0) + break; + rflags &= ~0x1; + error = vm_set_register(ctx, vcpu, VM_REG_GUEST_RFLAGS, rflags); + break; + } rflags |= 0x1; error = vm_set_register(ctx, vcpu, VM_REG_GUEST_RFLAGS, rflags); break; + case 0x42: + { + ssize_t siz; + int fd; + char *dap; + uint16_t sector, segment, offset; + uint64_t count; + + /* XXX: pass fd from somewhere else */ + fd = open("diskdev", O_RDWR); + if (fd < 0) { + perror("open "); + goto fail42; + } + + dap = (char *)paddr_guest2host((ds16 << 4) + si); + sector = *(uint16_t *)(dap + 0x02); + offset = *(uint16_t *)(dap + 0x04); + segment = *(uint16_t *)(dap + 0x06); + count = *(uint64_t *)(dap + 0x08); + + printf(" dap=%x:%x sector=%x dest=%x:%x count=%lx\n", + ds16, si, sector, segment, offset, count); + + siz = pread(fd, + paddr_guest2host((segment << 4) + offset), + count * SECTOR_SIZE, sector * SECTOR_SIZE); + if (siz < 0) { + perror("read "); + error = siz; + close(fd); + goto fail42; + } + if ((error = vm_set_register(ctx, vcpu, VM_REG_GUEST_RAX, al)) != 0) + goto fail42; + + rflags &= ~0x1; + error = vm_set_register(ctx, vcpu, VM_REG_GUEST_RFLAGS, rflags); + close(fd); + break; +fail42: + rflags |= 0x1; + vm_set_register(ctx, vcpu, VM_REG_GUEST_RFLAGS, rflags); + break; + } + default: fprintf(stderr, "Not implemented BIOS call int=%x ah=%x\n", intno, ah); Added: soc2012/syuu/bhyve-bios/usr.sbin/bhyve/bios_int16.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/syuu/bhyve-bios/usr.sbin/bhyve/bios_int16.c Wed Jul 11 03:21:20 2012 (r239263) @@ -0,0 +1,103 @@ +/*- + * Copyright (c) 2011 NetApp, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY NETAPP, INC ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL NETAPP, INC OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#include +__FBSDID("$FreeBSD$"); + +#include + +#include +#include +#include +#include +#include + +#include +#include + +#include "consport.h" +#include "bios_call.h" + +static int +int16_handler(struct vmctx *ctx, int vcpu, int intno) +{ + uint64_t rax, rflags; + uint8_t al, ah; + int error; + + if (!console_opened) { + ttyopen(); + console_opened = 1; + } + + if ((error = vm_get_register(ctx, vcpu, VM_REG_GUEST_RAX, &rax)) != 0) + goto done; + + if ((error = vm_get_register(ctx, vcpu, VM_REG_GUEST_RFLAGS, &rflags)) != 0) + goto done; + + + al = (uint8_t)rax; + ah = (uint8_t)(rax >> 8); + + switch (ah) { + case 0x00: + { + int c; + while((c = ttyread()) == -1) + ; + + error = vm_set_register(ctx, vcpu, VM_REG_GUEST_RAX, c & 0xff); + break; + } + case 0x01: + { + int c = ttyread(); + if (c == -1) { + rflags |= 0x40; + } else { + rflags &= ~0x40; + if ((error = vm_set_register(ctx, vcpu, VM_REG_GUEST_RAX, c & 0xff)) != 0) + goto done; + } + + error = vm_set_register(ctx, vcpu, VM_REG_GUEST_RFLAGS, rflags); + + break; + } + + default: + fprintf(stderr, "Not implemented BIOS call int=%x ah=%x\n", + intno, ah); + } + +done: + return (error); + +} +BIOS_CALL(int16, 0x16, int16_handler); Modified: soc2012/syuu/bhyve-bios/usr.sbin/bhyve/bios_int18.c ============================================================================== --- soc2012/syuu/bhyve-bios/usr.sbin/bhyve/bios_int18.c Wed Jul 11 02:57:32 2012 (r239262) +++ soc2012/syuu/bhyve-bios/usr.sbin/bhyve/bios_int18.c Wed Jul 11 03:21:20 2012 (r239263) @@ -29,11 +29,13 @@ #include __FBSDID("$FreeBSD$"); +#include #include "bios_call.h" static int int18_handler(struct vmctx *ctx, int vcpu, int intno) { + printf("int18\n"); return (0); } BIOS_CALL(int18, 0x18, int18_handler); Modified: soc2012/syuu/bhyve-bios/usr.sbin/bhyve/pci_virtio_block.c ============================================================================== --- soc2012/syuu/bhyve-bios/usr.sbin/bhyve/pci_virtio_block.c Wed Jul 11 02:57:32 2012 (r239262) +++ soc2012/syuu/bhyve-bios/usr.sbin/bhyve/pci_virtio_block.c Wed Jul 11 03:21:20 2012 (r239263) @@ -136,8 +136,6 @@ struct vtblk_config vbsc_cfg; }; -int block_drive_c_fd = -1; - /* * Return the number of available descriptors in the vring taking care * of the 16-bit index wraparound. @@ -362,10 +360,6 @@ return (1); } - if (block_drive_c_fd == -1) { - block_drive_c_fd = fd; - } - sc = malloc(sizeof(struct pci_vtblk_softc)); memset(sc, 0, sizeof(struct pci_vtblk_softc)); From owner-svn-soc-all@FreeBSD.ORG Wed Jul 11 12:54:14 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 51503106564A for ; Wed, 11 Jul 2012 12:54:13 +0000 (UTC) (envelope-from exxo@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Wed, 11 Jul 2012 12:54:13 +0000 Date: Wed, 11 Jul 2012 12:54:13 +0000 From: exxo@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120711125413.51503106564A@hub.freebsd.org> Cc: Subject: socsvn commit: r239266 - soc2012/exxo X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Jul 2012 12:54:14 -0000 Author: exxo Date: Wed Jul 11 12:54:12 2012 New Revision: 239266 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239266 Log: Updating sofnotes Modified: soc2012/exxo/softnotes.txt Modified: soc2012/exxo/softnotes.txt ============================================================================== --- soc2012/exxo/softnotes.txt Wed Jul 11 08:24:30 2012 (r239265) +++ soc2012/exxo/softnotes.txt Wed Jul 11 12:54:12 2012 (r239266) @@ -1,3 +1,48 @@ -contrib/cvs FIXED (patch updated) -usr.bin/who OK (software dependant, utmpx fixed it) - +openssl-1.0.1c FIXED (patch provided. Be aware of some TODO parts, Bio connect is not concerned by this patch) +contrib/cvs FIXED (patch updated) +usr.bin/who OK (software dependant, utmpx fixed it) +usr.bin/rusers +usr.bin/bluetooth +usr.bin/systat +usr.bin/rup +usr.bin/quota +usr.bin/newkey +usr.bin/ypwhich +usr.bin/getent +usr.bin/talk +contrib/bsnmp +contrib/amd +contrib/ntp +contrib/tcsh +contrib/tcp_wrappers +contrib/libpcap +contrib/traceroute +contrib/ipfilter +contrib/gdb +contrib/opie +contrib/sendmail +contrib/bind9 +contrib/smbfs +crypto/heimdal +sbin/atm +sbin/route +sbin/natd +sbin/nos-tun +sbin/routed +sbin/ipfw +sbin/ggate +share/doc/psd +usr.sbin/ypset +usr.sbin/bluetooth +usr.sbin/mount_portalfs +usr.sbin/ppp +usr.sbin/timed +usr.sbin/bootparamd +usr.sbin/ypbind +usr.sbin/bsnmpd +lib/libbluetooth +lib/libutil +lib/libradius +lib/libtacplus +lib/libcompat +libexec/bootpd From owner-svn-soc-all@FreeBSD.ORG Wed Jul 11 17:25:46 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 6A30C106564A for ; Wed, 11 Jul 2012 17:25:44 +0000 (UTC) (envelope-from exxo@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Wed, 11 Jul 2012 17:25:44 +0000 Date: Wed, 11 Jul 2012 17:25:44 +0000 From: exxo@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120711172544.6A30C106564A@hub.freebsd.org> Cc: Subject: socsvn commit: r239272 - soc2012/exxo/freebsd-head/usr.bin/systat X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Jul 2012 17:25:46 -0000 Author: exxo Date: Wed Jul 11 17:25:43 2012 New Revision: 239272 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239272 Log: Fixing usr.bin/systat Modified: soc2012/exxo/freebsd-head/usr.bin/systat/netcmds.c Modified: soc2012/exxo/freebsd-head/usr.bin/systat/netcmds.c ============================================================================== --- soc2012/exxo/freebsd-head/usr.bin/systat/netcmds.c Wed Jul 11 16:52:25 2012 (r239271) +++ soc2012/exxo/freebsd-head/usr.bin/systat/netcmds.c Wed Jul 11 17:25:43 2012 (r239272) @@ -61,8 +61,14 @@ #define streq(a,b) (strcmp(a,b)==0) +union storage_addr { + struct in_addr in; + struct in6_addr in6; +}; + static struct hitem { - struct in_addr addr; + union storage_addr addr; + int family; int onoff; } *hosts; @@ -73,7 +79,7 @@ static void showprotos(void); static int selectport(long, int); static void showports(void); -static int selecthost(struct in_addr *, int); +static int selecthost(union storage_addr *, int, int); static void showhosts(void); int @@ -96,7 +102,7 @@ } if (prefix(cmd, "reset")) { selectproto(0); - selecthost(0, 0); + selecthost(0, 0, 0); selectport(-1, 0); return (1); } @@ -126,8 +132,9 @@ { char *cp, *tmpstr, *tmpstr1; struct servent *sp; - struct hostent *hp; - struct in_addr in; + struct addrinfo hint, *res, *res0; + union storage_addr addr; + int family = AF_UNSPEC; tmpstr = tmpstr1 = strdup(args); cp = strchr(tmpstr1, '\n'); @@ -143,22 +150,46 @@ *cp++ = '\0'; if (cp - tmpstr1 == 0) break; + if (streq(tmpstr1, "-4")) { + family = AF_INET; + continue; + } + else if (streq(tmpstr1, "-6")) { + family = AF_INET6; + continue; + } sp = getservbyname(tmpstr1, protos == TCP ? "tcp" : protos == UDP ? "udp" : 0); if (sp) { selectport(sp->s_port, onoff); continue; } - hp = gethostbyname(tmpstr1); - if (hp == 0) { - in.s_addr = inet_addr(tmpstr1); - if ((int)in.s_addr == -1) { - error("%s: unknown host or port", tmpstr1); + memset(&hint, 0, sizeof(hint)); + hint.ai_family = family; + hint.ai_protocol = (protos == TCP ? IPPROTO_TCP : protos == UDP ? IPPROTO_UDP : 0); + hint.ai_flags = AI_ADDRCONFIG; + if ( (getaddrinfo(tmpstr1, 0, &hint, &res0))) { + error("%s: unknown host or port", tmpstr1); + continue; + } + for (res = res0; res; res = res->ai_next) { + switch (res->ai_family) { + case AF_INET : + memcpy(&addr.in, + &((struct sockaddr_in *)res->ai_addr)->sin_addr, + sizeof(addr.in)); + break; + case AF_INET6 : + memcpy(&addr.in6, + &((struct sockaddr_in6 *)res->ai_addr)->sin6_addr, + sizeof(addr.in6)); + break; + default : continue; } - } else - in = *(struct in_addr *)hp->h_addr; - selecthost(&in, onoff); + selecthost(&addr, res->ai_family, onoff); + } + freeaddrinfo(res0); } free(tmpstr); } @@ -253,12 +284,15 @@ } } +#define af4cmp(x, y) (memcmp(&x.s_addr, &y.s_addr, sizeof(x.s_addr))==0) +#define af6cmp(x, y) (memcmp(&x.s6_addr, &y.s6_addr, sizeof(x.s6_addr))==0) + static int -selecthost(struct in_addr *in, int onoff) +selecthost(union storage_addr *addr, int family, int onoff) { struct hitem *p; - if (in == 0) { + if (addr == 0) { if (hosts == 0) return (0); free((char *)hosts), hosts = 0; @@ -266,7 +300,9 @@ return (1); } for (p = hosts; p < hosts+nhosts; p++) - if (p->addr.s_addr == in->s_addr) { + if (p->family == family && family == AF_INET ? + af4cmp(p->addr.in, addr->in) : af6cmp(p->addr.in6, addr->in6)) + { p->onoff = onoff; return (0); } @@ -275,7 +311,8 @@ else hosts = (struct hitem *)realloc(hosts, (nhosts+1)*sizeof (*p)); p = &hosts[nhosts++]; - p->addr = *in; + p->addr = *addr; + p->family = family; p->onoff = onoff; return (1); } @@ -287,8 +324,11 @@ if (hosts) for (p = hosts; p < hosts+nhosts; p++) - if (p->addr.s_addr == inp->inp_laddr.s_addr || - p->addr.s_addr == inp->inp_faddr.s_addr) + if (((inp->inp_vflag & INP_IPV4) && p->family == AF_INET && + (af4cmp(p->addr.in, inp->inp_laddr) || af4cmp(p->addr.in, inp->inp_faddr))) + || + ((inp->inp_vflag & INP_IPV6) && p->family == AF_INET6 && + (af6cmp(p->addr.in6, inp->in6p_laddr) || af6cmp(p->addr.in6, inp->in6p_faddr)))) return (p->onoff); return (1); } @@ -298,11 +338,27 @@ { struct hitem *p; struct hostent *hp; + const void *host; + socklen_t len; + char str[INET6_ADDRSTRLEN]; for (p = hosts; p < hosts+nhosts; p++) { - hp = gethostbyaddr((char *)&p->addr, sizeof (p->addr), AF_INET); + switch (p->family) { + case AF_INET : + host = (const void *)&p->addr.in; + len = sizeof(p->addr.in); + break; + case AF_INET6 : + host = (const void *)&p->addr.in6; + len = sizeof(p->addr.in6); + break; + default : + continue; + } + hp = gethostbyaddr(host, len, p->family); if (!p->onoff) addch('!'); - printw("%s ", hp ? hp->h_name : (char *)inet_ntoa(p->addr)); + printw("%s%s ", hp ? hp->h_name : (char *)inet_ntop(p->family, host, str, INET6_ADDRSTRLEN), + p->family == AF_INET ? "(v4)" : "(v6)"); } } From owner-svn-soc-all@FreeBSD.ORG Wed Jul 11 18:37:34 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 8CF54106566B for ; Wed, 11 Jul 2012 18:37:32 +0000 (UTC) (envelope-from exxo@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Wed, 11 Jul 2012 18:37:32 +0000 Date: Wed, 11 Jul 2012 18:37:32 +0000 From: exxo@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120711183732.8CF54106566B@hub.freebsd.org> Cc: Subject: socsvn commit: r239275 - soc2012/exxo/freebsd-head/usr.bin/systat X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Jul 2012 18:37:34 -0000 Author: exxo Date: Wed Jul 11 18:37:31 2012 New Revision: 239275 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239275 Log: Add IPV6 definitions to usr.bin/systat Modified: soc2012/exxo/freebsd-head/usr.bin/systat/netcmds.c Modified: soc2012/exxo/freebsd-head/usr.bin/systat/netcmds.c ============================================================================== --- soc2012/exxo/freebsd-head/usr.bin/systat/netcmds.c Wed Jul 11 17:11:54 2012 (r239274) +++ soc2012/exxo/freebsd-head/usr.bin/systat/netcmds.c Wed Jul 11 18:37:31 2012 (r239275) @@ -63,7 +63,9 @@ union storage_addr { struct in_addr in; +#ifdef INET6 struct in6_addr in6; +#endif }; static struct hitem { @@ -134,7 +136,11 @@ struct servent *sp; struct addrinfo hint, *res, *res0; union storage_addr addr; +#ifdef INET6 int family = AF_UNSPEC; +#else + int family = AF_INET; +#endif tmpstr = tmpstr1 = strdup(args); cp = strchr(tmpstr1, '\n'); @@ -154,10 +160,12 @@ family = AF_INET; continue; } +#ifdef INET6 else if (streq(tmpstr1, "-6")) { family = AF_INET6; continue; } +#endif sp = getservbyname(tmpstr1, protos == TCP ? "tcp" : protos == UDP ? "udp" : 0); if (sp) { @@ -179,11 +187,13 @@ &((struct sockaddr_in *)res->ai_addr)->sin_addr, sizeof(addr.in)); break; +#ifdef INET6 case AF_INET6 : memcpy(&addr.in6, &((struct sockaddr_in6 *)res->ai_addr)->sin6_addr, sizeof(addr.in6)); break; +#endif default : continue; } @@ -285,7 +295,9 @@ } #define af4cmp(x, y) (memcmp(&x.s_addr, &y.s_addr, sizeof(x.s_addr))==0) +#ifdef INET6 #define af6cmp(x, y) (memcmp(&x.s6_addr, &y.s6_addr, sizeof(x.s6_addr))==0) +#endif static int selecthost(union storage_addr *addr, int family, int onoff) @@ -300,8 +312,12 @@ return (1); } for (p = hosts; p < hosts+nhosts; p++) +#ifdef INET6 if (p->family == family && family == AF_INET ? af4cmp(p->addr.in, addr->in) : af6cmp(p->addr.in6, addr->in6)) +#else + if (p->family == family && af4cmp(p->addr.in, addr->in)) +#endif { p->onoff = onoff; return (0); @@ -326,10 +342,11 @@ for (p = hosts; p < hosts+nhosts; p++) if (((inp->inp_vflag & INP_IPV4) && p->family == AF_INET && (af4cmp(p->addr.in, inp->inp_laddr) || af4cmp(p->addr.in, inp->inp_faddr))) - || - ((inp->inp_vflag & INP_IPV6) && p->family == AF_INET6 && - (af6cmp(p->addr.in6, inp->in6p_laddr) || af6cmp(p->addr.in6, inp->in6p_faddr)))) - return (p->onoff); +#ifdef INET6 + || ((inp->inp_vflag & INP_IPV6) && p->family == AF_INET6 && + (af6cmp(p->addr.in6, inp->in6p_laddr) || af6cmp(p->addr.in6, inp->in6p_faddr))) +#endif + ) return (p->onoff); return (1); } @@ -340,7 +357,11 @@ struct hostent *hp; const void *host; socklen_t len; +#ifdef INET6 char str[INET6_ADDRSTRLEN]; +#else + char str[INET_ADDRSTRLEN]; +#endif for (p = hosts; p < hosts+nhosts; p++) { switch (p->family) { @@ -348,17 +369,23 @@ host = (const void *)&p->addr.in; len = sizeof(p->addr.in); break; +#ifdef INET6 case AF_INET6 : host = (const void *)&p->addr.in6; len = sizeof(p->addr.in6); break; +#endif default : continue; } hp = gethostbyaddr(host, len, p->family); if (!p->onoff) addch('!'); +#ifdef INET6 printw("%s%s ", hp ? hp->h_name : (char *)inet_ntop(p->family, host, str, INET6_ADDRSTRLEN), p->family == AF_INET ? "(v4)" : "(v6)"); +#else + printw("%s ", hp ? hp->h_name : (char *)inet_ntoa(p->addr.in)); +#endif } } From owner-svn-soc-all@FreeBSD.ORG Wed Jul 11 18:46:52 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 5F130106564A for ; Wed, 11 Jul 2012 18:46:50 +0000 (UTC) (envelope-from exxo@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Wed, 11 Jul 2012 18:46:50 +0000 Date: Wed, 11 Jul 2012 18:46:50 +0000 From: exxo@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120711184650.5F130106564A@hub.freebsd.org> Cc: Subject: socsvn commit: r239276 - soc2012/exxo/patches X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Jul 2012 18:46:52 -0000 Author: exxo Date: Wed Jul 11 18:46:50 2012 New Revision: 239276 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239276 Log: Adding systat.patch Added: soc2012/exxo/patches/systat.patch Added: soc2012/exxo/patches/systat.patch ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/exxo/patches/systat.patch Wed Jul 11 18:46:50 2012 (r239276) @@ -0,0 +1,217 @@ +Index: freebsd-head/usr.bin/systat/netcmds.c +=================================================================== +--- freebsd-head/usr.bin/systat/netcmds.c (revision 239266) ++++ freebsd-head/usr.bin/systat/netcmds.c (working copy) +@@ -61,8 +61,16 @@ static const char sccsid[] = "@(#)netcmd + + #define streq(a,b) (strcmp(a,b)==0) + ++union storage_addr { ++ struct in_addr in; ++#ifdef INET6 ++ struct in6_addr in6; ++#endif ++}; ++ + static struct hitem { +- struct in_addr addr; ++ union storage_addr addr; ++ int family; + int onoff; + } *hosts; + +@@ -73,7 +81,7 @@ static int selectproto(const char *); + static void showprotos(void); + static int selectport(long, int); + static void showports(void); +-static int selecthost(struct in_addr *, int); ++static int selecthost(union storage_addr *, int, int); + static void showhosts(void); + + int +@@ -96,7 +104,7 @@ netcmd(const char *cmd, const char *args + } + if (prefix(cmd, "reset")) { + selectproto(0); +- selecthost(0, 0); ++ selecthost(0, 0, 0); + selectport(-1, 0); + return (1); + } +@@ -126,8 +134,13 @@ changeitems(const char *args, int onoff) + { + char *cp, *tmpstr, *tmpstr1; + struct servent *sp; +- struct hostent *hp; +- struct in_addr in; ++ struct addrinfo hint, *res, *res0; ++ union storage_addr addr; ++#ifdef INET6 ++ int family = AF_UNSPEC; ++#else ++ int family = AF_INET; ++#endif + + tmpstr = tmpstr1 = strdup(args); + cp = strchr(tmpstr1, '\n'); +@@ -143,22 +156,50 @@ changeitems(const char *args, int onoff) + *cp++ = '\0'; + if (cp - tmpstr1 == 0) + break; ++ if (streq(tmpstr1, "-4")) { ++ family = AF_INET; ++ continue; ++ } ++#ifdef INET6 ++ else if (streq(tmpstr1, "-6")) { ++ family = AF_INET6; ++ continue; ++ } ++#endif + sp = getservbyname(tmpstr1, + protos == TCP ? "tcp" : protos == UDP ? "udp" : 0); + if (sp) { + selectport(sp->s_port, onoff); + continue; + } +- hp = gethostbyname(tmpstr1); +- if (hp == 0) { +- in.s_addr = inet_addr(tmpstr1); +- if ((int)in.s_addr == -1) { +- error("%s: unknown host or port", tmpstr1); ++ memset(&hint, 0, sizeof(hint)); ++ hint.ai_family = family; ++ hint.ai_protocol = (protos == TCP ? IPPROTO_TCP : protos == UDP ? IPPROTO_UDP : 0); ++ hint.ai_flags = AI_ADDRCONFIG; ++ if ( (getaddrinfo(tmpstr1, 0, &hint, &res0))) { ++ error("%s: unknown host or port", tmpstr1); ++ continue; ++ } ++ for (res = res0; res; res = res->ai_next) { ++ switch (res->ai_family) { ++ case AF_INET : ++ memcpy(&addr.in, ++ &((struct sockaddr_in *)res->ai_addr)->sin_addr, ++ sizeof(addr.in)); ++ break; ++#ifdef INET6 ++ case AF_INET6 : ++ memcpy(&addr.in6, ++ &((struct sockaddr_in6 *)res->ai_addr)->sin6_addr, ++ sizeof(addr.in6)); ++ break; ++#endif ++ default : + continue; + } +- } else +- in = *(struct in_addr *)hp->h_addr; +- selecthost(&in, onoff); ++ selecthost(&addr, res->ai_family, onoff); ++ } ++ freeaddrinfo(res0); + } + free(tmpstr); + } +@@ -253,12 +294,17 @@ showports(void) + } + } + ++#define af4cmp(x, y) (memcmp(&x.s_addr, &y.s_addr, sizeof(x.s_addr))==0) ++#ifdef INET6 ++#define af6cmp(x, y) (memcmp(&x.s6_addr, &y.s6_addr, sizeof(x.s6_addr))==0) ++#endif ++ + static int +-selecthost(struct in_addr *in, int onoff) ++selecthost(union storage_addr *addr, int family, int onoff) + { + struct hitem *p; + +- if (in == 0) { ++ if (addr == 0) { + if (hosts == 0) + return (0); + free((char *)hosts), hosts = 0; +@@ -266,7 +312,13 @@ selecthost(struct in_addr *in, int onoff + return (1); + } + for (p = hosts; p < hosts+nhosts; p++) +- if (p->addr.s_addr == in->s_addr) { ++#ifdef INET6 ++ if (p->family == family && family == AF_INET ? ++ af4cmp(p->addr.in, addr->in) : af6cmp(p->addr.in6, addr->in6)) ++#else ++ if (p->family == family && af4cmp(p->addr.in, addr->in)) ++#endif ++ { + p->onoff = onoff; + return (0); + } +@@ -275,7 +327,8 @@ selecthost(struct in_addr *in, int onoff + else + hosts = (struct hitem *)realloc(hosts, (nhosts+1)*sizeof (*p)); + p = &hosts[nhosts++]; +- p->addr = *in; ++ p->addr = *addr; ++ p->family = family; + p->onoff = onoff; + return (1); + } +@@ -287,9 +340,13 @@ checkhost(struct inpcb *inp) + + if (hosts) + for (p = hosts; p < hosts+nhosts; p++) +- if (p->addr.s_addr == inp->inp_laddr.s_addr || +- p->addr.s_addr == inp->inp_faddr.s_addr) +- return (p->onoff); ++ if (((inp->inp_vflag & INP_IPV4) && p->family == AF_INET && ++ (af4cmp(p->addr.in, inp->inp_laddr) || af4cmp(p->addr.in, inp->inp_faddr))) ++#ifdef INET6 ++ || ((inp->inp_vflag & INP_IPV6) && p->family == AF_INET6 && ++ (af6cmp(p->addr.in6, inp->in6p_laddr) || af6cmp(p->addr.in6, inp->in6p_faddr))) ++#endif ++ ) return (p->onoff); + return (1); + } + +@@ -298,11 +355,37 @@ showhosts(void) + { + struct hitem *p; + struct hostent *hp; ++ const void *host; ++ socklen_t len; ++#ifdef INET6 ++ char str[INET6_ADDRSTRLEN]; ++#else ++ char str[INET_ADDRSTRLEN]; ++#endif + + for (p = hosts; p < hosts+nhosts; p++) { +- hp = gethostbyaddr((char *)&p->addr, sizeof (p->addr), AF_INET); ++ switch (p->family) { ++ case AF_INET : ++ host = (const void *)&p->addr.in; ++ len = sizeof(p->addr.in); ++ break; ++#ifdef INET6 ++ case AF_INET6 : ++ host = (const void *)&p->addr.in6; ++ len = sizeof(p->addr.in6); ++ break; ++#endif ++ default : ++ continue; ++ } ++ hp = gethostbyaddr(host, len, p->family); + if (!p->onoff) + addch('!'); +- printw("%s ", hp ? hp->h_name : (char *)inet_ntoa(p->addr)); ++#ifdef INET6 ++ printw("%s%s ", hp ? hp->h_name : (char *)inet_ntop(p->family, host, str, INET6_ADDRSTRLEN), ++ p->family == AF_INET ? "(v4)" : "(v6)"); ++#else ++ printw("%s ", hp ? hp->h_name : (char *)inet_ntoa(p->addr.in)); ++#endif + } + } From owner-svn-soc-all@FreeBSD.ORG Wed Jul 11 21:35:56 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 100B3106566C for ; Wed, 11 Jul 2012 21:35:54 +0000 (UTC) (envelope-from oleksandr@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Wed, 11 Jul 2012 21:35:54 +0000 Date: Wed, 11 Jul 2012 21:35:54 +0000 From: oleksandr@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120711213554.100B3106566C@hub.freebsd.org> Cc: Subject: socsvn commit: r239283 - soc2012/oleksandr/udf-head/sys/fs/udf2 X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Jul 2012 21:35:56 -0000 Author: oleksandr Date: Wed Jul 11 21:35:53 2012 New Revision: 239283 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239283 Log: Clean code, add debug printf and KASSERTS Modified: soc2012/oleksandr/udf-head/sys/fs/udf2/udf_subr.c soc2012/oleksandr/udf-head/sys/fs/udf2/udf_vnops.c Modified: soc2012/oleksandr/udf-head/sys/fs/udf2/udf_subr.c ============================================================================== --- soc2012/oleksandr/udf-head/sys/fs/udf2/udf_subr.c Wed Jul 11 20:17:14 2012 (r239282) +++ soc2012/oleksandr/udf-head/sys/fs/udf2/udf_subr.c Wed Jul 11 21:35:53 2012 (r239283) @@ -31,11 +31,11 @@ #include #include #include -#include /* KASSERT */ +#include #include #include #include -#include /* We shouldn't be, but are dependent on this header. */ +#include #include #include "ecma167-udf.h" #include "udf.h" @@ -353,7 +353,7 @@ return (EINVAL); } -/* assert(*last_tracknr >= *first_tracknr); */ + KASSERT(*last_tracknr >= *first_tracknr, ("udf_search_tracks: sanity check failed")); return (0); } @@ -1151,8 +1151,8 @@ free(dscr, M_UDFTEMP); break; } - /* assert((dscr_size % sector_size) == 0); */ - + KASSERT(!(dscr_size % sector_size), ("udf_read_vds_extent:" + "wrong descriptor sze")); len -= dscr_size; loc += dscr_size / sector_size; } @@ -1181,6 +1181,7 @@ anchor = ump->anchors[0]; anchor2 = ump->anchors[1]; + KASSERT(anchor, ("udf_read_vds_space: anchor is not valid")); if (anchor2) { size = sizeof(struct extent_ad); @@ -2075,7 +2076,8 @@ maps_on = ump->vtop[log_part]; switch (ump->vtop_tp[log_part]) { case UDF_VTOP_TYPE_PHYS : - KASSERT(maps_on == log_part, (" maps_on != log_part")); + KASSERT(maps_on == log_part, ("udf_process_vds: logical" + "partition do not equal vpartnr translations\n")); ump->vtop_alloc[log_part] = UDF_ALLOC_SPACEMAP; break; case UDF_VTOP_TYPE_VIRT : @@ -2083,7 +2085,8 @@ ump->vtop_alloc[maps_on] = UDF_ALLOC_SEQUENTIAL; break; case UDF_VTOP_TYPE_SPARABLE : - KASSERT(maps_on == log_part, ("maps_on != log_part")); + KASSERT(maps_on == log_part, ("udf_process_vds: logical" + "partition do not equal vpartnr translations\n")); ump->vtop_alloc[log_part] = UDF_ALLOC_SPACEMAP; break; case UDF_VTOP_TYPE_META : @@ -2937,8 +2940,9 @@ sector_size = le32toh(ump->logical_vol->lb_size); /* check assertions */ - /* assert(vat_node->fe || vat_node->efe); */ - /* assert(ump->logvol_integrity); */ + KASSERT(vat_node->fe || vat_node->efe, ("udf_check_for_vat:" + "Extended File Entry or File Entry is null\n")); + KASSERT(ump->logvol_integrity, ("udf_check_for_vat: invalid current integrity")); /* set vnode type to regular file or we can't read from it! */ /* vat_node->vnode->v_type = VREG; */ @@ -3037,7 +3041,7 @@ vat_offset = vat->header_len; vat_entries = (vat_length - vat_offset)/4; - /* assert(lvinfo); */ + KASSERT(lvinfo, ("udf_check_for_vat: invalid integrity descriptor")); lvinfo->num_files = vat->num_files; lvinfo->num_directories = vat->num_directories; lvinfo->min_udf_readver = vat->min_udf_readver; @@ -3134,15 +3138,16 @@ if (file_type == 248) { + DPRINTF(VOLUMES, ("Checking for VAT at sector %d\n", vat_loc)); icb_loc.loc.part_num = htole16(UDF_VTOP_RAWPART); icb_loc.loc.lb_num = htole32(vat_loc); ino = udf_get_node_id(&icb_loc); error = udf_get_node(ump, ino, &vat_node); - /* error = udf_vget(ump->vfs_mountp, ino, LK_EXCLUSIVE, &vp); */ - /* vat_node = VTOI(vp); */ if (!error) { error = udf_check_for_vat(vat_node); + DPRINTFIF(VOLUMES, !error, + ("VAT accepted at %d\n", vat_loc)); if (!error) break; } @@ -4496,15 +4501,16 @@ struct extfile_entry *efe = dir_node->efe; struct fileid_desc *fid; struct dirent *dirent; - uint64_t file_size, pre_diroffset, diroffset; + uint64_t file_size, pre_diroffset, diroffset = 0; uint32_t lb_size; - int error; + int error = 0; /* make sure we have a dirhash to work on */ dirh = dir_node->dir_hash; - KASSERT(dirh); - KASSERT(dirh->refcnt > 0); + KASSERT(dirh, ("dirhash_fill: dirhash is null")); + KASSERT(dirh->dn_refcount > 0, ("dirhash_fill: dirhash does not have reference")); +#if 0 if (dirh->flags & DIRH_BROKEN) return (EIO); if (dirh->flags & DIRH_COMPLETE) @@ -4512,12 +4518,13 @@ /* make sure we have a clean dirhash to add to */ dirhash_purge_entries(dirh); +#endif /* get directory filesize */ if (fe) { file_size = le64toh(fe->inf_len); } else { - assert(efe); + KASSERT(node->efe, ("Extended File Entry is null")); file_size = le64toh(efe->inf_len); } @@ -4528,8 +4535,6 @@ /* allocate temporary space for dirent */ dirent = malloc(sizeof(struct dirent), M_UDFTEMP, M_WAITOK); - error = 0; - diroffset = 0; while (diroffset < file_size) { /* transfer a new fid/dirent */ pre_diroffset = diroffset; @@ -5293,48 +5298,6 @@ #endif /* --------------------------------------------------------------------- */ -#if 0 -int -udf_vget(struct mount *mp, ino_t ino, int flags, struct vnode **vpp) -{ - printf("%s ran\n", __func__); - - int error; - struct udf_node *unode; - struct udf_mount *ump; - struct vnode *nvp; - struct long_ad node_icb_loc; - int udf_file_type; - - unode = uma_zalloc(udf_zone_node, M_WAITOK | M_ZERO); - unode = udf_alloc_node() - - unode->hash_id = ino; - - lockmgr(nvp->v_vnlock, LK_EXCLUSIVE, NULL); - if ((error = insmntque(nvp, mp)) != 0) { - uma_zfree(udf_zone_node, unode); - return (error); - } - - /* TODO: Does this leak unode or vnodes? */ - error = vfs_hash_insert(nvp, ino, flags, curthread, vpp, NULL, NULL); - if (error || *vpp != NULL) - return (error); - - /* - * Load read and set up the unode structure. - */ - udf_get_node_longad(ino, &node_icb_loc); - error = udf_get_node(ump, &node_icb_loc, unode); - if (error) { - vgone(nvp); - vput(nvp); - ungetnewvnode(nvp); - } - return -} -#endif /* * Each node can have an attached streamdir node though not recursively. These @@ -5363,6 +5326,8 @@ uint32_t lb_size, sector, dummy; uint8_t *file_data; + DPRINTF(NODE, ("udf_get_node called\n")); + udf_get_node_longad(ino, &icb_loc); @@ -6221,12 +6186,13 @@ int enough, error; uint32_t fid_size, lb_size; -/* assert(fid); - assert(dirent); - assert(dir_node); - assert(offset); - assert(*offset != 1); */ + KASSERT(fid, ("udf_read_fid_stream: File Identifier Descriptor is null")); + /* KASSERT(dirent, ("dirent == null")); */ + KASSERT(dir_node, ("udf_read_fid_stream: udf_node is null")); + KASSERT(offset, ("udf_read_fid_stream: offset == 0")); + KASSERT(*offset != 1, ("udf_read_fid_stream: offset != 1")); + DPRINTF(FIDS, ("read_fid_stream called at offset %llu\n", *offset)); /* check if we're past the end of the directory */ if (fe) { file_size = le64toh(fe->inf_len); @@ -6259,6 +6225,7 @@ if (error) return (error); + DPRINTF(FIDS, ("\tfid piece read in fine\n")); /* * Check if we got a whole descriptor. * TODO Try to `resync' directory stream when something is very wrong. @@ -6269,11 +6236,13 @@ if (error) { goto brokendir; } + DPRINTF(FIDS, ("\ttag check ok\n")); if (le16toh(fid->tag.id) != TAGID_FID) { error = EIO; goto brokendir; } + DPRINTF(FIDS, ("\ttag checked ok: got TAGID_FID\n")); /* check for length */ fid_size = udf_fidsize(fid); @@ -6282,16 +6251,22 @@ error = EIO; goto brokendir; } + DPRINTF(FIDS, ("\tthe complete fid is read in\n")); /* check FID contents */ error = udf_check_tag_payload((union dscrptr *) fid, lb_size); brokendir: if (error) { /* note that is sometimes a bit quick to report */ + printf("UDF: BROKEN DIRECTORY ENTRY\n"); /* RESYNC? */ /* TODO: use udf_resync_fid_stream */ return (EIO); } + DPRINTF(FIDS, ("\tplayload checked ok\n")); + + /* we got a whole and valid descriptor! */ + DPRINTF(FIDS, ("\tinterpret FID\n")); /* advance */ *offset += fid_size; Modified: soc2012/oleksandr/udf-head/sys/fs/udf2/udf_vnops.c ============================================================================== --- soc2012/oleksandr/udf-head/sys/fs/udf2/udf_vnops.c Wed Jul 11 20:17:14 2012 (r239282) +++ soc2012/oleksandr/udf-head/sys/fs/udf2/udf_vnops.c Wed Jul 11 21:35:53 2012 (r239283) @@ -520,8 +520,8 @@ /* bp->b_lblkno = bp->b_blkno; */ /* check assertions: we OUGHT to always get multiples of this */ - KASSERT(sectors * lb_size == bp->b_bcount, ("udf_strategy: wrong length - to fetch/store in sectors")); + KASSERT(sectors * lb_size == bp->b_bcount, ("udf_strategy: wrong length" + "to fetch/store in sectors")); if (bp->b_blkno == bp->b_lblkno) { /* get logical block and run */ error = udf_bmap_translate(udf_node, bp->b_lblkno, &lsector, &maxblks); From owner-svn-soc-all@FreeBSD.ORG Thu Jul 12 04:37:59 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id A88B5106564A for ; Thu, 12 Jul 2012 04:37:57 +0000 (UTC) (envelope-from gmiller@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Thu, 12 Jul 2012 04:37:57 +0000 Date: Thu, 12 Jul 2012 04:37:57 +0000 From: gmiller@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120712043757.A88B5106564A@hub.freebsd.org> Cc: Subject: socsvn commit: r239297 - in soc2012/gmiller/locking-head: . include lib/libwitness X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Jul 2012 04:37:59 -0000 Author: gmiller Date: Thu Jul 12 04:37:56 2012 New Revision: 239297 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239297 Log: r239323@FreeBSD-dev: root | 2012-07-03 20:22:26 -0500 Implement LoR log retrieval functions: * pthread_lor_begin_np() * pthread_lor_next_np() * pthread_lor_end_np() Implement LoR log clearing function pthread_lor_clear_np(). Modified: soc2012/gmiller/locking-head/ (props changed) soc2012/gmiller/locking-head/include/pthread_np.h soc2012/gmiller/locking-head/lib/libwitness/logs.c Modified: soc2012/gmiller/locking-head/include/pthread_np.h ============================================================================== --- soc2012/gmiller/locking-head/include/pthread_np.h Thu Jul 12 02:58:45 2012 (r239296) +++ soc2012/gmiller/locking-head/include/pthread_np.h Thu Jul 12 04:37:56 2012 (r239297) @@ -58,7 +58,10 @@ #endif +struct _pthread_lor_private; + struct pthread_lock_order_np { + struct _pthread_lor_private *_pvt; void *lock_first; void *lock_second; }; Modified: soc2012/gmiller/locking-head/lib/libwitness/logs.c ============================================================================== --- soc2012/gmiller/locking-head/lib/libwitness/logs.c Thu Jul 12 02:58:45 2012 (r239296) +++ soc2012/gmiller/locking-head/lib/libwitness/logs.c Thu Jul 12 04:37:56 2012 (r239297) @@ -27,13 +27,74 @@ #include "witness.h" +STAILQ_HEAD(lor_head, lor_entry) lor_head = STAILQ_HEAD_INITIALIZER(lor_head); + +struct lor_entry { + STAILQ_ENTRY(lor_entry) lor_next; + void *lock_first; + void *lock_second; +}; + +struct _pthread_lor_private { + struct lor_entry *last_record; +}; + void log_reversal(void *lock, void *previous) { - struct pthread_lock_order_np *entry; + struct lor_entry *entry; - entry = malloc(sizeof(struct pthread_lock_order_np)); + entry = malloc(sizeof(struct lor_entry)); entry->lock_first = previous; entry->lock_second = lock; + + STAILQ_INSERT_TAIL(&lor_head, entry, lor_next); +} + +void +pthread_lor_begin_np(struct pthread_lock_order_np *lor) +{ + lor->_pvt = malloc(sizeof(struct _pthread_lor_private)); + lor->_pvt->last_record = NULL; +} + +int +pthread_lor_next_np(struct pthread_lock_order_np *lor) +{ + if (lor->_pvt->last_record == NULL) { + lor->_pvt->last_record = STAILQ_FIRST(&lor_head); + } else { + lor->_pvt->last_record = + STAILQ_NEXT(lor->_pvt->last_record, lor_next); + } + + if (lor->_pvt->last_record == NULL) { + return (0); + } + + lor->lock_first = lor->_pvt->last_record->lock_first; + lor->lock_second = lor->_pvt->last_record->lock_second; + + return (1); } +void +pthread_lor_end_np(struct pthread_lock_order_np *lor) +{ + if (lor->_pvt != NULL) { + free(lor->_pvt); + lor->_pvt = NULL; + } +} + +void +pthread_lor_clear_np(void) +{ + struct lor_entry *lor; + struct lor_entry *lor_temp; + + STAILQ_FOREACH_SAFE(lor, &lor_head, lor_next, lor_temp) { + STAILQ_REMOVE(&lor_head, lor, lor_entry, lor_next); + free(lor); + } +} From owner-svn-soc-all@FreeBSD.ORG Thu Jul 12 16:49:53 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 54AB81065675 for ; Thu, 12 Jul 2012 16:49:51 +0000 (UTC) (envelope-from exxo@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Thu, 12 Jul 2012 16:49:51 +0000 Date: Thu, 12 Jul 2012 16:49:51 +0000 From: exxo@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120712164951.54AB81065675@hub.freebsd.org> Cc: Subject: socsvn commit: r239308 - in soc2012/exxo: . freebsd-head/usr.bin/quota X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Jul 2012 16:49:53 -0000 Author: exxo Date: Thu Jul 12 16:49:50 2012 New Revision: 239308 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239308 Log: Fixing quota using new RPC API Modified: soc2012/exxo/freebsd-head/usr.bin/quota/quota.c soc2012/exxo/softnotes.txt Modified: soc2012/exxo/freebsd-head/usr.bin/quota/quota.c ============================================================================== --- soc2012/exxo/freebsd-head/usr.bin/quota/quota.c Thu Jul 12 15:20:20 2012 (r239307) +++ soc2012/exxo/freebsd-head/usr.bin/quota/quota.c Thu Jul 12 16:49:50 2012 (r239308) @@ -657,28 +657,17 @@ callaurpc(char *host, int prognum, int versnum, int procnum, xdrproc_t inproc, char *in, xdrproc_t outproc, char *out) { - struct sockaddr_in server_addr; enum clnt_stat clnt_stat; - struct hostent *hp; struct timeval timeout, tottimeout; CLIENT *client = NULL; - int sock = RPC_ANYSOCK; - if ((hp = gethostbyname(host)) == NULL) - return ((int) RPC_UNKNOWNHOST); timeout.tv_usec = 0; timeout.tv_sec = 6; - bcopy(hp->h_addr, &server_addr.sin_addr, - MIN(hp->h_length,(int)sizeof(server_addr.sin_addr))); - server_addr.sin_family = AF_INET; - server_addr.sin_port = 0; + if ((client = clnt_create_timed(host, prognum, + versnum, "udp", &timeout)) == NULL) - if ((client = clntudp_create(&server_addr, prognum, - versnum, timeout, &sock)) == NULL) - return ((int) rpc_createerr.cf_stat); - - client->cl_auth = authunix_create_default(); + client->cl_auth = authsys_create_default(); tottimeout.tv_sec = 25; tottimeout.tv_usec = 0; clnt_stat = clnt_call(client, procnum, inproc, in, Modified: soc2012/exxo/softnotes.txt ============================================================================== --- soc2012/exxo/softnotes.txt Thu Jul 12 15:20:20 2012 (r239307) +++ soc2012/exxo/softnotes.txt Thu Jul 12 16:49:50 2012 (r239308) @@ -3,9 +3,9 @@ usr.bin/who OK (software dependant, utmpx fixed it) usr.bin/rusers usr.bin/bluetooth -usr.bin/systat +usr.bin/systat FIXED (patch provided. systat now supports IPv6 when using ignore/display/show netstat commands) usr.bin/rup -usr.bin/quota +usr.bin/quota FIXED usr.bin/newkey usr.bin/ypwhich usr.bin/getent From owner-svn-soc-all@FreeBSD.ORG Thu Jul 12 16:53:41 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id ED2D41065674 for ; Thu, 12 Jul 2012 16:53:38 +0000 (UTC) (envelope-from vchan@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Thu, 12 Jul 2012 16:53:38 +0000 Date: Thu, 12 Jul 2012 16:53:38 +0000 From: vchan@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120712165338.ED2D41065674@hub.freebsd.org> Cc: Subject: socsvn commit: r239309 - soc2012/vchan/gtcp/bwalex-tc-play X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Jul 2012 16:53:41 -0000 Author: vchan Date: Thu Jul 12 16:53:38 2012 New Revision: 239309 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239309 Log: whole lotta changes to tcplay Modified: soc2012/vchan/gtcp/bwalex-tc-play/Makefile soc2012/vchan/gtcp/bwalex-tc-play/tcplay.c Modified: soc2012/vchan/gtcp/bwalex-tc-play/Makefile ============================================================================== --- soc2012/vchan/gtcp/bwalex-tc-play/Makefile Thu Jul 12 16:49:50 2012 (r239308) +++ soc2012/vchan/gtcp/bwalex-tc-play/Makefile Thu Jul 12 16:53:38 2012 (r239309) @@ -21,7 +21,7 @@ OBJS= tcplay.o crc32.o safe_mem.o io.o hdr.o humanize.o OBJS+= crypto.o generic_xts.o -CFLAGS+= $(WARNFLAGS) -I/usr/include +CFLAGS+= $(WARNFLAGS) -I/usr/include -I/usr/local/include ifeq (${DEBUG}, yes) CFLAGS+= -O0 -g -DDEBUG Modified: soc2012/vchan/gtcp/bwalex-tc-play/tcplay.c ============================================================================== --- soc2012/vchan/gtcp/bwalex-tc-play/tcplay.c Thu Jul 12 16:49:50 2012 (r239308) +++ soc2012/vchan/gtcp/bwalex-tc-play/tcplay.c Thu Jul 12 16:53:38 2012 (r239309) @@ -31,6 +31,7 @@ //#if defined(__DragonFly__) #include + //#endif #include @@ -42,12 +43,24 @@ #include #include #include + //#if defined(__linux__) //#include //#include //#elif defined(__DragonFly__) //#include #include + +//FreeBSD specific headers +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include @@ -71,6 +84,7 @@ /* new for FreeBSD */ static int unit = G_GATE_UNIT_AUTO; static int force = 0; +static unsigned sectorsize = 0; void tc_log(int is_err, const char *fmt, ...) @@ -926,41 +940,98 @@ return -1; } +/* not correct yet int -map_volume(const char *map_name, int sflag, - int interactive, time_t timeout) - +map_volume(int fd, int interactive) { - struct g_gate_ctl_create ggioc; - int fd; + struct g_gate_ctl_io ggio; + size_t bsize; + + if (g_gate_verbose == 0) { + if (daemon(0, 0) == -1) { + g_gate_destroy(unit, 1); + err(EXIT_FAILURE, "Cannot daemonize"); + } + } + g_gate_log(LOG_DEBUG, "Worker created: %u.", getpid()); + ggio.gctl_version = G_GATE_VERSION; + ggio.gctl_unit = unit; + bsize = sectorsize; + ggio.gctl_data = malloc(bsize); + for (;;) { + int error; +once_again: + ggio.gctl_length = bsize; + ggio.gctl_error = 0; + g_gate_ioctl(G_GATE_CMD_START, &ggio); + error = ggio.gctl_error; + switch (error) { + case 0: + break; + case ECANCELED: + /* Exit gracefully. + free(ggio.gctl_data); + g_gate_close_device(); + close(fd); + exit(EXIT_SUCCESS); + case ENOMEM: + /* Buffer too small. + assert(ggio.gctl_cmd == BIO_DELETE || + ggio.gctl_cmd == BIO_WRITE); + ggio.gctl_data = realloc(ggio.gctl_data, + ggio.gctl_length); + if (ggio.gctl_data != NULL) { + bsize = ggio.gctl_length; + goto once_again; + } + /* FALLTHROUGH + case ENXIO: + default: + g_gate_xlog("ioctl(/dev/%s): %s.", G_GATE_CTL_NAME, + strerror(error)); + } + + error = 0; + switch (ggio.gctl_cmd) { + case BIO_READ: + if ((size_t)ggio.gctl_length > bsize) { + ggio.gctl_data = realloc(ggio.gctl_data, + ggio.gctl_length); + if (ggio.gctl_data != NULL) + bsize = ggio.gctl_length; + else + error = ENOMEM; + } + if (error == 0) { + if (pread(fd, ggio.gctl_data, ggio.gctl_length, + ggio.gctl_offset) == -1) { + error = errno; + } + } + break; + case BIO_DELETE: + case BIO_WRITE: + if (pwrite(fd, ggio.gctl_data, ggio.gctl_length, + ggio.gctl_offset) == -1) { + error = errno; + } + break; + default: + error = EOPNOTSUPP; + } + + ggio.gctl_error = error; + g_gate_ioctl(G_GATE_CMD_DONE, &ggio); + } - fd = open(map_name, g_gate_openflags(sflags) | O_DIRECT | O_FSYNC); - if (fd == -1) - err(EXIT_FAILURE, "Cannot open %s", map_name); - ggioc.gctl_version = G_GATE_VERSION; - ggioc.gctl_unit = unit; - ggioc.gctl_mediasize = g_gate_mediasize(fd); - if (sectorsize == 0) - sectorsize = g_gate_sectorsize(fd); - ggioc.gctl_sectorsize = sectorsize; - ggioc.gctl_timeout = timeout; - ggioc.gctl_flags = sflags; - ggioc.gctl_maxcount = 0; - strlcpy(ggioc.gctl_info, map_name, sizeof(ggioc.gctl_info)); - g_gate_ioctl(G_GATE_CMD_CREATE, &ggioc); - if (unit == -1) - printf("%s%u\n", G_GATE_PROVIDER_NAME, ggioc.gctl_unit); - unit = ggioc.gctl_unit; - g_gatel_serve(fd); -} if (interactive) printf("All ok!\n"); return 0; -} -/* +}*/ + int map_volume(const char *map_name, const char *device, int sflag, const char *sys_dev, int protect_hidden, const char *keyfiles[], @@ -971,6 +1042,7 @@ { struct tcplay_info *info; int error; + int fd; info = info_map_common(device, sflag, sys_dev, protect_hidden, keyfiles, nkeyfiles, h_keyfiles, n_hkeyfiles, @@ -979,7 +1051,7 @@ if (info == NULL) return -1; - if ((error = dm_setup(map_name, info)) != 0) { + if ((error = dm_setup(fd, info)) != 0) { tc_log(1, "Could not set up mapping %s\n", map_name); if (info->hdr) free_safe_mem(info->hdr); @@ -994,7 +1066,7 @@ return 0; } -*/ + static int @@ -1038,7 +1110,7 @@ } int -dm_setup(const char *mapname, struct tcplay_info *info) +dm_setup(int fd, struct tcplay_info *info) { /* Commented out variables not needed in freeBSD*/ struct tc_cipher_chain *cipher_chain; @@ -1080,7 +1152,7 @@ cipher_chain = cipher_chain->prev, j++) { cookie = 0; - force = 1; //used in g_gate_destroy + //force = 1; used in g_gate_destroy /* aes-cbc-essiv:sha256 7997f8af... 0 /dev/ad0s0a 8 */ /* iv off---^ block off--^ */ @@ -1101,18 +1173,18 @@ /* * If this is the last element in the cipher chain, use the * final map name. Otherwise pick a secondary name... - */ + if (cipher_chain->prev == NULL) strcpy(map, mapname); else sprintf(map, "%s.%d", mapname, j); - /* changed from, "if ((dm_task_set_name(dmt, map)) == 0" */ + /* changed from, "if ((dm_task_set_name(dmt, map)) == 0" if (map == NULL) { tc_log(1, "task_set_name failed\n"); ret = -1; goto out; - } + }*/ /*#if defined(__linux__) uuid_generate(info->uuid); @@ -1175,8 +1247,89 @@ dm_udev_wait(cookie); */ +//FreeBSD + + struct g_gate_ctl_io ggio; + size_t bsize; - if ((r = asprintf(&uu_stack[uu_stack_idx++], "%s", map)) < 0) + if (g_gate_verbose == 0) { + if (daemon(0, 0) == -1) { + g_gate_destroy(unit, 1); + err(EXIT_FAILURE, "Cannot daemonize"); + } + } + g_gate_log(LOG_DEBUG, "Worker created: %u.", getpid()); + ggio.gctl_version = G_GATE_VERSION; + ggio.gctl_unit = unit; + bsize = sectorsize; + ggio.gctl_data = malloc(bsize); + for (;;) { + int error; +once_again: + ggio.gctl_length = bsize; + ggio.gctl_error = 0; + g_gate_ioctl(G_GATE_CMD_START, &ggio); + error = ggio.gctl_error; + switch (error) { + case 0: + break; + case ECANCELED: + /* Exit gracefully. */ + free(ggio.gctl_data); + g_gate_close_device(); + close(fd); + exit(EXIT_SUCCESS); + case ENOMEM: + /* Buffer too small. */ + assert(ggio.gctl_cmd == BIO_DELETE || + ggio.gctl_cmd == BIO_WRITE); + ggio.gctl_data = realloc(ggio.gctl_data, + ggio.gctl_length); + if (ggio.gctl_data != NULL) { + bsize = ggio.gctl_length; + goto once_again; + } + /* FALLTHROUGH */ + case ENXIO: + default: + g_gate_xlog("ioctl(/dev/%s): %s.", G_GATE_CTL_NAME, + strerror(error)); + } + + error = 0; + switch (ggio.gctl_cmd) { + case BIO_READ: + if ((size_t)ggio.gctl_length > bsize) { + ggio.gctl_data = realloc(ggio.gctl_data, + ggio.gctl_length); + if (ggio.gctl_data != NULL) + bsize = ggio.gctl_length; + else + error = ENOMEM; + } + if (error == 0) { + if (pread(fd, ggio.gctl_data, ggio.gctl_length, + ggio.gctl_offset) == -1) { + error = errno; + } + } + break; + case BIO_DELETE: + case BIO_WRITE: + if (pwrite(fd, ggio.gctl_data, ggio.gctl_length, + ggio.gctl_offset) == -1) { + error = errno; + } + break; + default: + error = EOPNOTSUPP; + } + + ggio.gctl_error = error; + g_gate_ioctl(G_GATE_CMD_DONE, &ggio); + } + +/* if ((r = asprintf(&uu_stack[uu_stack_idx++], "%s", map)) < 0) tc_log(1, "warning, asprintf failed. won't be able to " "unroll changes\n"); @@ -1185,15 +1338,15 @@ start = 0; sprintf(dev, "/dev/mapper/%s.%d", mapname, j); - g_gate_destroy(unit, force); /* was dm_task_destroy(dmt); */ - /*not needed in FreeBSD dm_task_update_nodes(); */ + /* was dm_task_destroy(dmt); + /*not needed in FreeBSD dm_task_update_nodes(); } out: /* * If an error occured, try to unroll changes made before it * happened. - */ + if (ret) { j = uu_stack_idx; while (j > 0) { @@ -1209,7 +1362,7 @@ } } } - +*/ while (uu_stack_idx > 0) free(uu_stack[--uu_stack_idx]); From owner-svn-soc-all@FreeBSD.ORG Thu Jul 12 17:12:18 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 6C2F2106564A for ; Thu, 12 Jul 2012 17:12:17 +0000 (UTC) (envelope-from exxo@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Thu, 12 Jul 2012 17:12:17 +0000 Date: Thu, 12 Jul 2012 17:12:17 +0000 From: exxo@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120712171217.6C2F2106564A@hub.freebsd.org> Cc: Subject: socsvn commit: r239313 - soc2012/exxo/patches X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Jul 2012 17:12:18 -0000 Author: exxo Date: Thu Jul 12 17:12:16 2012 New Revision: 239313 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239313 Log: Provide quota patch Added: soc2012/exxo/patches/quota.patch Added: soc2012/exxo/patches/quota.patch ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/exxo/patches/quota.patch Thu Jul 12 17:12:16 2012 (r239313) @@ -0,0 +1,36 @@ +Index: freebsd-head/usr.bin/quota/quota.c +=================================================================== +--- freebsd-head/usr.bin/quota/quota.c (revision 239276) ++++ freebsd-head/usr.bin/quota/quota.c (working copy) +@@ -657,28 +657,17 @@ static int + callaurpc(char *host, int prognum, int versnum, int procnum, + xdrproc_t inproc, char *in, xdrproc_t outproc, char *out) + { +- struct sockaddr_in server_addr; + enum clnt_stat clnt_stat; +- struct hostent *hp; + struct timeval timeout, tottimeout; + + CLIENT *client = NULL; +- int sock = RPC_ANYSOCK; + +- if ((hp = gethostbyname(host)) == NULL) +- return ((int) RPC_UNKNOWNHOST); + timeout.tv_usec = 0; + timeout.tv_sec = 6; +- bcopy(hp->h_addr, &server_addr.sin_addr, +- MIN(hp->h_length,(int)sizeof(server_addr.sin_addr))); +- server_addr.sin_family = AF_INET; +- server_addr.sin_port = 0; ++ if ((client = clnt_create_timed(host, prognum, ++ versnum, "udp", &timeout)) == NULL) + +- if ((client = clntudp_create(&server_addr, prognum, +- versnum, timeout, &sock)) == NULL) +- return ((int) rpc_createerr.cf_stat); +- +- client->cl_auth = authunix_create_default(); ++ client->cl_auth = authsys_create_default(); + tottimeout.tv_sec = 25; + tottimeout.tv_usec = 0; + clnt_stat = clnt_call(client, procnum, inproc, in, From owner-svn-soc-all@FreeBSD.ORG Thu Jul 12 23:01:53 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 9936B106564A for ; Thu, 12 Jul 2012 23:01:51 +0000 (UTC) (envelope-from vchan@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Thu, 12 Jul 2012 23:01:51 +0000 Date: Thu, 12 Jul 2012 23:01:51 +0000 From: vchan@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120712230151.9936B106564A@hub.freebsd.org> Cc: Subject: socsvn commit: r239322 - soc2012/vchan/gtcp/bwalex-tc-play X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Jul 2012 23:01:53 -0000 Author: vchan Date: Thu Jul 12 23:01:51 2012 New Revision: 239322 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239322 Log: it COMPILES...well mostly Modified: soc2012/vchan/gtcp/bwalex-tc-play/Makefile soc2012/vchan/gtcp/bwalex-tc-play/io.c soc2012/vchan/gtcp/bwalex-tc-play/main.c soc2012/vchan/gtcp/bwalex-tc-play/tcplay.c soc2012/vchan/gtcp/bwalex-tc-play/tcplay.h Modified: soc2012/vchan/gtcp/bwalex-tc-play/Makefile ============================================================================== --- soc2012/vchan/gtcp/bwalex-tc-play/Makefile Thu Jul 12 22:55:48 2012 (r239321) +++ soc2012/vchan/gtcp/bwalex-tc-play/Makefile Thu Jul 12 23:01:51 2012 (r239322) @@ -30,8 +30,8 @@ endif - LIBS+= -lcrypto -ldm -lprop - SRCS+= crypto-dev.c + LIBS+= -lcrypto -lgeom -lutil -lsbuf + SRCS+= crypto-dev.c ggate.c OBJS+= crypto-dev.o SRCS+= pbkdf2-openssl.c OBJS+= pbkdf2-openssl.o Modified: soc2012/vchan/gtcp/bwalex-tc-play/io.c ============================================================================== --- soc2012/vchan/gtcp/bwalex-tc-play/io.c Thu Jul 12 22:55:48 2012 (r239321) +++ soc2012/vchan/gtcp/bwalex-tc-play/io.c Thu Jul 12 23:01:51 2012 (r239322) @@ -39,6 +39,7 @@ #include #include #include +#include #include "tcplay.h" Modified: soc2012/vchan/gtcp/bwalex-tc-play/main.c ============================================================================== --- soc2012/vchan/gtcp/bwalex-tc-play/main.c Thu Jul 12 22:55:48 2012 (r239321) +++ soc2012/vchan/gtcp/bwalex-tc-play/main.c Thu Jul 12 23:01:51 2012 (r239322) @@ -278,7 +278,7 @@ /* Create a new volume */ if (create_vol) { - error = create_volume(dev, contain_hidden, keyfiles, nkeyfiles, + error = create_volume(map_name, dev, contain_hidden, keyfiles, nkeyfiles, h_keyfiles, n_hkeyfiles, prf, cipher_chain, h_prf, h_cipher_chain, NULL, NULL, 0, 1 /* interactive */, @@ -287,7 +287,7 @@ tc_log(1, "could not create new volume on %s\n", dev); } } else if (info_vol) { - error = info_volume(dev, sflag, sys_dev, protect_hidden, + error = info_volume(map_name, dev, sflag, sys_dev, protect_hidden, keyfiles, nkeyfiles, h_keyfiles, n_hkeyfiles, NULL, NULL, 1 /* interactive */, DEFAULT_RETRIES, 0); } else if (map_vol) { Modified: soc2012/vchan/gtcp/bwalex-tc-play/tcplay.c ============================================================================== --- soc2012/vchan/gtcp/bwalex-tc-play/tcplay.c Thu Jul 12 22:55:48 2012 (r239321) +++ soc2012/vchan/gtcp/bwalex-tc-play/tcplay.c Thu Jul 12 23:01:51 2012 (r239322) @@ -85,6 +85,18 @@ static int unit = G_GATE_UNIT_AUTO; static int force = 0; static unsigned sectorsize = 0; +static unsigned flags = 0; + +static int +g_gate_openflags(unsigned ggflags) +{ + + if ((ggflags & G_GATE_FLAG_READONLY) != 0) + return (O_RDONLY); + else if ((ggflags & G_GATE_FLAG_WRITEONLY) != 0) + return (O_WRONLY); + return (O_RDWR); +} void tc_log(int is_err, const char *fmt, ...) @@ -402,7 +414,7 @@ } int -create_volume(const char *dev, int hidden, const char *keyfiles[], int nkeyfiles, +create_volume(const char *map_name, const char *dev, int hidden, const char *keyfiles[], int nkeyfiles, const char *h_keyfiles[], int n_hkeyfiles, struct pbkdf_prf_algo *prf_algo, struct tc_cipher_chain *cipher_chain, struct pbkdf_prf_algo *h_prf_algo, struct tc_cipher_chain *h_cipher_chain, char *passphrase, @@ -417,7 +429,8 @@ struct tchdr_enc *ehdr_backup, *hehdr_backup; uint64_t tmp; int error, r, ret; - + int fd; + pass = h_pass = pass_again = NULL; ehdr = hehdr = NULL; ehdr_backup = hehdr_backup = NULL; @@ -431,11 +444,12 @@ h_cipher_chain = cipher_chain; if (h_prf_algo == NULL) h_prf_algo = prf_algo; - - if ((error = get_disk_info(dev, &blocks, &blksz)) != 0) { - tc_log(1, "could not get disk info\n"); - return -1; - } + + fd = open(map_name, g_gate_openflags(flags)); + blksz = g_gate_sectorsize(fd); + blocks = g_gate_mediasize(fd)/blksz; + + if ((blocks*blksz) <= MIN_VOL_BYTES) { tc_log(1, "Cannot create volumes on devices with less " @@ -705,7 +719,7 @@ static struct tcplay_info * -info_map_common(const char *dev, int sflag, const char *sys_dev, +info_map_common(const char *map_name, const char *dev, int sflag, const char *sys_dev, int protect_hidden, const char *keyfiles[], int nkeyfiles, const char *h_keyfiles[], int n_hkeyfiles, char *passphrase, char *passphrase_hidden, int interactive, int retries, time_t timeout) @@ -717,8 +731,13 @@ int error, error2 = 0; size_t sz; size_t blocks, blksz; - - if ((error = get_disk_info(dev, &blocks, &blksz)) != 0) { + int fd; + + fd = open(map_name, g_gate_openflags(flags)); + blksz = g_gate_sectorsize(fd); + blocks = g_gate_mediasize(fd)/blksz; + + if (blksz == 0) { tc_log(1, "could not get disk information\n"); return NULL; } @@ -915,7 +934,7 @@ } int -info_volume(const char *device, int sflag, const char *sys_dev, +info_volume(const char *map_name, const char *device, int sflag, const char *sys_dev, int protect_hidden, const char *keyfiles[], int nkeyfiles, const char *h_keyfiles[], int n_hkeyfiles, char *passphrase, char *passphrase_hidden, int interactive, int retries, @@ -923,7 +942,7 @@ { struct tcplay_info *info; - info = info_map_common(device, sflag, sys_dev, protect_hidden, + info = info_map_common(map_name, device, sflag, sys_dev, protect_hidden, keyfiles, nkeyfiles, h_keyfiles, n_hkeyfiles, passphrase, passphrase_hidden, interactive, retries, timeout); @@ -940,97 +959,6 @@ return -1; } -/* not correct yet -int -map_volume(int fd, int interactive) -{ - - struct g_gate_ctl_io ggio; - size_t bsize; - - if (g_gate_verbose == 0) { - if (daemon(0, 0) == -1) { - g_gate_destroy(unit, 1); - err(EXIT_FAILURE, "Cannot daemonize"); - } - } - g_gate_log(LOG_DEBUG, "Worker created: %u.", getpid()); - ggio.gctl_version = G_GATE_VERSION; - ggio.gctl_unit = unit; - bsize = sectorsize; - ggio.gctl_data = malloc(bsize); - for (;;) { - int error; -once_again: - ggio.gctl_length = bsize; - ggio.gctl_error = 0; - g_gate_ioctl(G_GATE_CMD_START, &ggio); - error = ggio.gctl_error; - switch (error) { - case 0: - break; - case ECANCELED: - /* Exit gracefully. - free(ggio.gctl_data); - g_gate_close_device(); - close(fd); - exit(EXIT_SUCCESS); - case ENOMEM: - /* Buffer too small. - assert(ggio.gctl_cmd == BIO_DELETE || - ggio.gctl_cmd == BIO_WRITE); - ggio.gctl_data = realloc(ggio.gctl_data, - ggio.gctl_length); - if (ggio.gctl_data != NULL) { - bsize = ggio.gctl_length; - goto once_again; - } - /* FALLTHROUGH - case ENXIO: - default: - g_gate_xlog("ioctl(/dev/%s): %s.", G_GATE_CTL_NAME, - strerror(error)); - } - - error = 0; - switch (ggio.gctl_cmd) { - case BIO_READ: - if ((size_t)ggio.gctl_length > bsize) { - ggio.gctl_data = realloc(ggio.gctl_data, - ggio.gctl_length); - if (ggio.gctl_data != NULL) - bsize = ggio.gctl_length; - else - error = ENOMEM; - } - if (error == 0) { - if (pread(fd, ggio.gctl_data, ggio.gctl_length, - ggio.gctl_offset) == -1) { - error = errno; - } - } - break; - case BIO_DELETE: - case BIO_WRITE: - if (pwrite(fd, ggio.gctl_data, ggio.gctl_length, - ggio.gctl_offset) == -1) { - error = errno; - } - break; - default: - error = EOPNOTSUPP; - } - - ggio.gctl_error = error; - g_gate_ioctl(G_GATE_CMD_DONE, &ggio); - } - - - if (interactive) - printf("All ok!\n"); - - return 0; -}*/ int map_volume(const char *map_name, const char *device, int sflag, @@ -1042,16 +970,15 @@ { struct tcplay_info *info; int error; - int fd; - info = info_map_common(device, sflag, sys_dev, protect_hidden, + info = info_map_common(map_name, device, sflag, sys_dev, protect_hidden, keyfiles, nkeyfiles, h_keyfiles, n_hkeyfiles, passphrase, passphrase_hidden, interactive, retries, timeout); if (info == NULL) return -1; - if ((error = dm_setup(fd, info)) != 0) { + if ((error = dm_setup(map_name, info)) != 0) { tc_log(1, "Could not set up mapping %s\n", map_name); if (info->hdr) free_safe_mem(info->hdr); @@ -1070,7 +997,7 @@ static int -dm_remove_device() +dm_remove_device(void) { int ret = EINVAL; @@ -1084,55 +1011,24 @@ g_gate_open_device(); g_gate_destroy(unit, force); -/* -static -int -dm_remove_device(const char *name) -{ - struct dm_task *dmt = NULL; - int ret = EINVAL; - - if ((dmt = dm_task_create(DM_DEVICE_REMOVE)) == NULL) - goto out; - - if ((dm_task_set_name(dmt, name)) == 0) - goto out; - - if ((dm_task_run(dmt)) == 0) - goto out; - - ret = 0; -out: - if (dmt) - dm_task_destroy(dmt); -*/ return ret; } int -dm_setup(int fd, struct tcplay_info *info) +dm_setup(const char *map_name, struct tcplay_info *info) { - /* Commented out variables not needed in freeBSD*/ struct tc_cipher_chain *cipher_chain; -// struct dm_task *dmt = NULL; -// struct dm_info dmi; - char *params = NULL; -// char *uu; - char *uu_stack[64]; - int uu_stack_idx; -/*#if defined(__DragonFly__) - uint32_t status; -#endif*/ - int r, ret = 0; + int ret = 0; int j; + int fd; off_t start, offset; char dev[PATH_MAX]; - char map[PATH_MAX]; + char *params = NULL; uint32_t cookie; - - /* dm_udev_set_sync_support(1); */ + fd = open(map_name, g_gate_openflags(flags) | O_DIRECT | O_FSYNC); + if ((params = alloc_safe_mem(512)) == NULL) { tc_log(1, "could not allocate safe parameters memory"); return ENOMEM; @@ -1141,7 +1037,6 @@ strcpy(dev, info->dev); start = info->start; offset = info->offset; - uu_stack_idx = 0; /* Get to the end of the chain */ for (cipher_chain = info->cipher_chain; cipher_chain->next != NULL; @@ -1152,7 +1047,6 @@ cipher_chain = cipher_chain->prev, j++) { cookie = 0; - //force = 1; used in g_gate_destroy /* aes-cbc-essiv:sha256 7997f8af... 0 /dev/ad0s0a 8 */ /* iv off---^ block off--^ */ @@ -1162,91 +1056,7 @@ #ifdef DEBUG printf("Params: %s\n", params); #endif - /* - if ((dmt = dm_task_create(DM_DEVICE_CREATE)) == NULL) { - tc_log(1, "dm_task_create failed\n"); - ret = -1; - goto out; - } - */ - - /* - * If this is the last element in the cipher chain, use the - * final map name. Otherwise pick a secondary name... - - if (cipher_chain->prev == NULL) - strcpy(map, mapname); - else - sprintf(map, "%s.%d", mapname, j); - - /* changed from, "if ((dm_task_set_name(dmt, map)) == 0" - if (map == NULL) { - tc_log(1, "task_set_name failed\n"); - ret = -1; - goto out; - }*/ - -/*#if defined(__linux__) - uuid_generate(info->uuid); - if ((uu = malloc(1024)) == NULL) { - tc_log(1, "uuid_unparse memory failed\n"); - ret = -1; - goto out; - } - uuid_unparse(info->uuid, uu); -#elif defined(__DragonFly__) - uuid_create(&info->uuid, &status); - if (status != uuid_s_ok) { - tc_log(1, "uuid_create failed\n"); - ret = -1; - goto out; - } - - uuid_to_string(&info->uuid, &uu, &status); - if (uu == NULL) { - tc_log(1, "uuid_to_string failed\n"); - ret = -1; - goto out; - } -#endif - - if (( dm_task_set_uuid(dmt, uu)) == 0) { - free(uu); - tc_log(1, "dm_task_set_uuid failed\n"); - ret = -1; - goto out; - } - - free(uu); - - if (( dm_task_add_target(dmt, start, info->size, "crypt", params)) == 0) { - tc_log(1, "dm_task_add_target failed\n"); - ret = -1; - goto out; - } - - if ((dm_task_set_cookie(dmt, &cookie, 0)) == 0) { - tc_log(1, "dm_task_set_cookie failed\n"); - ret = -1; - goto out; - } - - if ((dm_task_run(dmt)) == 0) { - dm_udev_wait(cookie); - tc_log(1, "dm_task_run failed\n"); - ret = -1; - goto out; - } - - if ((dm_task_get_info(dmt, &dmi)) == 0) { - dm_udev_wait(cookie); - tc_log(1, "dm_task_get info failed\n"); - ret = -1; - goto out; - } - - dm_udev_wait(cookie); -*/ + } //FreeBSD struct g_gate_ctl_io ggio; @@ -1329,42 +1139,6 @@ g_gate_ioctl(G_GATE_CMD_DONE, &ggio); } -/* if ((r = asprintf(&uu_stack[uu_stack_idx++], "%s", map)) < 0) - tc_log(1, "warning, asprintf failed. won't be able to " - "unroll changes\n"); - - - offset = 0; - start = 0; - sprintf(dev, "/dev/mapper/%s.%d", mapname, j); - - /* was dm_task_destroy(dmt); - /*not needed in FreeBSD dm_task_update_nodes(); - } - -out: - /* - * If an error occured, try to unroll changes made before it - * happened. - - if (ret) { - j = uu_stack_idx; - while (j > 0) { -#ifdef DEBUG - printf("Unrolling dm changes! j = %d (%s)\n", j-1, - uu_stack[j-1]); -#endif - if ((uu_stack[j-1] == NULL) || - ((r = dm_remove_device(uu_stack[--j])) != 0)) { - tc_log(1, "Tried to unroll dm changes, " - "giving up.\n"); - break; - } - } - } -*/ - while (uu_stack_idx > 0) - free(uu_stack[--uu_stack_idx]); free_safe_mem(params); @@ -1374,14 +1148,11 @@ int dm_teardown(const char *mapname, const char *device __unused) { -#if 0 - struct dm_task *dmt = NULL; - struct dm_info dmi; -#endif + char map[PATH_MAX]; int i, error; - if ((error = dm_remove_device(mapname)) != 0) { + if ((error = dm_remove_device()) != 0) { tc_log(1, "Could not remove mapping %s\n", mapname); return error; } @@ -1389,7 +1160,7 @@ /* Try to remove other cascade devices */ for (i = 2; i >= 0; i--) { sprintf(map, "%s.%d", mapname, i); - dm_remove_device(map); + dm_remove_device(); } return 0; Modified: soc2012/vchan/gtcp/bwalex-tc-play/tcplay.h ============================================================================== --- soc2012/vchan/gtcp/bwalex-tc-play/tcplay.h Thu Jul 12 22:55:48 2012 (r239321) +++ soc2012/vchan/gtcp/bwalex-tc-play/tcplay.h Thu Jul 12 23:01:51 2012 (r239322) @@ -116,6 +116,7 @@ } __attribute__((__packed__)); struct tcplay_info { + const char *map_name; const char *dev; struct tchdr_dec *hdr; struct tc_cipher_chain *cipher_chain; @@ -185,13 +186,13 @@ int adjust_info(struct tcplay_info *info, struct tcplay_info *hinfo); int process_hdr(const char *dev, int sflag, unsigned char *pass, int passlen, struct tchdr_enc *ehdr, struct tcplay_info **pinfo); -int create_volume(const char *dev, int hidden, const char *keyfiles[], +int create_volume(const char *map_name, const char *dev, int hidden, const char *keyfiles[], int nkeyfiles, const char *h_keyfiles[], int n_hkeyfiles, struct pbkdf_prf_algo *prf_algo, struct tc_cipher_chain *cipher_chain, struct pbkdf_prf_algo *h_prf_algo, struct tc_cipher_chain *h_cipher_chain, char *passphrase, char *h_passphrase, size_t hidden_bytes_in, int interactive, int secure_erase); -int info_volume(const char *device, int sflag, const char *sys_dev, +int info_volume(const char *map_name, const char *device, int sflag, const char *sys_dev, int protect_hidden, const char *keyfiles[], int nkeyfiles, const char *h_keyfiles[], int n_hkeyfiles, char *passphrase, char *passphrase_hidden, int interactive, int retries, From owner-svn-soc-all@FreeBSD.ORG Fri Jul 13 00:54:55 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 2E5021065670 for ; Fri, 13 Jul 2012 00:54:53 +0000 (UTC) (envelope-from exxo@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Fri, 13 Jul 2012 00:54:53 +0000 Date: Fri, 13 Jul 2012 00:54:53 +0000 From: exxo@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120713005453.2E5021065670@hub.freebsd.org> Cc: Subject: socsvn commit: r239325 - soc2012/exxo/freebsd-head/usr.bin/newkey X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Jul 2012 00:54:55 -0000 Author: exxo Date: Fri Jul 13 00:54:52 2012 New Revision: 239325 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239325 Log: Fixing usr.bin/newkey Modified: soc2012/exxo/freebsd-head/usr.bin/newkey/newkey.c Modified: soc2012/exxo/freebsd-head/usr.bin/newkey/newkey.c ============================================================================== --- soc2012/exxo/freebsd-head/usr.bin/newkey/newkey.c Thu Jul 12 23:11:30 2012 (r239324) +++ soc2012/exxo/freebsd-head/usr.bin/newkey/newkey.c Fri Jul 13 00:54:52 2012 (r239325) @@ -125,13 +125,15 @@ (void)user2netname(name, (int)pw->pw_uid, (char *)NULL); } else { #ifdef undef - h = gethostbyname(argv[2]); + h = gethostbyname(argv[2]); /* If ever turned on, this needs to be IPv6 ready. */ if (h == NULL) errx(1, "unknown host: %s", argv[1]); - (void)host2netname(name, h->h_name, (char *)NULL); + status = host2netname(name, h->h_name, (char *)NULL); #else - (void)host2netname(name, argv[2], (char *)NULL); + status = host2netname(name, argv[2], (char *)NULL); #endif + if (status == FALSE) + errx(1, "unable to generate netname"); } (void)printf("Adding new key for %s.\n", name); From owner-svn-soc-all@FreeBSD.ORG Fri Jul 13 01:21:28 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 7FEA8106566C for ; Fri, 13 Jul 2012 01:21:27 +0000 (UTC) (envelope-from exxo@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Fri, 13 Jul 2012 01:21:27 +0000 Date: Fri, 13 Jul 2012 01:21:27 +0000 From: exxo@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120713012127.7FEA8106566C@hub.freebsd.org> Cc: Subject: socsvn commit: r239326 - in soc2012/exxo: . patches X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Jul 2012 01:21:28 -0000 Author: exxo Date: Fri Jul 13 01:21:25 2012 New Revision: 239326 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239326 Log: Adding newkey.patch and updating notes Added: soc2012/exxo/patches/newkey.patch Deleted: soc2012/exxo/patches/openssl-1.0.1c-getaddrinfo.patch Modified: soc2012/exxo/bugnotes.txt soc2012/exxo/softnotes.txt Modified: soc2012/exxo/bugnotes.txt ============================================================================== --- soc2012/exxo/bugnotes.txt Fri Jul 13 00:54:52 2012 (r239325) +++ soc2012/exxo/bugnotes.txt Fri Jul 13 01:21:25 2012 (r239326) @@ -12,3 +12,12 @@ WHERE b_sock.c:705 in BIO_get_accept_socket() DESCRIPTION requesting an IPv6 listening of an host without AAAA record fallback to IPv4 AFFECTS all hosts supporting IPv4 only + + + + + TYPE programming error + WHERE newkey.c:133 in main() + DESCRIPTION if host2netname() came to fail, the buff `name' is left uninitialized. + Thus it possibly leads to a sigsev when displayed at line 137. + AFFECTS * Added: soc2012/exxo/patches/newkey.patch ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/exxo/patches/newkey.patch Fri Jul 13 01:21:25 2012 (r239326) @@ -0,0 +1,23 @@ +Index: freebsd-head/usr.bin/newkey/newkey.c +=================================================================== +--- freebsd-head/usr.bin/newkey/newkey.c (revision 239313) ++++ freebsd-head/usr.bin/newkey/newkey.c (working copy) +@@ -125,13 +125,15 @@ main(int argc, char *argv[]) + (void)user2netname(name, (int)pw->pw_uid, (char *)NULL); + } else { + #ifdef undef +- h = gethostbyname(argv[2]); ++ h = gethostbyname(argv[2]); /* If ever turned on, this needs to be IPv6 ready. */ + if (h == NULL) + errx(1, "unknown host: %s", argv[1]); +- (void)host2netname(name, h->h_name, (char *)NULL); ++ status = host2netname(name, h->h_name, (char *)NULL); + #else +- (void)host2netname(name, argv[2], (char *)NULL); ++ status = host2netname(name, argv[2], (char *)NULL); + #endif ++ if (status == FALSE) ++ errx(1, "unable to generate netname"); + } + + (void)printf("Adding new key for %s.\n", name); Modified: soc2012/exxo/softnotes.txt ============================================================================== --- soc2012/exxo/softnotes.txt Fri Jul 13 00:54:52 2012 (r239325) +++ soc2012/exxo/softnotes.txt Fri Jul 13 01:21:25 2012 (r239326) @@ -1,15 +1,15 @@ openssl-1.0.1c FIXED (patch provided. Be aware of some TODO parts, Bio connect is not concerned by this patch) contrib/cvs FIXED (patch updated) usr.bin/who OK (software dependant, utmpx fixed it) -usr.bin/rusers -usr.bin/bluetooth usr.bin/systat FIXED (patch provided. systat now supports IPv6 when using ignore/display/show netstat commands) -usr.bin/rup -usr.bin/quota FIXED -usr.bin/newkey +usr.bin/quota FIXED (patch provided. quota should now work correctly on NFSv6 shares) +usr.bin/newkey OK (the address lookup is not used anymore) usr.bin/ypwhich usr.bin/getent usr.bin/talk +usr.bin/rusers +usr.bin/rup +usr.bin/bluetooth contrib/bsnmp contrib/amd contrib/ntp From owner-svn-soc-all@FreeBSD.ORG Fri Jul 13 05:33:56 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 18F6C106566B for ; Fri, 13 Jul 2012 05:33:54 +0000 (UTC) (envelope-from jhagewood@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Fri, 13 Jul 2012 05:33:54 +0000 Date: Fri, 13 Jul 2012 05:33:54 +0000 From: jhagewood@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120713053354.18F6C106566B@hub.freebsd.org> Cc: Subject: socsvn commit: r239330 - in soc2012/jhagewood: diff diff3 mdocml sdiff X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Jul 2012 05:33:56 -0000 Author: jhagewood Date: Fri Jul 13 05:33:53 2012 New Revision: 239330 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239330 Log: Modified: soc2012/jhagewood/diff/hagewood-diff.patch soc2012/jhagewood/diff3/hagewood-diff3.patch soc2012/jhagewood/mdocml/hagewood-mdocml-ns.patch soc2012/jhagewood/sdiff/hagewood-sdiff.patch Modified: soc2012/jhagewood/diff/hagewood-diff.patch ============================================================================== --- soc2012/jhagewood/diff/hagewood-diff.patch Fri Jul 13 04:22:08 2012 (r239329) +++ soc2012/jhagewood/diff/hagewood-diff.patch Fri Jul 13 05:33:53 2012 (r239330) @@ -1,6 +1,1589 @@ +diff -rupN jhagewood/diff/diff-orig/.svn/all-wcprops jhagewood/diff/diff/.svn/all-wcprops +--- jhagewood/diff/diff-orig/.svn/all-wcprops 2012-07-13 01:33:43.000000000 -0400 ++++ jhagewood/diff/diff/.svn/all-wcprops 2012-07-13 01:33:43.000000000 -0400 +@@ -1,59 +1,59 @@ + K 25 + svn:wc:ra_dav:version-url +-V 56 +-/socsvn/!svn/ver/238807/soc2012/jhagewood/diff/diff-orig ++V 51 ++/socsvn/!svn/ver/239048/soc2012/jhagewood/diff/diff + END + diff.1.gz + K 25 + svn:wc:ra_dav:version-url +-V 66 +-/socsvn/!svn/ver/238807/soc2012/jhagewood/diff/diff-orig/diff.1.gz ++V 61 ++/socsvn/!svn/ver/238807/soc2012/jhagewood/diff/diff/diff.1.gz + END + pathnames.h + K 25 + svn:wc:ra_dav:version-url +-V 68 +-/socsvn/!svn/ver/238807/soc2012/jhagewood/diff/diff-orig/pathnames.h ++V 63 ++/socsvn/!svn/ver/238807/soc2012/jhagewood/diff/diff/pathnames.h + END + diff.1 + K 25 + svn:wc:ra_dav:version-url +-V 63 +-/socsvn/!svn/ver/238807/soc2012/jhagewood/diff/diff-orig/diff.1 ++V 58 ++/socsvn/!svn/ver/238807/soc2012/jhagewood/diff/diff/diff.1 + END + diffreg.c + K 25 + svn:wc:ra_dav:version-url +-V 66 +-/socsvn/!svn/ver/238807/soc2012/jhagewood/diff/diff-orig/diffreg.c ++V 61 ++/socsvn/!svn/ver/239048/soc2012/jhagewood/diff/diff/diffreg.c + END + diff + K 25 + svn:wc:ra_dav:version-url +-V 61 +-/socsvn/!svn/ver/238807/soc2012/jhagewood/diff/diff-orig/diff ++V 56 ++/socsvn/!svn/ver/238807/soc2012/jhagewood/diff/diff/diff + END + diffdir.c + K 25 + svn:wc:ra_dav:version-url +-V 66 +-/socsvn/!svn/ver/238807/soc2012/jhagewood/diff/diff-orig/diffdir.c ++V 61 ++/socsvn/!svn/ver/238807/soc2012/jhagewood/diff/diff/diffdir.c + END + diff.c + K 25 + svn:wc:ra_dav:version-url +-V 63 +-/socsvn/!svn/ver/238807/soc2012/jhagewood/diff/diff-orig/diff.c ++V 58 ++/socsvn/!svn/ver/239007/soc2012/jhagewood/diff/diff/diff.c + END + Makefile + K 25 + svn:wc:ra_dav:version-url +-V 65 +-/socsvn/!svn/ver/238807/soc2012/jhagewood/diff/diff-orig/Makefile ++V 60 ++/socsvn/!svn/ver/238807/soc2012/jhagewood/diff/diff/Makefile + END + diff.h + K 25 + svn:wc:ra_dav:version-url +-V 63 +-/socsvn/!svn/ver/238807/soc2012/jhagewood/diff/diff-orig/diff.h ++V 58 ++/socsvn/!svn/ver/238807/soc2012/jhagewood/diff/diff/diff.h + END +diff -rupN jhagewood/diff/diff-orig/.svn/entries jhagewood/diff/diff/.svn/entries +--- jhagewood/diff/diff-orig/.svn/entries 2012-07-13 01:33:43.000000000 -0400 ++++ jhagewood/diff/diff/.svn/entries 2012-07-13 01:33:43.000000000 -0400 +@@ -2,13 +2,13 @@ + + dir + 239329 +-https://socsvn.freebsd.org/socsvn/soc2012/jhagewood/diff/diff-orig ++https://socsvn.freebsd.org/socsvn/soc2012/jhagewood/diff/diff + https://socsvn.freebsd.org/socsvn + + + +-2012-07-02T14:59:21.494992Z +-238807 ++2012-07-06T17:31:27.428691Z ++239048 + jhagewood + + +@@ -67,7 +67,7 @@ file + + + 2012-07-13T05:33:43.000000Z +-5a0333c769b4cd0b56d0183979c3c3da ++02e0e4002578433745dc1989cde68db3 + 2012-07-02T14:59:21.494992Z + 238807 + jhagewood +@@ -92,7 +92,7 @@ jhagewood + + + +-1173 ++1208 + + diff.1 + file +@@ -135,9 +135,9 @@ file + + + 2012-07-13T05:33:43.000000Z +-41390d52e706fd5ff89e5139b1a3992a +-2012-07-02T14:59:21.494992Z +-238807 ++360e792dce77ba35267246e878158613 ++2012-07-06T17:31:27.428691Z ++239048 + jhagewood + + +@@ -160,7 +160,7 @@ jhagewood + + + +-38935 ++40791 + + diff + file +@@ -203,7 +203,7 @@ file + + + 2012-07-13T05:33:43.000000Z +-28bd85291f636c13f457cda2ec9e2168 ++44a983d6f3f06103b3210dc9799dc9aa + 2012-07-02T14:59:21.494992Z + 238807 + jhagewood +@@ -228,7 +228,7 @@ jhagewood + + + +-8385 ++8360 + + diff.c + file +@@ -237,9 +237,9 @@ file + + + 2012-07-13T05:33:43.000000Z +-5c74db6e58594c5d345aa050fcda44ae +-2012-07-02T14:59:21.494992Z +-238807 ++060bb447cdcbd060f328603bc0595a90 ++2012-07-05T18:13:06.636166Z ++239007 + jhagewood + + +@@ -262,7 +262,7 @@ jhagewood + + + +-14455 ++18176 + + Makefile + file +@@ -305,7 +305,7 @@ file + + + 2012-07-13T05:33:43.000000Z +-eab9e28aee9d963655a25372ef2f2657 ++f389a5742640cda8b39f75a4cda31197 + 2012-07-02T14:59:21.494992Z + 238807 + jhagewood +@@ -330,5 +330,5 @@ jhagewood + + + +-3738 ++3852 + +diff -rupN jhagewood/diff/diff-orig/.svn/text-base/diff.c.svn-base jhagewood/diff/diff/.svn/text-base/diff.c.svn-base +--- jhagewood/diff/diff-orig/.svn/text-base/diff.c.svn-base 2012-07-13 01:33:43.000000000 -0400 ++++ jhagewood/diff/diff/.svn/text-base/diff.c.svn-base 2012-07-13 01:33:43.000000000 -0400 +@@ -1,4 +1,4 @@ +-/*- ++/* + * Copyright (c) 2003 Todd C. Miller + * + * Permission to use, copy, modify, and distribute this software for any +@@ -18,15 +18,13 @@ + * Materiel Command, USAF, under agreement number F39502-99-1-0512. + */ + +-#include +- +-#ifndef lint + #if 0 +-__RCSID("$OpenBSD: diff.c,v 1.50 2007/05/29 18:24:56 ray Exp $"); +-#else +-__FBSDID("$FreeBSD$"); ++#ifndef lint ++static char sccsid[] = "@(#)diff.c 8.1 (Berkeley) 6/6/93"; + #endif + #endif /* not lint */ ++#include ++__FBSDID("$FreeBSD$"); + + #include + #include +@@ -45,20 +43,20 @@ __FBSDID("$FreeBSD$"); + #include "diff.h" + #include "pathnames.h" + +-int aflag, bflag, dflag, iflag, lflag, Nflag, Pflag, pflag, rflag; +-int sflag, tflag, Tflag, wflag; +-int Bflag, yflag; +-int strip_cr, tabsize=8; +-char ignore_file_case = 0; +-int format, context, status; +-char *start, *ifdefname, *diffargs, *label[2], *ignore_pats; ++int aflag, bflag, cflag, dflag, Eflag, iflag, lflag, Nflag, Pflag, pflag, rflag; ++int sflag, tflag, Tflag, wflag, Toflag, Fromflag; ++int Bflag, yflag; ++int strip_cr, suppress_cl, tabsize = 8; ++char ignore_file_case = 0; ++int format, context, status; ++char *start, *ifdefname, *diffargs, *label[2], *ignore_pats, *line_format, *group_format; + struct stat stb1, stb2; + struct excludes *excludes_list; + regex_t ignore_re; + + int flag_opts = 0; + +-#define OPTIONS "0123456789aBbC:cdD:efhI:iL:lnNPpqrS:sTtU:uvwXy:x" ++#define OPTIONS "0123456789aBbC:cdD:EefhI:iL:lnNPpqrS:sTtU:uvwXy:x" + + + /* Options which exceed manageable alphanumeric assignments */ +@@ -69,84 +67,129 @@ enum + OPT_STRIPCR, + OPT_NORMAL, + OPT_LEFTC, +- OT_SUPCL, +- OPT_GTYPE, ++ OPT_SUPCL, ++ OPT_CHGD_GF, ++ OPT_NEW_GF, ++ OPT_OLD_GF, ++ OPT_UNCHGD_GF, + OPT_LF, + OPT_LLF, + OPT_TSIZE, +- OPT_UNINF, + OPT_FFILE, + OPT_TOFILE, + OPT_HLINES, + OPT_LFILES, + OPT_HELP, ++ OPT_NEW_LF, ++ OPT_OLD_LF, ++ OPT_UNCHGD_LF, + }; + + + static struct option longopts[] = { +-/* XXX: UNIMPLEMENTED +- { "normal", no_argument, NULL, OPT_NORMAL }, +- { "left-column", no_argument, NULL, OPT_LEFTC }, +- { "suppress-common-lines", no_argument, NULL, OT_SUPCL }, +- { "GTYPE-group-format", required_argument, NULL, OPT_GTYPE }, +- { "line-format", required_argument, NULL, OPT_LF }, +- { "LTYPE-line-format", required_argument, NULL, OPT_LLF }, +- { "unidirectional-new-file", no_argument, NULL, OPT_UNINF }, +- { "from-file", required_argument, NULL, OPT_FFILE }, +- { "to-file", required_argument, NULL, OPT_TOFILE }, +- { "horizon-lines", required_argument, NULL, OPT_HLINES }, +- { "speed-large-files", no_argument, NULL, OPT_LFILES }, */ +- { "tabsize", optional_argument, NULL, OPT_TSIZE }, +- { "strip-trailing-cr", no_argument, NULL, OPT_STRIPCR }, +- { "help", no_argument, NULL, OPT_HELP }, +- { "ignore-file-name-case", no_argument, NULL, OPT_IGN_FN_CASE }, +- { "no-ignore-file-name-case", no_argument, NULL, OPT_NIGN_FN_CASE }, +- { "text", no_argument, NULL, 'a' }, +-/* XXX: UNIMPLEMENTED */ +- { "ignore-blank-lines", no_argument, NULL, 'B' }, +- { "ignore-space-change", no_argument, NULL, 'b' }, +-/* XXX: -c is incompatible with GNU version */ ++ ++ /* ++ * Commented-out options are unimplemented. ++ */ ++ ++ { "brief", no_argument, NULL, 'q' }, ++ { "changed-group-format", required_argument, NULL, OPT_CHGD_GF}, + { "context", optional_argument, NULL, 'C' }, +- { "ifdef", required_argument, NULL, 'D' }, +- { "minimal", no_argument, NULL, 'd' }, +-/* XXX: UNIMPLEMENTED +- { "ignore-tab-expansion", no_argument, NULL, 'E' }, */ + { "ed", no_argument, NULL, 'e' }, +-/* XXX: UNIMPLEMENTED +- { "show-function-line", required_argument, NULL, 'F' }, */ ++ { "exclude", required_argument, NULL, 'x' }, ++ { "exclude-from", required_argument, NULL, 'X' }, ++ { "expand-tabs", no_argument, NULL, 't' }, ++ { "from-file", required_argument, NULL, OPT_FFILE }, + { "forward-ed", no_argument, NULL, 'f' }, ++ { "help", no_argument, NULL, OPT_HELP }, ++ /*{ "horizon-lines", required_argument, NULL, OPT_HLINES },*/ ++ { "ifdef", required_argument, NULL, 'D' }, ++ { "ignore-all-space", no_argument, NULL, 'W' }, ++ { "ignore-blank-lines", no_argument, NULL, 'B' }, ++ { "ignore-case", no_argument, NULL, 'i' }, ++ { "ignore-file-name-case", no_argument, NULL, OPT_IGN_FN_CASE }, + { "ignore-matching-lines", required_argument, NULL, 'I' }, +- { "ignore-case", no_argument, NULL, 'i' }, ++ { "ignore-space-change", no_argument, NULL, 'b' }, ++ { "ignore-tab-expansion", no_argument, NULL, 'E' }, ++ { "initial-tab", no_argument, NULL, 'T' }, + { "label", required_argument, NULL, 'L' }, +- { "paginate", no_argument, NULL, 'l' }, ++ { "left-column", no_argument, NULL, OPT_LEFTC }, ++ { "line-format", required_argument, NULL, OPT_LF }, ++ { "minimal", no_argument, NULL, 'd' }, + { "new-file", no_argument, NULL, 'N' }, +- { "rcs", no_argument, NULL, 'n' }, +- { "unidirectional-new-file", no_argument, NULL, 'P' }, +- { "show-c-function", no_argument, NULL, 'p' }, +- { "brief", no_argument, NULL, 'q' }, ++ { "new-line-format", required_argument, NULL, OPT_NEW_LF}, ++ { "new-group-format", required_argument, NULL, OPT_NEW_GF}, ++ { "no-ignore-file-name-case", no_argument, NULL, OPT_NIGN_FN_CASE }, ++ { "normal", no_argument, NULL, OPT_NORMAL }, ++ { "old-line-format", required_argument, NULL, OPT_OLD_LF}, ++ { "old-group-format", required_argument, NULL, OPT_OLD_GF}, ++ { "paginate", no_argument, NULL, 'l' }, + { "recursive", no_argument, NULL, 'r' }, +- { "starting-file", required_argument, NULL, 'S' }, + { "report-identical-files", no_argument, NULL, 's' }, +- { "initial-tab", no_argument, NULL, 'T' }, +- { "expand-tabs", no_argument, NULL, 't' }, +-/* XXX: -u is incompatible with GNU version */ ++ { "rcs", no_argument, NULL, 'n' }, ++ { "show-c-function", no_argument, NULL, 'p' }, ++ { "show-function-line", required_argument, NULL, 'F' }, ++ { "side-by-side", no_argument, NULL, 'y' }, ++ /*{ "speed-large-files", no_argument, NULL, OPT_LFILES }, */ ++ { "starting-file", required_argument, NULL, 'S' }, ++ { "strip-trailing-cr", no_argument, NULL, OPT_STRIPCR }, ++ { "suppress-common-lines", no_argument, NULL, OPT_SUPCL }, ++ { "tabsize", optional_argument, NULL, OPT_TSIZE }, ++ { "text", no_argument, NULL, 'a' }, ++ { "to-file", required_argument, NULL, OPT_TOFILE }, ++ { "unchanged-group-format", required_argument, NULL, OPT_UNCHGD_GF}, ++ { "unchanged-line-format", required_argument, NULL, OPT_UNCHGD_LF}, ++ { "unidirectional-new-file", no_argument, NULL, 'P' }, + { "unified", optional_argument, NULL, 'U' }, + { "version", no_argument, NULL, 'v' }, +-/* XXX: UNIMPLEMENTED +- { "width", optional_argument, NULL, 'W' }, */ +- { "ignore-all-space", no_argument, NULL, 'w' }, +- { "exclude-from", required_argument, NULL, 'X' }, +- { "exclude", required_argument, NULL, 'x' }, +- { "side-by-side", no_argument, NULL, 'y' }, ++ /*{ "width", optional_argument, NULL, 'w' }, */ + { NULL, 0, NULL, '\0'} + }; + + static const char *help_msg[] = { +-"-a --text treat files as ASCII text", +-"-B --ignore-blank-lines Ignore blank newlines in the comparison", +-"-b --ignore-space-change Ignore all changes due to whitespace", +-"-C NUM --context=[NUM] Show NUM lines before and after change (default 3)", +-"-D --ifdef=NAME", ++"\t-a --text treat files as ASCII text", ++"\t-B --ignore-blank-lines Ignore blank newlines in the comparison", ++"\t-b --ignore-space-change Ignore all changes due to whitespace", ++"\t-C -c NUM --context=NUM Show NUM lines before and after change (default 3)", ++"\t-D --ifdef=NAME Output merged file with `#ifdef NAME' diffs", ++"\t-E --ignore-tab-expansion Ignore tab expansion in the comparison", ++"\t-e --ed Output an ed script", ++"\t-F --show-function-line=RE Show the most recent line matching RE", ++"\t-f --forward-ed Output a forward ed script", ++"\t-I --ignore-matching-lines=RE Ignore changes whose lines all match RE", ++"\t-i --ignore-case Ignore case differences in file contents", ++"\t-L --label=NAME Label file header", ++"\t-l --paginate Paginates output through pr", ++"\t-N --new-file Treat new files as empty", ++"\t-n --rcs Output an RCS format diff", ++"\t-P --unidirectional-new-file Treat absent-first files as empty", ++"\t-p --show-c-function Show which C function each change is in", ++"\t-q --brief report only when files differ", ++"\t-r --recursive Recursively compare any sub-directories found", ++"\t-S --starting-file=FILE Start with FILE when comparing directories", ++"\t-s --report-identical-files Report when two files are the same", ++"\t-T --initial-tab Make tabs line up by prepending a tab", ++"\t-t --expand-tabs Expand tabs to spaces in output", ++"\t-U -u NUM --unified=NUM Show NUM lines of unified context", ++"\t-v --version Show diff version", ++"\t-W --ignore-all-space Ignore all space", ++"\t-w --width=NUM Output at most NUM (default 130) print columns", ++"\t-X --exclude-from=FILE Start with FILE when comparing directories", ++"\t-x --exclude=PAT Exclude files that match PAT", ++"\t-y --side-by-side Output difference in two columns", ++"\t--GTYPE-group-format=GFMT Format GTYPE input groups with GFMT", ++"\t--LTYPE-line-format=LFMT Format LTYPE input lines with LFMT", ++"\t--from-file=FILE Compare FILE to all operands", ++"\t--to-file=FILE Compare all operands to FILE", ++"\t--ignore-file-name-case Ignore file name case", ++"\t--left-column Output the only the left column of common lines", ++"\t--line-format=LFMT Format all input lines with LFMT", ++"\t--no-ignore-file-name-case Do not ignore file name case", ++"\t--normal Output a normal diff (default output)", ++"\t--strip-trailing-cr Strip trailing carriage return", ++"\t--suppress-common-lines Do not output common lines", ++"\t--tabsize=NUM Tab stops every NUM (default 8) print columns", ++"\t--help Output this help message", + NULL, + }; + char **help_strs = (char **)help_msg; +@@ -162,14 +205,15 @@ void read_excludes_file(char *); + int + main(int argc, char **argv) + { +- char *ep, **oargv; +- long l; +- int ch, lastch, gotstdin, prevoptind, newarg; +- int oargc; +- ++ char *ep, **oargv, *optfile; ++ long l; ++ int ch, lastch, gotstdin, prevoptind, newarg; ++ int oargc; ++ + oargv = argv; + oargc = argc; + gotstdin = 0; ++ optfile = "\0"; + + lastch = '\0'; + prevoptind = 1; +@@ -197,6 +241,7 @@ main(int argc, char **argv) + break; + case 'C': + case 'c': ++ cflag = 1; + format = D_CONTEXT; + if (optarg != NULL) { + l = strtol(optarg, &ep, 10); +@@ -213,6 +258,9 @@ main(int argc, char **argv) + case 'd': + dflag = 1; + break; ++ case 'E': ++ Eflag = 1; ++ break; + case 'e': + format = D_EDIT; + break; +@@ -284,7 +332,7 @@ main(int argc, char **argv) + case 'v': + printf("FreeBSD diff 2.8.7\n"); + exit(0); +- case 'w': ++ case 'W': + wflag = 1; + break; + case 'X': +@@ -296,15 +344,48 @@ main(int argc, char **argv) + case 'y': + yflag = 1; + break; ++ case OPT_FFILE: ++ Toflag = 1; ++ optfile = optarg; ++ break; ++ case OPT_TOFILE: ++ Fromflag = 1; ++ optfile = optarg; ++ break; ++ case OPT_CHGD_GF: ++ case OPT_NEW_GF: ++ case OPT_OLD_GF: ++ case OPT_UNCHGD_GF: ++ /* XXX To do: Complete --GTYPE-group-format. */ ++ format = D_GF; ++ group_format = optarg; ++ break; ++ case OPT_NEW_LF: ++ case OPT_OLD_LF: ++ case OPT_UNCHGD_LF: ++ case OPT_LF: ++ /* XXX To do: Complete --line-format. */ ++ format = D_LF; ++ line_format = optarg; ++ break; ++ case OPT_NORMAL: ++ format = D_NORMAL; ++ break; ++ case OPT_LEFTC: ++ /* Do nothing, passes option to sdiff. */ ++ break; ++ case OPT_SUPCL: ++ /* Do nothing, passes option to sdiff. */ ++ break; + case OPT_TSIZE: +- if (optarg != NULL) { +- l = strtol(optarg, &ep, 10); +- if (*ep != '\0' || l < 1 || l >= INT_MAX) +- usage(); +- tabsize = (int)l; +- } else +- tabsize = 8; +- break; ++ if (optarg != NULL) { ++ l = strtol(optarg, &ep, 10); ++ if (*ep != '\0' || l < 1 || l >= INT_MAX) ++ usage(); ++ tabsize = (int)l; ++ } else ++ tabsize = 8; ++ break; + case OPT_STRIPCR: + strip_cr=1; + break; +@@ -315,11 +396,10 @@ main(int argc, char **argv) + ignore_file_case = 0; + break; + case OPT_HELP: +- for(;*help_strs;help_strs++) +- { ++ for (; *help_strs; help_strs++) { + printf("%s\n", *help_strs); + } +- exit(2); ++ exit(0); + break; + default: + usage(); +@@ -328,20 +408,20 @@ main(int argc, char **argv) + lastch = ch; + newarg = optind != prevoptind; + prevoptind = optind; ++ + } + argc -= optind; + argv += optind; +- +- if(yflag) { ++ if (yflag) { + /* remove y flag from args and call sdiff */ +- for(argv=oargv; argv && strcmp(*argv, "-y") != 0; argv++); ++ for (argv = oargv; argv && strcmp(*argv, "-y") != 0 && ++ strcmp(*argv, "--side-by-side") != 0; argv++); + while(argv != &oargv[oargc]){ +- *argv=*(argv+1); ++ *argv= *(argv+1); + argv++; + } + oargv[0] = _PATH_SDIFF; + *argv= "\0"; +- + execv(_PATH_SDIFF, oargv); + _exit(127); + } +@@ -380,7 +460,10 @@ main(int argc, char **argv) + set_argstr(oargv, argv); + if (S_ISDIR(stb1.st_mode) && S_ISDIR(stb2.st_mode)) { + if (format == D_IFDEF) +- errx(2, "-D option not supported with directories"); ++ if (ch == 'D') ++ errx(2, "-D option not supported with directories"); ++ if (ch == OPT_LF) ++ errx(2, "--line-format option not supported with directories"); + diffdir(argv[0], argv[1]); + } else { + if (S_ISDIR(stb1.st_mode)) { +@@ -393,8 +476,26 @@ main(int argc, char **argv) + if (stat(argv[1], &stb2) < 0) + err(2, "%s", argv[1]); + } +- print_status(diffreg(argv[0], argv[1], 0), argv[0], argv[1], +- NULL); ++ /* Checks if --to-file or --from-file are specified */ ++ if (Toflag && Fromflag) { ++ (void)fprintf(stderr, "--from-file and --to-file both specified.\n"); ++ exit(2); ++ } ++ if (Toflag) { ++ print_status(diffreg(optfile, argv[0], 0), optfile, argv[0], ++ NULL); ++ print_status(diffreg(optfile, argv[1], 0), optfile, argv[1], ++ NULL); ++ } ++ if (Fromflag) { ++ print_status(diffreg(argv[0], optfile, 0), argv[0], optfile, ++ NULL); ++ print_status(diffreg(argv[1], optfile, 0), argv[1], optfile, ++ NULL); ++ } ++ if (!Toflag && !Fromflag) ++ print_status(diffreg(argv[0], argv[1], 0), argv[0], argv[1], ++ NULL); + } + exit(status); + } +@@ -402,11 +503,10 @@ main(int argc, char **argv) + void * + emalloc(size_t n) + { +- void *p; ++ void *p; + + if (n == 0) + errx(2, NULL); +- + if ((p = malloc(n)) == NULL) + errx(2, NULL); + return (p); +@@ -415,7 +515,7 @@ emalloc(size_t n) + void * + erealloc(void *p, size_t n) + { +- void *q; ++ void *q; + + if (n == 0) + errx(2, NULL); +@@ -431,13 +531,12 @@ erealloc(void *p, size_t n) + int + easprintf(char **ret, const char *fmt, ...) + { +- int len; +- va_list ap; ++ int len; ++ va_list ap; + + va_start(ap, fmt); + len = vasprintf(ret, fmt, ap); + va_end(ap); +- + if (len < 0 || *ret == NULL) + errx(2, NULL); + return (len); +@@ -446,11 +545,12 @@ easprintf(char **ret, const char *fmt, . + char * + estrdup(const char *str) + { +- size_t len; +- char *cp; ++ size_t len; ++ char *cp; + + len = strlen(str) + 1; + cp = emalloc(len); ++ + strlcpy(cp, str, len); + return (cp); + } +@@ -531,6 +631,7 @@ push_ignore_pats(char *pattern) + void + print_only(const char *path, size_t dirlen, const char *entry) + { ++ + if (dirlen > 1) + dirlen--; + printf("Only in %.*s: %s\n", (int)dirlen, path, entry); +@@ -539,45 +640,46 @@ print_only(const char *path, size_t dirl + void + print_status(int val, char *path1, char *path2, char *entry) + { ++ + switch (val) { + case D_ONLY: + print_only(path1, strlen(path1), entry); + break; + case D_COMMON: + printf("Common subdirectories: %s%s and %s%s\n", +- path1, entry ? entry : "", path2, entry ? entry : ""); ++ path1, entry ? entry : "", path2, entry ? entry : ""); + break; + case D_BINARY: +- printf("Binary files %s%s and %s%s differ\n", +- path1, entry ? entry : "", path2, entry ? entry : ""); ++ printf("Files %s%s and %s%s differ\n", ++ path1, entry ? entry : "", path2, entry ? entry : ""); + break; + case D_DIFFER: + if (format == D_BRIEF) + printf("Files %s%s and %s%s differ\n", +- path1, entry ? entry : "", +- path2, entry ? entry : ""); ++ path1, entry ? entry : "", ++ path2, entry ? entry : ""); + break; + case D_SAME: + if (sflag) + printf("Files %s%s and %s%s are identical\n", +- path1, entry ? entry : "", +- path2, entry ? entry : ""); ++ path1, entry ? entry : "", ++ path2, entry ? entry : ""); + break; + case D_MISMATCH1: + printf("File %s%s is a directory while file %s%s is a regular file\n", +- path1, entry ? entry : "", path2, entry ? entry : ""); ++ path1, entry ? entry : "", path2, entry ? entry : ""); + break; + case D_MISMATCH2: + printf("File %s%s is a regular file while file %s%s is a directory\n", +- path1, entry ? entry : "", path2, entry ? entry : ""); ++ path1, entry ? entry : "", path2, entry ? entry : ""); + break; + case D_SKIPPED1: + printf("File %s%s is not a regular file or directory and was skipped\n", +- path1, entry ? entry : ""); ++ path1, entry ? entry : ""); + break; + case D_SKIPPED2: + printf("File %s%s is not a regular file or directory and was skipped\n", +- path2, entry ? entry : ""); ++ path2, entry ? entry : ""); + break; + } + } +@@ -585,6 +687,7 @@ print_status(int val, char *path1, char + void + usage(void) + { ++ + (void)fprintf(stderr, + "usage: diff [-abdilpqTtw] [-I pattern] [-c | -e | -f | -n | -u]\n" + " [-L label] file1 file2\n" +diff -rupN jhagewood/diff/diff-orig/.svn/text-base/diff.h.svn-base jhagewood/diff/diff/.svn/text-base/diff.h.svn-base +--- jhagewood/diff/diff-orig/.svn/text-base/diff.h.svn-base 2012-07-13 01:33:43.000000000 -0400 ++++ jhagewood/diff/diff/.svn/text-base/diff.h.svn-base 2012-07-13 01:33:43.000000000 -0400 +@@ -48,6 +48,8 @@ + #define D_NREVERSE 5 /* Reverse ed script with numbered + lines and no trailing . */ + #define D_BRIEF 6 /* Say if the files differ */ ++#define D_GF 7 /* Group format */ ++#define D_LF 8 /* Line format */ + + /* + * Output flags +@@ -75,9 +77,9 @@ struct excludes { + struct excludes *next; + }; + +-extern int aflag, bflag, dflag, iflag, lflag, Nflag, Pflag, pflag, rflag, +- sflag, tflag, Tflag, wflag; +-extern int Bflag, strip_cr, tabsize; ++extern int aflag, bflag, cflag, dflag, Eflag, Fromflag, iflag, lflag, Nflag, Pflag, pflag, rflag, ++ sflag, tflag, Tflag, Toflag, wflag; ++extern int Bflag, strip_cr, suppress_cl, tabsize; + extern int format, context, status; + extern char ignore_file_case; + extern char *start, *ifdefname, *diffargs, *label[2], *ignore_pats; +diff -rupN jhagewood/diff/diff-orig/.svn/text-base/diffdir.c.svn-base jhagewood/diff/diff/.svn/text-base/diffdir.c.svn-base +--- jhagewood/diff/diff-orig/.svn/text-base/diffdir.c.svn-base 2012-07-13 01:33:43.000000000 -0400 ++++ jhagewood/diff/diff/.svn/text-base/diffdir.c.svn-base 2012-07-13 01:33:43.000000000 -0400 +@@ -20,14 +20,13 @@ + + #include + +-#ifndef lint + #if 0 +-__RCSID("$OpenBSD: diffdir.c,v 1.32 2007/06/09 05:16:21 ray Exp $"); +-#else +-__FBSDID("$FreeBSD$"); ++#ifndef lint ++static char sccsid[] = "@(#)diffdir.c 8.1 (Berkeley) 6/6/93"; + #endif + #endif /* not lint */ +- ++#include ++__FBSDID("$FreeBSD$"); + #include + #include + +@@ -57,12 +56,12 @@ static void diffit(struct dirent *, char + void + diffdir(char *p1, char *p2) + { +- struct dirent **dirp1, **dirp2, **dp1, **dp2; +- struct dirent *dent1, *dent2; +- size_t dirlen1, dirlen2; +- char path1[MAXPATHLEN], path2[MAXPATHLEN]; +- char *dirbuf1, *dirbuf2; +- int pos; ++ struct dirent **dirp1, **dirp2, **dp1, **dp2; ++ struct dirent *dent1, *dent2; ++ size_t dirlen1, dirlen2; ++ char path1[MAXPATHLEN], path2[MAXPATHLEN]; ++ char *dirbuf1, *dirbuf2; ++ int pos; + + dirlen1 = strlcpy(path1, *p1 ? p1 : ".", sizeof(path1)); + if (dirlen1 >= sizeof(path1) - 1) { +@@ -169,17 +168,16 @@ diffdir(char *p1, char *p2) + static struct dirent ** + slurpdir(char *path, char **bufp, int enoentok) + { +- char *buf, *ebuf, *cp; +- size_t bufsize, have, need; +- long base; +- int fd, nbytes, entries; +- struct stat sb; +- struct dirent **dirlist, *dp; ++ char *buf, *ebuf, *cp; ++ size_t bufsize, have, need; ++ long base; ++ int fd, nbytes, entries; ++ struct stat sb; ++ struct dirent **dirlist, *dp; + + *bufp = NULL; + if ((fd = open(path, O_RDONLY, 0644)) == -1) { + static struct dirent *dummy; +- + if (!enoentok || errno != ENOENT) { + warn("%s", path); + return (NULL); +@@ -191,19 +189,17 @@ slurpdir(char *path, char **bufp, int en + close(fd); + return (NULL); + } +- + need = roundup(sb.st_blksize, sizeof(struct dirent)); + have = bufsize = roundup(MAX(sb.st_size, sb.st_blksize), + sizeof(struct dirent)) + need; + ebuf = buf = emalloc(bufsize); +- + do { + if (have < need) { +- bufsize += need; +- have += need; +- cp = erealloc(buf, bufsize); +- ebuf = cp + (ebuf - buf); +- buf = cp; ++ bufsize += need; ++ have += need; ++ cp = erealloc(buf, bufsize); ++ ebuf = cp + (ebuf - buf); ++ buf = cp; + } + nbytes = getdirentries(fd, ebuf, have, &base); + if (nbytes == -1) { +@@ -255,8 +251,8 @@ slurpdir(char *path, char **bufp, int en + static int + dircompare(const void *vp1, const void *vp2) + { +- struct dirent *dp1 = *((struct dirent **) vp1); +- struct dirent *dp2 = *((struct dirent **) vp2); ++ struct dirent *dp1 = *((struct dirent **) vp1); ++ struct dirent *dp2 = *((struct dirent **) vp2); + + return (strcmp(dp1->d_name, dp2->d_name)); + } +@@ -267,7 +263,7 @@ dircompare(const void *vp1, const void * + static void + diffit(struct dirent *dp, char *path1, size_t plen1, char *path2, size_t plen2) + { +- int flags = D_HEADER; ++ int flags = D_HEADER; + + strlcpy(path1 + plen1, dp->d_name, MAXPATHLEN - plen1); + if (stat(path1, &stb1) != 0) { +diff -rupN jhagewood/diff/diff-orig/.svn/text-base/diffreg.c.svn-base jhagewood/diff/diff/.svn/text-base/diffreg.c.svn-base +--- jhagewood/diff/diff-orig/.svn/text-base/diffreg.c.svn-base 2012-07-13 01:33:43.000000000 -0400 ++++ jhagewood/diff/diff/.svn/text-base/diffreg.c.svn-base 2012-07-13 01:33:43.000000000 -0400 +@@ -62,15 +62,13 @@ + * @(#)diffreg.c 8.1 (Berkeley) 6/6/93 + */ + +-#include +- +-#ifndef lint + #if 0 +-__RCSID("$OpenBSD: diffreg.c,v 1.70 2007/09/11 15:47:17 gilles Exp $"); +-#else +-__FBSDID("$FreeBSD"); ++#ifndef lint ++static char sccsid[] = "@(#)diffreg.c 8.1 (Berkeley) 6/6/93"; + #endif + #endif /* not lint */ ++#include ++__FBSDID("$FreeBSD$"); + + #include + #include +@@ -90,6 +88,14 @@ __FBSDID("$FreeBSD"); + #include "diff.h" + #include "pathnames.h" + ++#ifdef ST_MTIM_NSEC ++# define TIMESPEC_NS(timespec) ((timespec).ST_MTIM_NSEC) ++#else ++# define TIMESPEC_NS(timespec) 0 ++#endif ++ ++#define MAX_CHECK 768 ++ + /* + * diff - compare two files. + */ +@@ -196,7 +202,7 @@ static void change(char *, FILE *, char + static void sort(struct line *, int); + static void print_header(const char *, const char *); + static int ignoreline(char *); +-static int asciifile(FILE *); ++static int istextfile(FILE *); + static int fetch(long *, int, int, FILE *, int, int); + static int newcand(int, int, int); + static int search(int *, int, int); +@@ -294,13 +300,13 @@ u_char cup2low[256] = { + int + diffreg(char *ofile1, char *ofile2, int flags) + { +- char *file1 = ofile1; +- char *file2 = ofile2; +- FILE *f1 = NULL; +- FILE *f2 = NULL; +- int rval = D_SAME; +- int i, ostdout = -1; +- pid_t pid = -1; ++ char *file1 = ofile1; ++ char *file2 = ofile2; ++ FILE *f1 = NULL; ++ FILE *f2 = NULL; ++ int rval = D_SAME; ++ int i, ostdout = -1; ++ pid_t pid = -1; + + anychange = 0; + lastline = 0; +@@ -353,7 +359,6 @@ diffreg(char *ofile1, char *ofile2, int + status |= 2; + goto closem; + } +- + switch (files_differ(f1, f2, flags)) { + case 0: + goto closem; +@@ -365,7 +370,7 @@ diffreg(char *ofile1, char *ofile2, int + goto closem; + } + +- if (!asciifile(f1) || !asciifile(f2)) { ++ if (!istextfile(f1) || !istextfile(f2)) { + rval = D_BINARY; + status |= 1; + goto closem; +@@ -477,8 +482,8 @@ closem: + static int + files_differ(FILE *f1, FILE *f2, int flags) + { +- char buf1[BUFSIZ], buf2[BUFSIZ]; +- size_t i, j; ++ char buf1[BUFSIZ], buf2[BUFSIZ]; ++ size_t i, j; + + if ((flags & (D_EMPTY1|D_EMPTY2)) || stb1.st_size != stb2.st_size || + (stb1.st_mode & S_IFMT) != (stb2.st_mode & S_IFMT)) +@@ -503,9 +508,9 @@ files_differ(FILE *f1, FILE *f2, int fla + static FILE * + opentemp(const char *file) + { +- char buf[BUFSIZ], *tempdir, tempfile[MAXPATHLEN]; +- ssize_t nread; +- int ifd, ofd; ++ char buf[BUFSIZ], *tempdir, tempfile[MAXPATHLEN]; ++ ssize_t nread; ++ int ifd, ofd; + + if (strcmp(file, "-") == 0) + ifd = STDIN_FILENO; +@@ -541,7 +546,7 @@ opentemp(const char *file) *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-soc-all@FreeBSD.ORG Fri Jul 13 06:39:12 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id AE581106564A for ; Fri, 13 Jul 2012 06:39:10 +0000 (UTC) (envelope-from vchan@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Fri, 13 Jul 2012 06:39:10 +0000 Date: Fri, 13 Jul 2012 06:39:10 +0000 From: vchan@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120713063910.AE581106564A@hub.freebsd.org> Cc: Subject: socsvn commit: r239331 - soc2012/vchan/gtcp/bwalex-tc-play X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Jul 2012 06:39:12 -0000 Author: vchan Date: Fri Jul 13 06:39:10 2012 New Revision: 239331 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239331 Log: all compiling and linking errors fixed Modified: soc2012/vchan/gtcp/bwalex-tc-play/Makefile soc2012/vchan/gtcp/bwalex-tc-play/main.c soc2012/vchan/gtcp/bwalex-tc-play/pbkdf2-openssl.c Modified: soc2012/vchan/gtcp/bwalex-tc-play/Makefile ============================================================================== --- soc2012/vchan/gtcp/bwalex-tc-play/Makefile Fri Jul 13 05:33:53 2012 (r239330) +++ soc2012/vchan/gtcp/bwalex-tc-play/Makefile Fri Jul 13 06:39:10 2012 (r239331) @@ -18,23 +18,23 @@ SRCS= tcplay.c crc32.c safe_mem.c io.c hdr.c humanize.c SRCS+= crypto.c generic_xts.c -OBJS= tcplay.o crc32.o safe_mem.o io.o hdr.o humanize.o -OBJS+= crypto.o generic_xts.o +OBJS= tcplay.o crc32.o safe_mem.o io.o hdr.o humanize.o +OBJS+= crypto.o generic_xts.o -CFLAGS+= $(WARNFLAGS) -I/usr/include -I/usr/local/include +CFLAGS+= $(WARNFLAGS) -I/usr/src/sbin/ggate/shared -I/usr/include -I/usr/local/include ifeq (${DEBUG}, yes) - CFLAGS+= -O0 -g -DDEBUG + CFLAGS+= -O0 -g -DDEBUG else - CFLAGS+= -O3 + CFLAGS+= -O3 endif - LIBS+= -lcrypto -lgeom -lutil -lsbuf - SRCS+= crypto-dev.c ggate.c - OBJS+= crypto-dev.o - SRCS+= pbkdf2-openssl.c - OBJS+= pbkdf2-openssl.o + LIBS+= -lcrypto -lgeom -lutil -lsbuf + SRCS+= crypto-dev.c /usr/src/sbin/ggate/shared/ggate.c + OBJS+= crypto-dev.o + SRCS+= pbkdf2-openssl.c + OBJS+= pbkdf2-openssl.o program: @@ -48,4 +48,3 @@ gcc -O0 -g -L./usr/home/monty/vchan/gtcp/bwal-tc-play/ -I. tcplay_api_test.c -ltcplay -lcrypto -ldm -lprop clean: rm -f tcplay libtcplay.so tcplay.core *.o ktrace.out - Modified: soc2012/vchan/gtcp/bwalex-tc-play/main.c ============================================================================== --- soc2012/vchan/gtcp/bwalex-tc-play/main.c Fri Jul 13 05:33:53 2012 (r239330) +++ soc2012/vchan/gtcp/bwalex-tc-play/main.c Fri Jul 13 06:39:10 2012 (r239331) @@ -37,6 +37,9 @@ #include #include +#include +#include + #include "tcplay.h" #ifndef SIGINFO @@ -278,6 +281,8 @@ /* Create a new volume */ if (create_vol) { + g_gate_load_module(); + g_gate_open_device(); error = create_volume(map_name, dev, contain_hidden, keyfiles, nkeyfiles, h_keyfiles, n_hkeyfiles, prf, cipher_chain, h_prf, h_cipher_chain, NULL, NULL, @@ -291,11 +296,14 @@ keyfiles, nkeyfiles, h_keyfiles, n_hkeyfiles, NULL, NULL, 1 /* interactive */, DEFAULT_RETRIES, 0); } else if (map_vol) { + g_gate_load_module(); + g_gate_open_device(); error = map_volume(map_name, dev, sflag, sys_dev, protect_hidden, keyfiles, nkeyfiles, h_keyfiles, n_hkeyfiles, NULL, NULL, 1 /* interactive */, DEFAULT_RETRIES, 0); } - + g_gate_close_device(); + exit(EXIT_SUCCESS); return error; } Modified: soc2012/vchan/gtcp/bwalex-tc-play/pbkdf2-openssl.c ============================================================================== --- soc2012/vchan/gtcp/bwalex-tc-play/pbkdf2-openssl.c Fri Jul 13 05:33:53 2012 (r239330) +++ soc2012/vchan/gtcp/bwalex-tc-play/pbkdf2-openssl.c Fri Jul 13 06:39:10 2012 (r239331) @@ -48,8 +48,8 @@ tc_log(1, "Hash %s not found\n", hash->name); return ENOENT; } - r = PKCS5_PBKDF2_HMAC(pass, passlen, salt, saltlen, - hash->iteration_count, md, keylen, out); + r = PKCS5_PBKDF2_HMAC_SHA1(pass, passlen, salt, saltlen, + hash->iteration_count, keylen, out); if (r == 0) { tc_log(1, "Error in PBKDF2\n"); From owner-svn-soc-all@FreeBSD.ORG Fri Jul 13 07:18:12 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 111D01065672 for ; Fri, 13 Jul 2012 07:18:10 +0000 (UTC) (envelope-from vchan@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Fri, 13 Jul 2012 07:18:10 +0000 Date: Fri, 13 Jul 2012 07:18:10 +0000 From: vchan@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120713071810.111D01065672@hub.freebsd.org> Cc: Subject: socsvn commit: r239333 - soc2012/vchan/gtcp/bwalex-tc-play X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Jul 2012 07:18:12 -0000 Author: vchan Date: Fri Jul 13 07:18:09 2012 New Revision: 239333 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239333 Log: map_name function no longer needed in main.c Modified: soc2012/vchan/gtcp/bwalex-tc-play/main.c soc2012/vchan/gtcp/bwalex-tc-play/tcplay.c soc2012/vchan/gtcp/bwalex-tc-play/tcplay.h Modified: soc2012/vchan/gtcp/bwalex-tc-play/main.c ============================================================================== --- soc2012/vchan/gtcp/bwalex-tc-play/main.c Fri Jul 13 06:46:09 2012 (r239332) +++ soc2012/vchan/gtcp/bwalex-tc-play/main.c Fri Jul 13 07:18:09 2012 (r239333) @@ -218,9 +218,10 @@ keyfiles[nkeyfiles++] = optarg; break; case 'm': - map_vol = 1; - map_name = optarg; - break; + //map_vol = 1; + //map_name = optarg; + fprintf(stderr, "--map no longer needed.\n--create now does the mapping.\n"); + break; case 's': sflag = 1; sys_dev = optarg; @@ -283,7 +284,7 @@ if (create_vol) { g_gate_load_module(); g_gate_open_device(); - error = create_volume(map_name, dev, contain_hidden, keyfiles, nkeyfiles, + error = create_volume(map_name, dev, sflag, sys_dev, protect_hidden, contain_hidden, keyfiles, nkeyfiles, h_keyfiles, n_hkeyfiles, prf, cipher_chain, h_prf, h_cipher_chain, NULL, NULL, 0, 1 /* interactive */, @@ -295,14 +296,14 @@ error = info_volume(map_name, dev, sflag, sys_dev, protect_hidden, keyfiles, nkeyfiles, h_keyfiles, n_hkeyfiles, NULL, NULL, 1 /* interactive */, DEFAULT_RETRIES, 0); - } else if (map_vol) { + } /*else if (map_vol) { g_gate_load_module(); g_gate_open_device(); error = map_volume(map_name, dev, sflag, sys_dev, protect_hidden, keyfiles, nkeyfiles, h_keyfiles, n_hkeyfiles, NULL, NULL, - 1 /* interactive */, DEFAULT_RETRIES, 0); - } + 1 (comment: interactive ), DEFAULT_RETRIES, 0); + }*/ g_gate_close_device(); exit(EXIT_SUCCESS); return error; Modified: soc2012/vchan/gtcp/bwalex-tc-play/tcplay.c ============================================================================== --- soc2012/vchan/gtcp/bwalex-tc-play/tcplay.c Fri Jul 13 06:46:09 2012 (r239332) +++ soc2012/vchan/gtcp/bwalex-tc-play/tcplay.c Fri Jul 13 07:18:09 2012 (r239333) @@ -414,7 +414,7 @@ } int -create_volume(const char *map_name, const char *dev, int hidden, const char *keyfiles[], int nkeyfiles, +create_volume(const char *map_name, const char *dev, int sflag, const char *sys_dev, int protect_hidden, int hidden, const char *keyfiles[], int nkeyfiles, const char *h_keyfiles[], int n_hkeyfiles, struct pbkdf_prf_algo *prf_algo, struct tc_cipher_chain *cipher_chain, struct pbkdf_prf_algo *h_prf_algo, struct tc_cipher_chain *h_cipher_chain, char *passphrase, @@ -456,6 +456,14 @@ "than %d bytes\n", MIN_VOL_BYTES); return -1; } + if (( error = map_volume(map_name, + dev, sflag, sys_dev, protect_hidden, + keyfiles, nkeyfiles, h_keyfiles, n_hkeyfiles, NULL, NULL, + 1 /* interactive */, DEFAULT_RETRIES, 0))) { + tc_log(1, "Failed to map volume\n"); + goto out; + } + if (interactive) { if (((pass = alloc_safe_mem(MAX_PASSSZ)) == NULL) || Modified: soc2012/vchan/gtcp/bwalex-tc-play/tcplay.h ============================================================================== --- soc2012/vchan/gtcp/bwalex-tc-play/tcplay.h Fri Jul 13 06:46:09 2012 (r239332) +++ soc2012/vchan/gtcp/bwalex-tc-play/tcplay.h Fri Jul 13 07:18:09 2012 (r239333) @@ -186,7 +186,7 @@ int adjust_info(struct tcplay_info *info, struct tcplay_info *hinfo); int process_hdr(const char *dev, int sflag, unsigned char *pass, int passlen, struct tchdr_enc *ehdr, struct tcplay_info **pinfo); -int create_volume(const char *map_name, const char *dev, int hidden, const char *keyfiles[], +int create_volume(const char *map_name, const char *dev, int sflag, const char *sys_dev, int protect_hidden, int hidden, const char *keyfiles[], int nkeyfiles, const char *h_keyfiles[], int n_hkeyfiles, struct pbkdf_prf_algo *prf_algo, struct tc_cipher_chain *cipher_chain, struct pbkdf_prf_algo *h_prf_algo, struct tc_cipher_chain *h_cipher_chain, From owner-svn-soc-all@FreeBSD.ORG Fri Jul 13 12:39:50 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 73956106564A for ; Fri, 13 Jul 2012 12:39:48 +0000 (UTC) (envelope-from vbotton@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Fri, 13 Jul 2012 12:39:48 +0000 Date: Fri, 13 Jul 2012 12:39:48 +0000 From: vbotton@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120713123948.73956106564A@hub.freebsd.org> Cc: Subject: socsvn commit: r239339 - in soc2012/vbotton/head/sys/fs/ntfs: . test X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Jul 2012 12:39:50 -0000 Author: vbotton Date: Fri Jul 13 12:39:47 2012 New Revision: 239339 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239339 Log: Attempt to mount ntfs in VFS Added: soc2012/vbotton/head/sys/fs/ntfs/ntfs_attr.h soc2012/vbotton/head/sys/fs/ntfs/ntfs_attr_list.h soc2012/vbotton/head/sys/fs/ntfs/ntfs_bitmap.h soc2012/vbotton/head/sys/fs/ntfs/ntfs_collate.h soc2012/vbotton/head/sys/fs/ntfs/ntfs_compress.h soc2012/vbotton/head/sys/fs/ntfs/ntfs_debug.h soc2012/vbotton/head/sys/fs/ntfs/ntfs_dir.h soc2012/vbotton/head/sys/fs/ntfs/ntfs_endian.h soc2012/vbotton/head/sys/fs/ntfs/ntfs_hash.h soc2012/vbotton/head/sys/fs/ntfs/ntfs_index.h soc2012/vbotton/head/sys/fs/ntfs/ntfs_layout.h soc2012/vbotton/head/sys/fs/ntfs/ntfs_lcnalloc.h soc2012/vbotton/head/sys/fs/ntfs/ntfs_logfile.h soc2012/vbotton/head/sys/fs/ntfs/ntfs_mft.h soc2012/vbotton/head/sys/fs/ntfs/ntfs_mst.h soc2012/vbotton/head/sys/fs/ntfs/ntfs_original.h soc2012/vbotton/head/sys/fs/ntfs/ntfs_page.h soc2012/vbotton/head/sys/fs/ntfs/ntfs_quota.h soc2012/vbotton/head/sys/fs/ntfs/ntfs_runlist.h soc2012/vbotton/head/sys/fs/ntfs/ntfs_secure.h soc2012/vbotton/head/sys/fs/ntfs/ntfs_time.h soc2012/vbotton/head/sys/fs/ntfs/ntfs_types.h soc2012/vbotton/head/sys/fs/ntfs/ntfs_unistr.h soc2012/vbotton/head/sys/fs/ntfs/ntfs_usnjrnl.h soc2012/vbotton/head/sys/fs/ntfs/ntfs_vnops.h soc2012/vbotton/head/sys/fs/ntfs/ntfs_volume.h soc2012/vbotton/head/sys/fs/ntfs/test/ soc2012/vbotton/head/sys/fs/ntfs/test/ntfs_attr.c soc2012/vbotton/head/sys/fs/ntfs/test/ntfs_attr_list.c soc2012/vbotton/head/sys/fs/ntfs/test/ntfs_bitmap.c soc2012/vbotton/head/sys/fs/ntfs/test/ntfs_collate.c soc2012/vbotton/head/sys/fs/ntfs/test/ntfs_compress.c soc2012/vbotton/head/sys/fs/ntfs/test/ntfs_debug.c soc2012/vbotton/head/sys/fs/ntfs/test/ntfs_dir.c soc2012/vbotton/head/sys/fs/ntfs/test/ntfs_hash.c soc2012/vbotton/head/sys/fs/ntfs/test/ntfs_index.c soc2012/vbotton/head/sys/fs/ntfs/test/ntfs_inode.c soc2012/vbotton/head/sys/fs/ntfs/test/ntfs_lcnalloc.c soc2012/vbotton/head/sys/fs/ntfs/test/ntfs_logfile.c soc2012/vbotton/head/sys/fs/ntfs/test/ntfs_mft.c soc2012/vbotton/head/sys/fs/ntfs/test/ntfs_mst.c soc2012/vbotton/head/sys/fs/ntfs/test/ntfs_page.c soc2012/vbotton/head/sys/fs/ntfs/test/ntfs_quota.c soc2012/vbotton/head/sys/fs/ntfs/test/ntfs_runlist.c soc2012/vbotton/head/sys/fs/ntfs/test/ntfs_secure.c soc2012/vbotton/head/sys/fs/ntfs/test/ntfs_unistr.c soc2012/vbotton/head/sys/fs/ntfs/test/ntfs_usnjrnl.c soc2012/vbotton/head/sys/fs/ntfs/test/ntfs_vnops.c Replaced: soc2012/vbotton/head/sys/fs/ntfs/ntfs.h soc2012/vbotton/head/sys/fs/ntfs/ntfs_compr.c soc2012/vbotton/head/sys/fs/ntfs/ntfs_iconv.c soc2012/vbotton/head/sys/fs/ntfs/ntfs_ihash.c soc2012/vbotton/head/sys/fs/ntfs/ntfs_ihash.h soc2012/vbotton/head/sys/fs/ntfs/ntfs_inode.h soc2012/vbotton/head/sys/fs/ntfs/ntfs_subr.c (contents, props changed) soc2012/vbotton/head/sys/fs/ntfs/ntfs_subr.h soc2012/vbotton/head/sys/fs/ntfs/ntfs_vfsops.c soc2012/vbotton/head/sys/fs/ntfs/ntfs_vfsops.h soc2012/vbotton/head/sys/fs/ntfs/ntfs_vnops.c soc2012/vbotton/head/sys/fs/ntfs/ntfsmount.h Deleted: soc2012/vbotton/head/sys/fs/ntfs/ntfs_compr.h Added: soc2012/vbotton/head/sys/fs/ntfs/ntfs.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/vbotton/head/sys/fs/ntfs/ntfs.h Fri Jul 13 12:39:47 2012 (r239339) @@ -0,0 +1,167 @@ +/* + * ntfs.h - Some generic defines for the NTFS kernel driver. + * + * Copyright (c) 2006-2008 Anton Altaparmakov. All Rights Reserved. + * Portions Copyright (c) 2006-2008 Apple Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of Apple Inc. ("Apple") nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * ALTERNATIVELY, provided that this notice and licensing terms are retained in + * full, this file may be redistributed and/or modified under the terms of the + * GNU General Public License (GPL) Version 2, in which case the provisions of + * that version of the GPL will apply to you instead of the license terms + * above. You can obtain a copy of the GPL Version 2 at + * http://developer.apple.com/opensource/licenses/gpl-2.txt. + */ + +#ifndef _OSX_NTFS_H +#define _OSX_NTFS_H + +#ifdef KERNEL + +#include +#include + +/* The email address of the NTFS developers. */ +__private_extern__ const char ntfs_dev_email[]; +__private_extern__ const char ntfs_please_email[]; + +/* + * Lock group and lock attribute for de-/initialization of locks (defined + * in ntfs_vfsops.c). + */ +__private_extern__ lck_grp_t *ntfs_lock_grp; +__private_extern__ lck_attr_t *ntfs_lock_attr; + +/* + * A tag for allocation and freeing of memory (defined in ntfs_vfsops.c). + */ +__private_extern__ OSMallocTag ntfs_malloc_tag; +#endif /* KERNEL */ + +#include "ntfs_volume.h" + +/** + * NTFS_MP - return the NTFS volume given a vfs mount + * @mp: VFS mount + * + * NTFS_MP() returns the NTFS volume associated with the VFS mount @mp. + */ +static inline ntfs_volume *NTFS_MP(mount_t mp) +{ + return (ntfs_volume*)mp->mnt_data; +} + +__private_extern__ void ntfs_do_postponed_release(ntfs_volume *vol); + + +#include "ntfs_endian.h" +#include "ntfs_types.h" + +/* Some useful constants to do with NTFS. */ +enum { + NTFS_BLOCK_SIZE = 512, + NTFS_BLOCK_SIZE_SHIFT = 9, + NTFS_MAX_NAME_LEN = 255, + NTFS_MAX_ATTR_NAME_LEN = 255, + NTFS_MAX_SECTOR_SIZE = 4096, /* 4kiB */ + NTFS_MAX_CLUSTER_SIZE = 64 * 1024, /* 64kiB */ + NTFS_ALLOC_BLOCK = 1024, + NTFS_MAX_HARD_LINKS = 65535, /* 2^16 - 1 */ + NTFS_MAX_ATTR_LIST_SIZE = 256 * 1024, /* 256kiB, corresponding to the + VACB_MAPPING_GRANULARITY on + Windows. */ + NTFS_COMPRESSION_UNIT = 4, +}; + +/* + * The maximum attribute size on NTFS is 2^63 - 1 bytes as it is stored in a + * signed 64 bit type (s64). + */ +#define NTFS_MAX_ATTRIBUTE_SIZE 0x7fffffffffffffffULL + +/* + * The maximum number of MFT records allowed on NTFS is 2^32 as described in + * various documentation to be found on the Microsoft web site. This is an + * imposed limit rather than an inherent NTFS format limit. + */ +#define NTFS_MAX_NR_MFT_RECORDS 0x100000000ULL + +// TODO: Constants so ntfs_vfsops.c compiles for now... +enum { + /* One of these must be present, default is ON_ERRORS_CONTINUE. */ + ON_ERRORS_PANIC = 0x01, + ON_ERRORS_REMOUNT_RO = 0x02, + ON_ERRORS_CONTINUE = 0x04, + /* Optional, can be combined with any of the above. */ + ON_ERRORS_RECOVER = 0x10, +}; + +/* + * The NTFS mount options header passed in from user space. + */ +typedef struct { +#ifndef KERNEL + char *fspec; /* Path of device to mount, consumed by mount(2). */ +#endif /* !KERNEL */ + u8 major_ver; /* The major version of the mount options structure. */ + u8 minor_ver; /* The minor version of the mount options structure. */ +} __attribute__((__packed__)) ntfs_mount_options_header; + +/* + * The NTFS mount options passed in from user space. This follows the + * ntfs_mount_options_header aligned to an eight byte boundary. + * + * This is major version 0, minor version 0, which does not have any options, + * i.e. is empty. + */ +typedef struct { + /* Mount options version 0.0 does not have any ntfs options. */ +} __attribute__((__packed__)) ntfs_mount_options_0_0; + +/* + * The currently defined flags for the ntfs mount options structure. + */ +enum { + /* Below flag(s) appeared in mount options version 1.0. */ + NTFS_MNT_OPT_CASE_SENSITIVE = htole32(0x00000001), + /* Below flag(s) appeared in mount options version x.y. */ + // TODO: Add NTFS specific mount options flags here. +}; + +typedef le32 NTFS_MNT_OPTS; + +/* + * The NTFS mount options passed in from user space. This follows the + * ntfs_mount_options_header aligned to an eight byte boundary. + * + * This is major version 1, minor version 0, which has only one option, a + * little endian, 32-bit flags option. + */ +typedef struct { + NTFS_MNT_OPTS flags; + // TODO: Add NTFS specific mount options here. +} __attribute__((__packed__)) ntfs_mount_options_1_0; + +#endif /* !_OSX_NTFS_H */ Added: soc2012/vbotton/head/sys/fs/ntfs/ntfs_attr.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/vbotton/head/sys/fs/ntfs/ntfs_attr.h Fri Jul 13 12:39:47 2012 (r239339) @@ -0,0 +1,245 @@ +/* + * ntfs_attr.h - Defines for attribute handling in the NTFS kernel driver. + * + * Copyright (c) 2006-2008 Anton Altaparmakov. All Rights Reserved. + * Portions Copyright (c) 2006-2008 Apple Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of Apple Inc. ("Apple") nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * ALTERNATIVELY, provided that this notice and licensing terms are retained in + * full, this file may be redistributed and/or modified under the terms of the + * GNU General Public License (GPL) Version 2, in which case the provisions of + * that version of the GPL will apply to you instead of the license terms + * above. You can obtain a copy of the GPL Version 2 at + * http://developer.apple.com/opensource/licenses/gpl-2.txt. + */ + +#ifndef _OSX_NTFS_ATTR_H +#define _OSX_NTFS_ATTR_H + +#include + +/* Forward declaration. */ +typedef struct _ntfs_attr_search_ctx ntfs_attr_search_ctx; + +#include "ntfs_endian.h" +#include "ntfs_index.h" +#include "ntfs_inode.h" +#include "ntfs_layout.h" +#include "ntfs_types.h" + +/* + * The little endian Unicode empty string as a global constant. This is used + * when looking up attributes to specify that we want the unnamed attribute as + * opposed to any attribute or a specific named attribute. + */ +__private_extern__ ntfschar AT_UNNAMED[1]; + +__private_extern__ errno_t ntfs_attr_map_runlist(ntfs_inode *ni); + +__private_extern__ errno_t ntfs_map_runlist_nolock(ntfs_inode *ni, VCN vcn, + ntfs_attr_search_ctx *ctx); + +__private_extern__ LCN ntfs_attr_vcn_to_lcn_nolock(ntfs_inode *ni, + const VCN vcn, const BOOL write_locked, s64 *clusters); + +__private_extern__ errno_t ntfs_attr_find_vcn_nolock(ntfs_inode *ni, + const VCN vcn, ntfs_rl_element **run, + ntfs_attr_search_ctx *ctx); + +static inline s64 ntfs_attr_size(const ATTR_RECORD *a) +{ + if (!a->non_resident) + return (s64)le32toh(a->value_length); + return le64toh(a->data_size); +} + +/** + * ntfs_attr_search_ctx - used in attribute search functions + * @m: buffer containing mft record to search + * @a: attribute record in @m where to begin/continue search + * @is_first: if 1 the search begins search with @a, else after + * @is_iteration: if 1 this is not a search but an iteration + * @is_error: if 1 this search context is invalid and must be released + * @is_mft_locked: if 1 the mft is locked (@mft_ni->lock) + * + * Structure must be initialized to zero before the first call to one of the + * attribute search functions. Initialize @m to point to the mft record to + * search, and @a to point to the first attribute within @m and set @is_first + * to 1. + * + * If @is_first is 1, the search begins with @a. If @is_first is 0, the search + * begins after @a. This is so that, after the first call to one of the search + * attribute functions, we can call the function again, without any + * modification of the search context, to automagically get the next matching + * attribute. + * + * If @is_iteration is 1, all attributes are returned one after the other with + * each call to ntfs_attr_find_in_mft_record(). Note this only works with + * ntfs_attr_find_in_mft_record() and not with ntfs_attr_lookup() or + * ntfs_attr_find_in_attribute_list(). + * + * If @is_error is 1 this attribute search context has become invalid and must + * either be reinitialized via ntfs_attr_search_ctx_reinit() or released via + * ntfs_attr_search_ctx_put(). Functions to which you pass an attribute search + * context may require you to check @is_error after calling the function. If + * this is the case the function will explicictly say so in the function + * description. + * + * If @is_error is 1 you can see what the error code was that caused the + * context to become invalid by looking at the @error member of the search + * context. + * + * If @is_mft_locked is true the owner of the search context holds the mft lock + * (@mft_ni->lock) thus ntfs_attr_lookup() will make sure to pass this fact + * onto ntfs_extent_mft_record_map_ext() so that it will not try to take the + * same lock. It is then the responsibility of the caller that the mft is + * consistent and stable for the duration of the life of the search context. + */ +struct _ntfs_attr_search_ctx { + union { + MFT_RECORD *m; + errno_t error; + }; + ATTR_RECORD *a; + struct { + unsigned is_first:1; /* If 1 this is the first search. */ + unsigned is_iteration:1;/* If 1 this is an iteration of all + attributes in the mft record. */ + unsigned is_error:1; + unsigned is_mft_locked:1; + }; + ntfs_inode *ni; + ATTR_LIST_ENTRY *al_entry; + ntfs_inode *base_ni; + MFT_RECORD *base_m; + ATTR_RECORD *base_a; +}; + +/** + * ntfs_attr_search_ctx_init - initialize an attribute search context + * @ctx: attribute search context to initialize + * @ni: ntfs inode with which to initialize the search context + * @m: mft record with which to initialize the search context + * + * Initialize the attribute search context @ctx with @ni and @m. + */ +static inline void ntfs_attr_search_ctx_init(ntfs_attr_search_ctx *ctx, + ntfs_inode *ni, MFT_RECORD *m) +{ + /* + * Gcc is broken so it fails to see both the members of the anonymous + * union and the bitfield inside the C99 initializer. Work around this + * by setting @m and @is_first afterwards. + */ + *ctx = (ntfs_attr_search_ctx) { + /* Sanity checks are performed elsewhere. */ + .a = (ATTR_RECORD*)((u8*)m + le16toh(m->attrs_offset)), + .ni = ni, + }; + ctx->m = m, + ctx->is_first = 1; +} + +__private_extern__ void ntfs_attr_search_ctx_reinit(ntfs_attr_search_ctx *ctx); +__private_extern__ ntfs_attr_search_ctx *ntfs_attr_search_ctx_get( + ntfs_inode *ni, MFT_RECORD *m); +__private_extern__ void ntfs_attr_search_ctx_put(ntfs_attr_search_ctx *ctx); + +__private_extern__ errno_t ntfs_attr_find_in_mft_record(const ATTR_TYPE type, + const ntfschar *name, const u32 name_len, + const void *val, const u32 val_len, ntfs_attr_search_ctx *ctx); + +__private_extern__ errno_t ntfs_attr_lookup(const ATTR_TYPE type, + const ntfschar *name, const u32 name_len, const VCN lowest_vcn, + const void *val, const u32 val_len, ntfs_attr_search_ctx *ctx); + +__private_extern__ errno_t ntfs_attr_size_bounds_check(const ntfs_volume *vol, + const ATTR_TYPE type, const s64 size); + +__private_extern__ errno_t ntfs_attr_can_be_resident(const ntfs_volume *vol, + const ATTR_TYPE type); + +__private_extern__ BOOL ntfs_attr_record_is_only_one(MFT_RECORD *m, + ATTR_RECORD *a); + +__private_extern__ void ntfs_attr_record_delete_internal(MFT_RECORD *m, + ATTR_RECORD *a); +__private_extern__ errno_t ntfs_attr_record_delete(ntfs_inode *base_ni, + ntfs_attr_search_ctx *ctx); + +__private_extern__ errno_t ntfs_attr_record_make_space(MFT_RECORD *m, + ATTR_RECORD *a, u32 size); + +__private_extern__ errno_t ntfs_attr_record_resize(MFT_RECORD *m, + ATTR_RECORD *a, u32 new_size); + +__private_extern__ errno_t ntfs_attr_mapping_pairs_update(ntfs_inode *base_ni, + ntfs_inode *ni, VCN first_vcn, VCN last_vcn, + ntfs_attr_search_ctx *ctx); + +__private_extern__ errno_t ntfs_resident_attr_record_insert_internal( + MFT_RECORD *m, ATTR_RECORD *a, const ATTR_TYPE type, + const ntfschar *name, const u8 name_len, const u32 val_len); +__private_extern__ errno_t ntfs_resident_attr_record_insert(ntfs_inode *ni, + ntfs_attr_search_ctx *ctx, const ATTR_TYPE type, + const ntfschar *name, const u8 name_len, + const void *val, const u32 val_len); + +__private_extern__ errno_t ntfs_resident_attr_value_resize(MFT_RECORD *m, + ATTR_RECORD *a, const u32 new_size); + +__private_extern__ errno_t ntfs_attr_make_non_resident(ntfs_inode *ni); + +__private_extern__ errno_t ntfs_attr_record_move_for_attr_list_attribute( + ntfs_attr_search_ctx *al_ctx, ATTR_LIST_ENTRY *al_entry, + ntfs_attr_search_ctx *ctx, BOOL *remap_needed); + +__private_extern__ errno_t ntfs_attr_record_move(ntfs_attr_search_ctx *ctx); + +__private_extern__ errno_t ntfs_attr_set_initialized_size(ntfs_inode *ni, + s64 new_init_size); + +__private_extern__ errno_t ntfs_attr_extend_initialized(ntfs_inode *ni, + const s64 new_init_size); + +__private_extern__ errno_t ntfs_attr_instantiate_holes(ntfs_inode *ni, + s64 start, s64 end, s64 *new_end, BOOL atomic); + +__private_extern__ errno_t ntfs_attr_extend_allocation(ntfs_inode *ni, + s64 new_alloc_size, const s64 new_data_size, + const s64 data_start, ntfs_index_context *ictx, + s64 *dst_alloc_size, const BOOL atomic); + +__private_extern__ errno_t ntfs_attr_resize(ntfs_inode *ni, s64 new_size, + int ioflags, ntfs_index_context *ictx); + +__private_extern__ errno_t ntfs_attr_set(ntfs_inode *ni, s64 ofs, + const s64 cnt, const u8 val); + +__private_extern__ errno_t ntfs_resident_attr_read(ntfs_inode *ni, + const s64 ofs, const u32 cnt, u8 *buf); +__private_extern__ errno_t ntfs_resident_attr_write(ntfs_inode *ni, u8 *buf, + u32 cnt, const s64 ofs); +#endif /* !_OSX_NTFS_ATTR_H */ Added: soc2012/vbotton/head/sys/fs/ntfs/ntfs_attr_list.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/vbotton/head/sys/fs/ntfs/ntfs_attr_list.h Fri Jul 13 12:39:47 2012 (r239339) @@ -0,0 +1,112 @@ +/* + * ntfs_attr_list.h - Defines for attribute list attribute handling in the NTFS + * kernel driver. + * + * Copyright (c) 2006-2008 Anton Altaparmakov. All Rights Reserved. + * Portions Copyright (c) 2006-2008 Apple Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of Apple Inc. ("Apple") nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * ALTERNATIVELY, provided that this notice and licensing terms are retained in + * full, this file may be redistributed and/or modified under the terms of the + * GNU General Public License (GPL) Version 2, in which case the provisions of + * that version of the GPL will apply to you instead of the license terms + * above. You can obtain a copy of the GPL Version 2 at + * http://developer.apple.com/opensource/licenses/gpl-2.txt. + */ + +#ifndef _OSX_NTFS_ATTR_LIST_H +#define _OSX_NTFS_ATTR_LIST_H + +#include + +#include "ntfs_attr.h" +#include "ntfs_endian.h" +#include "ntfs_inode.h" +#include "ntfs_layout.h" +#include "ntfs_types.h" + +__private_extern__ errno_t ntfs_attr_list_is_needed(ntfs_inode *ni, + ATTR_LIST_ENTRY *skip_entry, BOOL *attr_list_is_needed); + +__private_extern__ errno_t ntfs_attr_list_delete(ntfs_inode *ni, + ntfs_attr_search_ctx *ctx); + +__private_extern__ errno_t ntfs_attr_list_add(ntfs_inode *ni, MFT_RECORD *m, + ntfs_attr_search_ctx *ctx); + +__private_extern__ errno_t ntfs_attr_list_sync_shrink(ntfs_inode *ni, + const unsigned start_ofs, ntfs_attr_search_ctx *ctx); + +__private_extern__ errno_t ntfs_attr_list_sync_extend(ntfs_inode *base_ni, + MFT_RECORD *base_m, unsigned al_ofs, + ntfs_attr_search_ctx *ctx); + +/** + * ntfs_attr_list_sync - update the attribute list content of an ntfs inode + * @ni: base ntfs inode whose attribute list attribugte to update + * @start_ofs: byte offset into attribute list attribute from which to write + * @ctx: initialized attribute search context + * + * Write the attribute list attribute value cached in @ni starting at byte + * offset @start_ofs into it to the attribute list attribute record (if the + * attribute list attribute is resident) or to disk as specified by the runlist + * of the attribute list attribute. + * + * This function only works when the attribute list content but not its size + * has changed. + * + * @ctx is an initialized, ready to use attribute search context that we use to + * look up the attribute list attribute in the mapped, base mft record. + * + * Return 0 on success and -errno on error. + */ +static inline int ntfs_attr_list_sync(ntfs_inode *ni, const unsigned start_ofs, + ntfs_attr_search_ctx *ctx) +{ + return ntfs_attr_list_sync_shrink(ni, start_ofs, ctx); +} + +__private_extern__ void ntfs_attr_list_entries_delete(ntfs_inode *ni, + ATTR_LIST_ENTRY *start_entry, ATTR_LIST_ENTRY *end_entry); + +/** + * ntfs_attr_list_entry_delete - delete an attribute list entry + * @ni: base ntfs inode whose attribute list to delete from + * @target_entry: attribute list entry to be deleted + * + * Delete the attribute list attribute entry @target_entry from the attribute + * list attribute belonging to the base ntfs inode @ni. + * + * This function cannot fail. + */ +static inline void ntfs_attr_list_entry_delete(ntfs_inode *ni, + ATTR_LIST_ENTRY *target_entry) +{ + ntfs_attr_list_entries_delete(ni, target_entry, + (ATTR_LIST_ENTRY*)((u8*)target_entry + + le16toh(target_entry->length))); +} + +#endif /* !_OSX_NTFS_ATTR_LIST_H */ Added: soc2012/vbotton/head/sys/fs/ntfs/ntfs_bitmap.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/vbotton/head/sys/fs/ntfs/ntfs_bitmap.h Fri Jul 13 12:39:47 2012 (r239339) @@ -0,0 +1,141 @@ +/* + * ntfs_bitmap.h - Defines for bitmap handling in the NTFS kernel driver. + * + * Copyright (c) 2006-2008 Anton Altaparmakov. All Rights Reserved. + * Portions Copyright (c) 2006-2008 Apple Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of Apple Inc. ("Apple") nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * ALTERNATIVELY, provided that this notice and licensing terms are retained in + * full, this file may be redistributed and/or modified under the terms of the + * GNU General Public License (GPL) Version 2, in which case the provisions of + * that version of the GPL will apply to you instead of the license terms + * above. You can obtain a copy of the GPL Version 2 at + * http://developer.apple.com/opensource/licenses/gpl-2.txt. + */ + +#ifndef _OSX_NTFS_BITMAP_H +#define _OSX_NTFS_BITMAP_H + +#include + +#include "ntfs_inode.h" +#include "ntfs_types.h" + +__private_extern__ errno_t __ntfs_bitmap_set_bits_in_run(ntfs_inode *ni, + const s64 start_bit, const s64 count, const u8 value, + const BOOL is_rollback); + +/** + * ntfs_bitmap_set_bits_in_run - set a run of bits in a bitmap to a value + * @ni: ntfs inode describing the bitmap + * @start_bit: first bit to set + * @count: number of bits to set + * @value: value to set the bits to (i.e. 0 or 1) + * + * Set @count bits starting at bit @start_bit in the bitmap described by the + * ntfs inode @ni to @value, where @value is either 0 or 1. + * + * Return 0 on success and errno on error. + * + * Locking: The caller must hold @ni->lock. + */ +static inline errno_t ntfs_bitmap_set_bits_in_run(ntfs_inode *ni, + const s64 start_bit, const s64 count, const u8 value) +{ + return __ntfs_bitmap_set_bits_in_run(ni, start_bit, count, value, + FALSE); +} + +/** + * ntfs_bitmap_set_run - set a run of bits in a bitmap + * @ni: ntfs inode describing the bitmap + * @start_bit: first bit to set + * @count: number of bits to set + * + * Set @count bits starting at bit @start_bit in the bitmap described by the + * ntfs inode @ni. + * + * Return 0 on success and errno on error. + * + * Locking: The caller must hold @ni->lock. + */ +static inline errno_t ntfs_bitmap_set_run(ntfs_inode *ni, const s64 start_bit, + const s64 count) +{ + return ntfs_bitmap_set_bits_in_run(ni, start_bit, count, 1); +} + +/** + * ntfs_bitmap_clear_run - clear a run of bits in a bitmap + * @ni: ntfs inode describing the bitmap + * @start_bit: first bit to clear + * @count: number of bits to clear + * + * Clear @count bits starting at bit @start_bit in the bitmap described by the + * ntfs inode @ni. + * + * Return 0 on success and errno on error. + * + * Locking: The caller must hold @ni->lock. + */ +static inline errno_t ntfs_bitmap_clear_run(ntfs_inode *ni, + const s64 start_bit, const s64 count) +{ + return ntfs_bitmap_set_bits_in_run(ni, start_bit, count, 0); +} + +/** + * ntfs_bitmap_set_bit - set a bit in a bitmap + * @ni: ntfs inode describing the bitmap + * @bit: bit to set + * + * Set bit @bit in the bitmap described by the ntfs inode @ni. + * + * Return 0 on success and errno on error. + * + * Locking: The caller must hold @ni->lock. + */ +static inline errno_t ntfs_bitmap_set_bit(ntfs_inode *ni, const s64 bit) +{ + return ntfs_bitmap_set_run(ni, bit, 1); +} + +/** + * ntfs_bitmap_clear_bit - clear a bit in a bitmap + * @ni: ntfs inode describing the bitmap + * @bit: bit to clear + * + * Clear bit @bit in the bitmap described by the ntfs inode @ni. + * + * Return 0 on success and errno on error. + * + * Locking: The caller must hold @ni->lock. + */ +static inline errno_t ntfs_bitmap_clear_bit(ntfs_inode *ni, const s64 bit) +{ + return ntfs_bitmap_clear_run(ni, bit, 1); +} + +#endif /* !_OSX_NTFS_BITMAP_H */ Added: soc2012/vbotton/head/sys/fs/ntfs/ntfs_collate.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/vbotton/head/sys/fs/ntfs/ntfs_collate.h Fri Jul 13 12:39:47 2012 (r239339) @@ -0,0 +1,65 @@ +/* + * ntfs_collate.h - Defines for collation handling in the NTFS kernel driver. + * + * Copyright (c) 2006-2008 Anton Altaparmakov. All Rights Reserved. + * Portions Copyright (c) 2006-2008 Apple Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of Apple Inc. ("Apple") nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * ALTERNATIVELY, provided that this notice and licensing terms are retained in + * full, this file may be redistributed and/or modified under the terms of the + * GNU General Public License (GPL) Version 2, in which case the provisions of + * that version of the GPL will apply to you instead of the license terms + * above. You can obtain a copy of the GPL Version 2 at + * http://developer.apple.com/opensource/licenses/gpl-2.txt. + */ + +#ifndef _OSX_NTFS_COLLATE_H +#define _OSX_NTFS_COLLATE_H + +#include "ntfs_layout.h" +#include "ntfs_types.h" +#include "ntfs_volume.h" + +static inline BOOL ntfs_is_collation_rule_supported(COLLATION_RULE cr) { + int i; + + /* + * TODO: We support everything other than COLLATION_UNICODE_STRING at + * present but we do a range check in case new collation rules turn up + * in later ntfs releases. + */ + if (cr == COLLATION_UNICODE_STRING) + return FALSE; + i = le32toh(cr); + if (((i >= 0) && (i <= 0x02)) || ((i >= 0x10) && (i <= 0x13))) + return TRUE; + return FALSE; +} + +__private_extern__ int ntfs_collate(ntfs_volume *vol, COLLATION_RULE cr, + const void *data1, const int data1_len, + const void *data2, const int data2_len); + +#endif /* _OSX_NTFS_COLLATE_H */ Added: soc2012/vbotton/head/sys/fs/ntfs/ntfs_compr.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/vbotton/head/sys/fs/ntfs/ntfs_compr.c Fri Jul 13 12:39:47 2012 (r239339) @@ -0,0 +1,2 @@ + + Added: soc2012/vbotton/head/sys/fs/ntfs/ntfs_compress.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/vbotton/head/sys/fs/ntfs/ntfs_compress.h Fri Jul 13 12:39:47 2012 (r239339) @@ -0,0 +1,52 @@ +/* + * ntfs_compress.h - Defines for compressed attribute handling in the NTFS + * kernel driver. + * + * Copyright (c) 2006-2008 Anton Altaparmakov. All Rights Reserved. + * Portions Copyright (c) 2006-2008 Apple Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of Apple Inc. ("Apple") nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * ALTERNATIVELY, provided that this notice and licensing terms are retained in + * full, this file may be redistributed and/or modified under the terms of the + * GNU General Public License (GPL) Version 2, in which case the provisions of + * that version of the GPL will apply to you instead of the license terms + * above. You can obtain a copy of the GPL Version 2 at + * http://developer.apple.com/opensource/licenses/gpl-2.txt. + */ + +#ifndef _OSX_NTFS_COMPRESS_H +#define _OSX_NTFS_COMPRESS_H + +#include + + +#include "ntfs_inode.h" +#include "ntfs_types.h" + +/*__private_extern__ errno_t ntfs_read_compressed(ntfs_inode *ni, + ntfs_inode *raw_ni, s64 ofs, const int start_count, + u8 *dst_start, upl_page_info_t *pl, int ioflags);*/ + +#endif /* !_OSX_NTFS_COMPRESS_H */ Added: soc2012/vbotton/head/sys/fs/ntfs/ntfs_debug.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/vbotton/head/sys/fs/ntfs/ntfs_debug.h Fri Jul 13 12:39:47 2012 (r239339) @@ -0,0 +1,89 @@ +/* + * ntfs_debug.h - Defines for NTFS kernel debug support. + * + * Copyright (c) 2006-2008 Anton Altaparmakov. All Rights Reserved. + * Portions Copyright (c) 2006-2008 Apple Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of Apple Inc. ("Apple") nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * ALTERNATIVELY, provided that this notice and licensing terms are retained in + * full, this file may be redistributed and/or modified under the terms of the + * GNU General Public License (GPL) Version 2, in which case the provisions of + * that version of the GPL will apply to you instead of the license terms + * above. You can obtain a copy of the GPL Version 2 at + * http://developer.apple.com/opensource/licenses/gpl-2.txt. + */ + +#ifndef _OSX_NTFS_DEBUG_H +#define _OSX_NTFS_DEBUG_H + +#include + +#include "ntfs_runlist.h" + +/* Forward declaration so we do not have to include here. */ +struct mount; + +__private_extern__ void ntfs_debug_init(void); +__private_extern__ void ntfs_debug_deinit(void); + +__private_extern__ void __ntfs_warning(const char *function, + struct mount *mp, const char *fmt, ...) __printflike(3, 4); +#define ntfs_warning(mp, fmt, a...) \ + __ntfs_warning(__FUNCTION__, mp, fmt, ##a) + +__private_extern__ void __ntfs_error(const char *function, + struct mount *mp, const char *fmt, ...) __printflike(3, 4); +#define ntfs_error(mp, fmt, a...) \ + __ntfs_error(__FUNCTION__, mp, fmt, ##a) + +#ifdef DEBUG + +/** + * ntfs_debug - write a debug message to the console + * @fmt: a printf format string containing the message + * @...: the variables to substitute into @fmt + * + * ntfs_debug() writes a message to the console but only if the driver was + * compiled with -DDEBUG. Otherwise, the call turns into a NOP. + */ +__private_extern__ void __ntfs_debug(const char *file, int line, + const char *function, const char *fmt, ...) + __printflike(4, 5); +#define ntfs_debug(fmt, a...) \ + __ntfs_debug(__FILE__, __LINE__, __FUNCTION__, fmt, ##a) + +__private_extern__ void ntfs_debug_runlist_dump(const ntfs_runlist *rl); +__private_extern__ void ntfs_debug_attr_list_dump(const u8 *al, + const unsigned size); + +#else /* !DEBUG */ + +#define ntfs_debug(fmt, a...) do {} while (0) +#define ntfs_debug_runlist_dump(rl) do {} while (0) +#define ntfs_debug_attr_list_dump(al, size) do {} while (0) + +#endif /* !DEBUG */ + +#endif /* !_OSX_NTFS_DEBUG_H */ Added: soc2012/vbotton/head/sys/fs/ntfs/ntfs_dir.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/vbotton/head/sys/fs/ntfs/ntfs_dir.h Fri Jul 13 12:39:47 2012 (r239339) @@ -0,0 +1,110 @@ +/* + * ntfs_dir.h - Defines for directory handling in the NTFS kernel driver. + * + * Copyright (c) 2006-2008 Anton Altaparmakov. All Rights Reserved. + * Portions Copyright (c) 2006-2008 Apple Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of Apple Inc. ("Apple") nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * ALTERNATIVELY, provided that this notice and licensing terms are retained in + * full, this file may be redistributed and/or modified under the terms of the + * GNU General Public License (GPL) Version 2, in which case the provisions of + * that version of the GPL will apply to you instead of the license terms + * above. You can obtain a copy of the GPL Version 2 at + * http://developer.apple.com/opensource/licenses/gpl-2.txt. + */ + +#ifndef _OSX_NTFS_DIR_H +#define _OSX_NTFS_DIR_H + +#include +#include + +#include "ntfs.h" +#include "ntfs_inode.h" +#include "ntfs_layout.h" +#include "ntfs_types.h" + +/* + * ntfs_name is used to return the actual found filename to the caller of + * ntfs_lookup_inode_by_name() in order for the caller + * (ntfs_vnops.c::ntfs_vnop_lookup()) to be able to deal with the case + * sensitive name cache effectively. + */ +typedef struct { + MFT_REF mref; + FILENAME_TYPE_FLAGS type; + u8 len; + ntfschar name[NTFS_MAX_NAME_LEN]; +} ntfs_dir_lookup_name; + +/* The little endian Unicode string $I30 as a global constant. */ +__private_extern__ ntfschar I30[5]; + +__private_extern__ errno_t ntfs_lookup_inode_by_name(ntfs_inode *dir_ni, + const ntfschar *uname, const signed uname_len, + MFT_REF *res_mref, ntfs_dir_lookup_name **res_name); + +//__private_extern__ errno_t ntfs_readdir(ntfs_inode *dir_ni, uio_t uio, +// int *eofflag, int *numdirent); + +__private_extern__ errno_t ntfs_dir_is_empty(ntfs_inode *dir_ni); + +__private_extern__ errno_t ntfs_dir_entry_delete(ntfs_inode *dir_ni, + ntfs_inode *ni, const FILENAME_ATTR *fn, const u32 fn_len); + +__private_extern__ errno_t ntfs_dir_entry_add(ntfs_inode *dir_ni, + const FILENAME_ATTR *fn, const u32 fn_len, + const leMFT_REF mref); + +/** + * struct _ntfs_dirhint - directory hint structure + * + * This is used to store state across directory enumerations, i.e. across calls + * to ntfs_readdir(). + */ +struct _ntfs_dirhint { + TAILQ_ENTRY(_ntfs_dirhint) link; + unsigned ofs; + unsigned time; + unsigned fn_size; + FILENAME_ATTR *fn; +}; +typedef struct _ntfs_dirhint ntfs_dirhint; + +/* + * NTFS_MAX_DIRHINTS cannot be larger than 63 without reducing + * NTFS_DIR_POS_MASK, because given the 6-bit tag, at most 63 different tags + * can exist. When NTFS_MAX_DIRHINTS is larger than 63, the same list may + * contain dirhints of the same tag, and a staled dirhint may be returned. *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-soc-all@FreeBSD.ORG Fri Jul 13 14:36:07 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id A66A11065670 for ; Fri, 13 Jul 2012 14:36:05 +0000 (UTC) (envelope-from gpf@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Fri, 13 Jul 2012 14:36:05 +0000 Date: Fri, 13 Jul 2012 14:36:05 +0000 From: gpf@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120713143605.A66A11065670@hub.freebsd.org> Cc: Subject: socsvn commit: r239343 - in soc2012/gpf/pefs_kmod: sbin/pefs sys/fs/pefs X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Jul 2012 14:36:07 -0000 Author: gpf Date: Fri Jul 13 14:36:05 2012 New Revision: 239343 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239343 Log: - sanitize .pefs.checksum global file header during VFS_MOUNT() - inline mini function that tells if a vnode needs integrity checking or not. - another inline func to tell if a given index entry is empty or not. (nhashes value of 0 symbolizes an empty index entry in the hash tables) - split code that reads an index entry from the hash tables to different function first steps towards actual integrity checking: During VOP_READ(), if a vnode has a key, then we try to check the integrity of the data before decrypting the data. We compare the stored checksum in .pefs.checksum vs the one we generate at that time. If integrity errors occurs, we mark the vnode as 'hacked' and any future attempts to verify the data will fail. Also, check the size of the file against the nhashes value of the file's index entry. all respective code can be found in pefs_checksum.c Modified: soc2012/gpf/pefs_kmod/sbin/pefs/pefs_checksum.c soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs.h soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_checksum.c soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_checksum.h soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_vfsops.c soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_vnops.c Modified: soc2012/gpf/pefs_kmod/sbin/pefs/pefs_checksum.c ============================================================================== --- soc2012/gpf/pefs_kmod/sbin/pefs/pefs_checksum.c Fri Jul 13 13:24:33 2012 (r239342) +++ soc2012/gpf/pefs_kmod/sbin/pefs/pefs_checksum.c Fri Jul 13 14:36:05 2012 (r239343) @@ -476,6 +476,7 @@ { struct checksum *csp, *tcsp; if (fhp != NULL) { + /* XXXgpf: [TODO] should probably call pefs_close_file() at this point */ TAILQ_FOREACH_SAFE(csp, &(fhp->checksums), checksum_entries, tcsp) { TAILQ_REMOVE(&(fhp->checksums), csp, checksum_entries); if (csp->hash != NULL) Modified: soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs.h ============================================================================== --- soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs.h Fri Jul 13 13:24:33 2012 (r239342) +++ soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs.h Fri Jul 13 14:36:05 2012 (r239343) @@ -122,7 +122,8 @@ #define PN_WANTRECYCLE 0x000100 #define PN_LOCKBUF_SMALL 0x001000 #define PN_LOCKBUF_LARGE 0x002000 -#define PN_NO_CHECKSUM 0x000010 +#define PN_NO_CHECKSUM 0x000010 +#define PN_WRONG_CHECKSUM 0x000020 struct pefs_node { LIST_ENTRY(pefs_node) pn_listentry; @@ -146,7 +147,8 @@ uint8_t pcs_version; uint8_t pcs_reserved; uint8_t pcs_hash_len; - uint8_t pcs_hash_algo[8]; + uint8_t pcs_hash_algo; + uint8_t pcs_hash_algo_name[8]; uint8_t pcs_offset_to_hash_table; uint32_t pcs_hash_table_size; char *pcs_table1, *pcs_table2; Modified: soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_checksum.c ============================================================================== --- soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_checksum.c Fri Jul 13 13:24:33 2012 (r239342) +++ soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_checksum.c Fri Jul 13 14:36:05 2012 (r239343) @@ -40,9 +40,45 @@ #include #include +#include + #include #include +const char *pefs_checksum_supported_digests[] = {"sha256","sha512"}; +uint8_t pefs_checksum_supported_hash_lengths[] = {32, 64}; + +int +pefs_sanitize_checksum_header(struct pefs_checksum *pcs) +{ + int error, i; + + error = 0; + for (i=0; i < PEFS_CHECKSUM_SUPPORTED_DIGESTS; i++) + if (strncmp(pefs_checksum_supported_digests[i], pcs->pcs_hash_algo_name, + sizeof(pcs->pcs_hash_algo_name)) == 0) + break; + + pcs->pcs_hash_algo = i; + switch(pcs->pcs_hash_algo) { + /* FALLTHROUGH */ + case (PEFS_SHA256): + case (PEFS_SHA512): + printf("digest: %s\n", pcs->pcs_hash_algo_name); + if (pcs->pcs_hash_len != pefs_checksum_supported_hash_lengths[i]) { + printf("pefs_sanitize invalid algo len %u\n", pcs->pcs_hash_len); + error = EINVAL; + } + break; + default: + printf("pefs_sanitize invalid algo %s\n", pcs->pcs_hash_algo_name); + error = ENODEV; + break; + } + + return (error); +} + static uint32_t pefs_checksum_hash1(struct pefs_checksum *pc, struct pefs_checksum_index_entry *pcie) { @@ -65,6 +101,26 @@ return (nbucket); } +/* fill out pcie for from data pointed to by p */ +static void +pefs_get_index_entry(char *p, struct pefs_checksum_index_entry *pcie) +{ + MPASS(p != NULL); + + memcpy(&(pcie->pcie_nhashes), p, sizeof(pcie->pcie_nhashes)); + pcie->pcie_nhashes = le32toh(pcie->pcie_nhashes); + if (pcie->pcie_nhashes != 0) { + p+=sizeof(pcie->pcie_nhashes); + + memcpy(&(pcie->pcie_offset), p, sizeof(pcie->pcie_offset)); + pcie->pcie_offset = le32toh(pcie->pcie_offset); + p+=sizeof(pcie->pcie_offset); + + memcpy(&(pcie->pcie_file_id), p, sizeof(pcie->pcie_file_id)); + pcie->pcie_file_id = le64toh(pcie->pcie_file_id); + } +} + static int pefs_checksum_index_lookup(struct pefs_checksum_index_entry *pcie, struct vnode *vp) { @@ -72,28 +128,14 @@ struct pefs_mount *pm = VFS_TO_PEFS(vp->v_mount); struct pefs_checksum *pcs = &(pm->pm_checksum); struct pefs_node *pn = VP_TO_PN(vp); - char *start, *p; + char *start; uint32_t pos; pos = pefs_checksum_hash1(pcs, pcie); start = &(pcs->pcs_table1[pos * PEFS_HT_CELL_SIZE]); - p = start; + pefs_get_index_entry(start, &target_pcie); - /* - * XXXgpf: [TODO] move the reading of a checksum index entry to a different function. - * Also, perhaps a macro to tell if an index entry is empty or not (nhashes == 0). - */ - memcpy(&(target_pcie.pcie_nhashes), p, sizeof(target_pcie.pcie_nhashes)); - target_pcie.pcie_nhashes = le32toh(target_pcie.pcie_nhashes); - if (target_pcie.pcie_nhashes != 0) { - p+=sizeof(target_pcie.pcie_nhashes); - - memcpy(&(target_pcie.pcie_offset), p, sizeof(target_pcie.pcie_offset)); - target_pcie.pcie_offset = le32toh(target_pcie.pcie_offset); - p+=sizeof(target_pcie.pcie_offset); - - memcpy(&(target_pcie.pcie_file_id), p, sizeof(target_pcie.pcie_file_id)); - target_pcie.pcie_file_id = le64toh(target_pcie.pcie_file_id); + if (!PEFS_EMPTY_INDEX_ENTRY(&target_pcie)) { printf("cell %d:\n", pos); printf("\thashes = %d\n\toffset = %d\n\tfile id = %llu\n", target_pcie.pcie_nhashes, target_pcie.pcie_offset, target_pcie.pcie_file_id); @@ -107,19 +149,9 @@ pos = pefs_checksum_hash2(pcs, pcie); start = &(pcs->pcs_table2[pos * PEFS_HT_CELL_SIZE]); - p = start; - - memcpy(&(target_pcie.pcie_nhashes), p, sizeof(target_pcie.pcie_nhashes)); - target_pcie.pcie_nhashes = le32toh(target_pcie.pcie_nhashes); - if (target_pcie.pcie_nhashes != 0) { - p+=sizeof(target_pcie.pcie_nhashes); - - memcpy(&(target_pcie.pcie_offset), p, sizeof(target_pcie.pcie_offset)); - target_pcie.pcie_offset = le32toh(target_pcie.pcie_offset); - p+=sizeof(target_pcie.pcie_offset); + pefs_get_index_entry(start, &target_pcie); - memcpy(&(target_pcie.pcie_file_id), p, sizeof(target_pcie.pcie_file_id)); - target_pcie.pcie_file_id = le64toh(target_pcie.pcie_file_id); + if (!PEFS_EMPTY_INDEX_ENTRY(&target_pcie)) { printf("cell %d:\n", pos); printf("\thashes = %d\n\toffset = %d\n\tfile id = %llu\n", target_pcie.pcie_nhashes, target_pcie.pcie_offset, target_pcie.pcie_file_id); @@ -137,7 +169,8 @@ } void -pefs_checksum_lookup(char *enc_name, size_t enc_name_len, struct componentname *cnp, struct vnode *vp) +pefs_checksum_lookup(char *enc_name, size_t enc_name_len, + struct componentname *cnp, struct vnode *vp) { struct pefs_checksum_index_entry pcie; struct pefs_node *pn = VP_TO_PN(vp); @@ -146,7 +179,8 @@ int error, r; printf("gpf: checksum code @ lookup\n"); - if ((cnp != NULL && cnp->cn_nameiop != LOOKUP) || (vp->v_type != VREG && vp->v_type != VLNK) + if ((cnp != NULL && cnp->cn_nameiop != LOOKUP) || (vp->v_type != VREG && + vp->v_type != VLNK) || ((pn->pn_flags & PN_NO_CHECKSUM) != 0)) goto not_found; @@ -185,3 +219,165 @@ not_found: pn->pn_flags|= PN_NO_CHECKSUM; } + +static int +pefs_generate_checksum(struct vnode *vp, char *data, ssize_t data_len, + unsigned char **digest, ssize_t *digest_len) +{ + struct pefs_mount *pm = VFS_TO_PEFS(vp->v_mount); + struct pefs_checksum *pcs = &(pm->pm_checksum); + unsigned char *dig; + + switch(pcs->pcs_hash_algo) { + case (PEFS_SHA256): + *digest_len = SHA256_DIGEST_STRING_LENGTH; + dig = malloc(*digest_len, M_TEMP, M_WAITOK); + /* + * XXXgpf: Does this interface work for any length input? + * Also, I should either use a different interface or store the checksums + * in hex during .pefs.checksum creation because turning them to hex + * at this point every single time we have a read is just silly. + */ + SHA256_Data(data, data_len, dig); + break; + case (PEFS_SHA512): + *digest_len = SHA512_DIGEST_STRING_LENGTH; + dig = malloc(*digest_len, M_TEMP, M_WAITOK); + SHA512_Data(data, data_len, dig); + break; + default: + printf("pefs_sanitize invalid algo %s\n", pcs->pcs_hash_algo_name); + return (ENODEV); + } + + *digest = dig; + return (0); +} + +static int +pefs_retrieve_checksum(struct vnode *vp, struct pefs_checksum_index_entry *pcie, + off_t block_offset, unsigned char **digest, ssize_t digest_len) +{ + struct pefs_mount *pm = VFS_TO_PEFS(vp->v_mount); + struct pefs_checksum *pcs = &(pm->pm_checksum); + struct ucred *cred = vp->v_mount->mnt_cred; + struct uio *puio; + struct pefs_chunk pc; + unsigned char *dig; + off_t checksum_offset; + int error, i; + + pefs_chunk_create(&pc, NULL, pcs->pcs_hash_len); + checksum_offset = pcie->pcie_offset + pcs->pcs_hash_len * + (block_offset / PEFS_SECTOR_SIZE); + puio = pefs_chunk_uio(&pc, checksum_offset, UIO_READ); + + /* XXXgpf: gleb says I should use vn_rdwr instead of VOP_READ */ + error = VOP_READ(pcs->pcs_checksumvp, puio, IO_UNIT, cred); + if (error != 0) { + printf("pefs_retrieve_checksum read error %d\n", error); + return (error); + } + + dig = malloc(digest_len, M_TEMP, M_WAITOK); + for (i=0; i < pcs->pcs_hash_len; i++) + sprintf(&dig[i*2],"%02x", ((unsigned char *)pc.pc_base)[i]); + dig[i*2] = '\0'; + + pefs_chunk_free(&pc, NULL); + *digest = dig; + + return (0); +} + +static int +pefs_compare_checksums(unsigned char *digest1, unsigned char *digest2, + ssize_t digest_len) +{ + int error; + + printf("compare dig1: %s\n", digest1); + printf("compare dig2: %s\n", digest2); + + error = memcmp(digest1, digest2, digest_len); + if (error != 0) { + printf("checksum mismatch!\n"); + error = EAUTH; + } + + return (error); +} + +int +pefs_integrity_check(struct vnode *vp, off_t offset, u_quad_t fsize, + struct pefs_chunk *pc) +{ + struct pefs_checksum_index_entry pcie; + struct pefs_node *pn = VP_TO_PN(vp); + ssize_t digest_len, resid; + unsigned char *digest1, *digest2; + char *buf, *end; + long *p; + int error; + + printf("integrity checking!\noffset %llu\n", offset); + + if ((pn->pn_flags & PN_WRONG_CHECKSUM) != 0) + return (EAUTH); + + pefs_get_index_entry(pn->pn_checksum_index_entry, &pcie); + + printf("id: %llu\n", pcie.pcie_file_id); + + buf = (char *)pc->pc_base; + end = buf + pc->pc_size; + + if ((fsize > pcie.pcie_nhashes * PEFS_SECTOR_SIZE) || + (fsize < (pcie.pcie_nhashes - 1) * PEFS_SECTOR_SIZE)) { + printf("file size differs from the one in .pefs.checksum\n"); + pn->pn_flags|= PN_WRONG_CHECKSUM; + return (EAUTH); + } + + while (buf < end) { + if ((end - buf) >= PEFS_SECTOR_SIZE) { + p = (long *)buf; + resid = PEFS_SECTOR_SIZE / sizeof(long); + for (; resid > 0; resid--) + if (*(p++) != 0) + break; + if (resid == 0) { + bzero(buf, PEFS_SECTOR_SIZE); + offset += PEFS_SECTOR_SIZE; + buf += PEFS_SECTOR_SIZE; + continue; + } + resid = PEFS_SECTOR_SIZE; + } + else + resid = end - buf; + + error = pefs_generate_checksum(vp, buf, resid, &digest1, &digest_len); + if (error != 0) + return (error); + + error = pefs_retrieve_checksum(vp, &pcie, offset, &digest2, digest_len); + if (error != 0) { + free(digest1, M_TEMP); + return (error); + } + + error = pefs_compare_checksums(digest1, digest2, digest_len); + free(digest1, M_TEMP); + free(digest2, M_TEMP); + if (error != 0) { + pn->pn_flags|= PN_WRONG_CHECKSUM; + return (error); + } + + buf += resid; + offset += resid; + } + + return (0); +} Modified: soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_checksum.h ============================================================================== --- soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_checksum.h Fri Jul 13 13:24:33 2012 (r239342) +++ soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_checksum.h Fri Jul 13 14:36:05 2012 (r239343) @@ -27,13 +27,40 @@ */ #define PEFS_FILE_CHECKSUM ".pefs.checksum" + #define PEFS_CFH_SIZE 16 /* file header of .pefs.checksum file */ #define PEFS_HT_CELL_SIZE 16 /* hash table cell(bucket) size */ +#define PEFS_CHECKSUM_SUPPORTED_DIGESTS 2 + +#define PEFS_SHA256 0 +#define PEFS_SHA512 1 + +//#define PEFS_EMPTY_INDEX_ENTRY(a) (((struct pefs_checksum_index_entry *)a->pcie_nhashes == 0) ? 1 : 0) +//#define PEFS_NEEDS_CHECKING(a) (((struct pefs_node *)a->pn_checksum_index_entry != NULL) ? 1 : 0) + struct pefs_checksum_index_entry { uint32_t pcie_nhashes; uint32_t pcie_offset; uint64_t pcie_file_id; }; -void pefs_checksum_lookup(char *enc_name, size_t enc_name_len, struct componentname *cnp, struct vnode *vp); +static __inline int +PEFS_EMPTY_INDEX_ENTRY(struct pefs_checksum_index_entry *pcie) +{ + MPASS(pcie != NULL); + return ((pcie->pcie_nhashes == 0) ? 1 : 0); +} + +static __inline int +PEFS_NEEDS_CHECKING(struct pefs_node *pn) +{ + MPASS(pn != NULL); + return ((pn->pn_checksum_index_entry != NULL) ? 1 : 0); +} + +void pefs_checksum_lookup(char *enc_name, size_t enc_name_len, + struct componentname *cnp, struct vnode *vp); +int pefs_integrity_check(struct vnode *vp, off_t offset, + u_quad_t fsize, struct pefs_chunk *pc); +int pefs_sanitize_checksum_header(struct pefs_checksum *pcs); Modified: soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_vfsops.c ============================================================================== --- soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_vfsops.c Fri Jul 13 13:24:33 2012 (r239342) +++ soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_vfsops.c Fri Jul 13 14:36:05 2012 (r239343) @@ -149,7 +149,7 @@ printf("\n+++CHECKSUM FILE HEADER INFO+++\n"); printf("version = %x\nreserved = %d\nhash len = %d\noffset = %d\nsize = %d\nalgo = %s\n\n", pcs->pcs_version, pcs->pcs_reserved, pcs->pcs_hash_len, pcs->pcs_offset_to_hash_table, - pcs->pcs_hash_table_size, pcs->pcs_hash_algo); + pcs->pcs_hash_table_size, pcs->pcs_hash_algo_name); /* print table1 */ printf("+++HASH TABLE 1+++\n\n"); @@ -252,14 +252,20 @@ bufp+=sizeof(pcs->pcs_reserved); memcpy(&(pcs->pcs_hash_len), bufp, sizeof(pcs->pcs_hash_len)); bufp+=sizeof(pcs->pcs_hash_len); - memcpy(&(pcs->pcs_hash_algo), bufp, sizeof(pcs->pcs_hash_algo)); - bufp+=sizeof(pcs->pcs_hash_algo); + memcpy(&(pcs->pcs_hash_algo_name), bufp, sizeof(pcs->pcs_hash_algo_name)); + bufp+=sizeof(pcs->pcs_hash_algo_name); memcpy(&(pcs->pcs_offset_to_hash_table), bufp, sizeof(pcs->pcs_offset_to_hash_table)); bufp+=sizeof(pcs->pcs_offset_to_hash_table); memcpy(&(pcs->pcs_hash_table_size), bufp, sizeof(pcs->pcs_hash_table_size)); pcs->pcs_hash_table_size = le32toh(pcs->pcs_hash_table_size); - /* XXXgpf: [TODO] sanitize input, turn hash_algo to number */ + error = pefs_sanitize_checksum_header(pcs); + if (error != 0) { + printf("pefs_checksum_load: sanitize error %d\n", error); + pefs_chunk_free(&pc, NULL); + vput(checksumvp); + return (error); + } pefs_chunk_free(&pc, NULL); Modified: soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_vnops.c ============================================================================== --- soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_vnops.c Fri Jul 13 13:24:33 2012 (r239342) +++ soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_vnops.c Fri Jul 13 14:36:05 2012 (r239343) @@ -1915,6 +1915,7 @@ return (error); error = pefs_read_int(vp, uio, ioflag, cred, fsize); + return (error); } @@ -1924,6 +1925,7 @@ { struct vnode *lvp = PEFS_LOWERVP(vp); struct uio *puio; + struct pefs_mount *pm = VFS_TO_PEFS(vp->v_mount); struct pefs_node *pn = VP_TO_PN(vp); struct pefs_chunk pc; struct sf_buf *sf; @@ -1980,6 +1982,11 @@ /* XXX assert full buffer is read */ pefs_chunk_setsize(&pc, done); + if ((pm->pm_flags & PM_CHECKSUM) != 0 && PEFS_NEEDS_CHECKING(pn)) { + error = pefs_integrity_check(vp, poffset, fsize, &pc); + if (error != 0) + break; + } pefs_data_decrypt(&pn->pn_tkey, poffset, &pc); if (nocopy == 0) { error = pefs_chunk_copy(&pc, bskip, uio); From owner-svn-soc-all@FreeBSD.ORG Fri Jul 13 16:14:39 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id B24E01065675 for ; Fri, 13 Jul 2012 16:14:37 +0000 (UTC) (envelope-from gpf@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Fri, 13 Jul 2012 16:14:37 +0000 Date: Fri, 13 Jul 2012 16:14:37 +0000 From: gpf@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120713161437.B24E01065675@hub.freebsd.org> Cc: Subject: socsvn commit: r239346 - in soc2012/gpf/pefs_kmod: sbin/pefs sys/fs/pefs X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Jul 2012 16:14:39 -0000 Author: gpf Date: Fri Jul 13 16:14:37 2012 New Revision: 239346 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239346 Log: - code refactoring/cleanup for kernel land also change pxnc_filename's size to MAXNAMLEN Modified: soc2012/gpf/pefs_kmod/sbin/pefs/pefs_checksum.c soc2012/gpf/pefs_kmod/sbin/pefs/pefs_ctl.c soc2012/gpf/pefs_kmod/sbin/pefs/pefs_key.c soc2012/gpf/pefs_kmod/sbin/pefs/pefs_keychain.c soc2012/gpf/pefs_kmod/sbin/pefs/pefs_subr.c soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs.h soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_checksum.c soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_checksum.h soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_vfsops.c soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_vnops.c soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_xbase64.c Modified: soc2012/gpf/pefs_kmod/sbin/pefs/pefs_checksum.c ============================================================================== --- soc2012/gpf/pefs_kmod/sbin/pefs/pefs_checksum.c Fri Jul 13 15:25:10 2012 (r239345) +++ soc2012/gpf/pefs_kmod/sbin/pefs/pefs_checksum.c Fri Jul 13 16:14:37 2012 (r239346) @@ -221,13 +221,13 @@ return (PEFS_ERR_IO); } - dprintf(("read %d bytes from kernel\n\n", xsl.pxsl_slink_len)); + dprintf(("read %d bytes from kernel\n\n", xsl.pxsl_target_len)); dprintf(("printing contents of buf:")); - for (i=0; i < (int)xsl.pxsl_slink_len; i++) - dprintf(("%c", xsl.pxsl_slink[i])); + for (i=0; i < (int)xsl.pxsl_target_len; i++) + dprintf(("%c", xsl.pxsl_target[i])); dprintf(("!\n")); - buf = xsl.pxsl_slink; - buf_len = xsl.pxsl_slink_len; + buf = xsl.pxsl_target; + buf_len = xsl.pxsl_target_len; } EVP_MD_CTX_init(&mdctx); EVP_DigestInit_ex(&mdctx, md, NULL); Modified: soc2012/gpf/pefs_kmod/sbin/pefs/pefs_ctl.c ============================================================================== --- soc2012/gpf/pefs_kmod/sbin/pefs/pefs_ctl.c Fri Jul 13 15:25:10 2012 (r239345) +++ soc2012/gpf/pefs_kmod/sbin/pefs/pefs_ctl.c Fri Jul 13 16:14:37 2012 (r239346) @@ -33,6 +33,7 @@ #include #include #include +#include #include #include Modified: soc2012/gpf/pefs_kmod/sbin/pefs/pefs_key.c ============================================================================== --- soc2012/gpf/pefs_kmod/sbin/pefs/pefs_key.c Fri Jul 13 15:25:10 2012 (r239345) +++ soc2012/gpf/pefs_kmod/sbin/pefs/pefs_key.c Fri Jul 13 16:14:37 2012 (r239346) @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include Modified: soc2012/gpf/pefs_kmod/sbin/pefs/pefs_keychain.c ============================================================================== --- soc2012/gpf/pefs_kmod/sbin/pefs/pefs_keychain.c Fri Jul 13 15:25:10 2012 (r239345) +++ soc2012/gpf/pefs_kmod/sbin/pefs/pefs_keychain.c Fri Jul 13 16:14:37 2012 (r239346) @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include Modified: soc2012/gpf/pefs_kmod/sbin/pefs/pefs_subr.c ============================================================================== --- soc2012/gpf/pefs_kmod/sbin/pefs/pefs_subr.c Fri Jul 13 15:25:10 2012 (r239345) +++ soc2012/gpf/pefs_kmod/sbin/pefs/pefs_subr.c Fri Jul 13 16:14:37 2012 (r239346) @@ -32,6 +32,7 @@ #include #include #include +#include #include #include Modified: soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs.h ============================================================================== --- soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs.h Fri Jul 13 15:25:10 2012 (r239345) +++ soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs.h Fri Jul 13 16:14:37 2012 (r239346) @@ -51,8 +51,7 @@ struct pefs_xnamecsum { uint32_t pxnc_namelen; char pxnc_csum[PEFS_NAME_CSUM_SIZE]; - /* XXXgpf: should probably be MAXNAMLEN */ - char pxnc_filename[MAXPATHLEN]; + char pxnc_filename[MAXNAMLEN]; }; struct pefs_xsector_ctext { @@ -63,10 +62,9 @@ struct pefs_xslink_ctext { uint32_t pxsl_namelen; - uint32_t pxsl_slink_len; + uint32_t pxsl_target_len; char pxsl_filename[MAXPATHLEN]; - /* XXXgpf: rename to target */ - char pxsl_slink[PEFS_SECTOR_SIZE]; + char pxsl_target[PEFS_SECTOR_SIZE]; }; #ifdef _IO Modified: soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_checksum.c ============================================================================== --- soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_checksum.c Fri Jul 13 15:25:10 2012 (r239345) +++ soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_checksum.c Fri Jul 13 16:14:37 2012 (r239346) @@ -48,6 +48,68 @@ const char *pefs_checksum_supported_digests[] = {"sha256","sha512"}; uint8_t pefs_checksum_supported_hash_lengths[] = {32, 64}; +/* XXXgpf: tmp 4 dbg purposes */ +//static void +//pefs_dbg_checksum_file(struct pefs_checksum *pcs) +//{ + //char *p; + //int i; + //uint32_t nhashes; + //uint32_t offset; + //uint64_t file_id; + + ///* print .pefs.checksum file header info */ + //printf("\n+++CHECKSUM FILE HEADER INFO+++\n"); + //printf("version = %x\nreserved = %d\nhash len = %d\noffset = %d\nsize = %d\nalgo = %s\n\n", + //pcs->pcs_version, pcs->pcs_reserved, pcs->pcs_hash_len, pcs->pcs_offset_to_hash_table, + //pcs->pcs_hash_table_size, pcs->pcs_hash_algo_name); + + ///* print table1 */ + //printf("+++HASH TABLE 1+++\n\n"); + //for (i = 0; i < pcs->pcs_hash_table_size; i++) { + //p = &(pcs->pcs_table1[i * PEFS_HT_CELL_SIZE]); + + //memcpy(&nhashes, p, sizeof(nhashes)); + //nhashes = le32toh(nhashes); + //if (nhashes != 0) { + //p+=sizeof(nhashes); + //memcpy(&offset, p, sizeof(offset)); + //offset = le32toh(offset); + //p+=sizeof(offset); + //memcpy(&file_id, p, sizeof(file_id)); + //file_id = le64toh(file_id); + //printf("cell %d:\n", i); + //printf("\thashes = %d\n\toffset = %d\n\tfile id = %llu\n", + //nhashes, offset, file_id); + //} + //else + //printf("cell %d: empty\n", i); + //} + + ///* print table2 */ + //printf("\n+++HASH TABLE 2+++\n\n"); + //for (i = 0; i < pcs->pcs_hash_table_size; i++) { + //p = &(pcs->pcs_table2[i * PEFS_HT_CELL_SIZE]); + + //memcpy(&nhashes, p, sizeof(nhashes)); + //nhashes = le32toh(nhashes); + //if (nhashes != 0) { + //p+=sizeof(nhashes); + //memcpy(&offset, p, sizeof(offset)); + //offset = le32toh(offset); + //p+=sizeof(offset); + //memcpy(&file_id, p, sizeof(file_id)); + //file_id = le64toh(file_id); + //printf("cell %d:\n", i); + //printf("\thashes = %d\n\toffset = %d\n\tfile id = %llu\n", + //nhashes, offset, file_id); + //} + //else + //printf("cell %d: empty\n", i); + //} +//} + +/* sanitize .pefs.checkum's global file header that's read during VFS_MOUNT() */ int pefs_sanitize_checksum_header(struct pefs_checksum *pcs) { @@ -64,14 +126,14 @@ /* FALLTHROUGH */ case (PEFS_SHA256): case (PEFS_SHA512): - printf("digest: %s\n", pcs->pcs_hash_algo_name); + dprintf(("digest: %s\n", pcs->pcs_hash_algo_name)); if (pcs->pcs_hash_len != pefs_checksum_supported_hash_lengths[i]) { - printf("pefs_sanitize invalid algo len %u\n", pcs->pcs_hash_len); + dprintf(("pefs_sanitize invalid algo len %u\n", pcs->pcs_hash_len)); error = EINVAL; } break; default: - printf("pefs_sanitize invalid algo %s\n", pcs->pcs_hash_algo_name); + dprintf(("pefs_sanitize invalid algo %s\n", pcs->pcs_hash_algo_name)); error = ENODEV; break; } @@ -80,23 +142,25 @@ } static uint32_t -pefs_checksum_hash1(struct pefs_checksum *pc, struct pefs_checksum_index_entry *pcie) +pefs_checksum_hash1(struct pefs_checksum *pc, + struct pefs_checksum_index_entry *pcie) { uint32_t nbucket; nbucket = pcie->pcie_file_id % pc->pcs_hash_table_size; - printf("hash1: goto bucket %d\n", nbucket); + dprintf(("hash1: goto bucket %d\n", nbucket)); return (nbucket); } static uint32_t -pefs_checksum_hash2(struct pefs_checksum *pc, struct pefs_checksum_index_entry *pcie) +pefs_checksum_hash2(struct pefs_checksum *pc, + struct pefs_checksum_index_entry *pcie) { uint32_t nbucket; - nbucket = fnv_64_buf(&(pcie->pcie_file_id), sizeof(pcie->pcie_file_id), FNV1_64_INIT) - % pc->pcs_hash_table_size; - printf("hash2: goto bucket %d\n", nbucket); + nbucket = fnv_64_buf(&(pcie->pcie_file_id), sizeof(pcie->pcie_file_id), + FNV1_64_INIT) % pc->pcs_hash_table_size; + dprintf(("hash2: goto bucket %d\n", nbucket)); return (nbucket); } @@ -122,7 +186,8 @@ } static int -pefs_checksum_index_lookup(struct pefs_checksum_index_entry *pcie, struct vnode *vp) +pefs_checksum_index_lookup(struct pefs_checksum_index_entry *pcie, + struct vnode *vp) { struct pefs_checksum_index_entry target_pcie; struct pefs_mount *pm = VFS_TO_PEFS(vp->v_mount); @@ -136,13 +201,14 @@ pefs_get_index_entry(start, &target_pcie); if (!PEFS_EMPTY_INDEX_ENTRY(&target_pcie)) { - printf("cell %d:\n", pos); - printf("\thashes = %d\n\toffset = %d\n\tfile id = %llu\n", - target_pcie.pcie_nhashes, target_pcie.pcie_offset, target_pcie.pcie_file_id); + dprintf(("cell %d:\n", pos)); + dprintf(("\thashes = %d\n\toffset = %d\n\tfile id = %llu\n", + target_pcie.pcie_nhashes, target_pcie.pcie_offset, + target_pcie.pcie_file_id)); if (target_pcie.pcie_file_id == pcie->pcie_file_id) { pn->pn_checksum_index_entry = start; - printf("checksum lookup: found1!\n"); + dprintf(("checksum lookup: found1!\n")); return (0); } } @@ -152,19 +218,20 @@ pefs_get_index_entry(start, &target_pcie); if (!PEFS_EMPTY_INDEX_ENTRY(&target_pcie)) { - printf("cell %d:\n", pos); - printf("\thashes = %d\n\toffset = %d\n\tfile id = %llu\n", - target_pcie.pcie_nhashes, target_pcie.pcie_offset, target_pcie.pcie_file_id); + dprintf(("cell %d:\n", pos)); + dprintf(("\thashes = %d\n\toffset = %d\n\tfile id = %llu\n", + target_pcie.pcie_nhashes, target_pcie.pcie_offset, + target_pcie.pcie_file_id)); if (target_pcie.pcie_file_id == pcie->pcie_file_id) { pn->pn_checksum_index_entry = start; - printf("checksum lookup: found2!\n"); + dprintf(("checksum lookup: found2!\n")); return (0); } } pn->pn_checksum_index_entry = NULL; - printf("checksum lookup: not found!\n"); + dprintf(("checksum lookup: not found!\n")); return (ENOENT); } @@ -178,14 +245,13 @@ size_t buf_len; int error, r; - printf("gpf: checksum code @ lookup\n"); + dprintf(("gpf: checksum code @ lookup\n")); if ((cnp != NULL && cnp->cn_nameiop != LOOKUP) || (vp->v_type != VREG && vp->v_type != VLNK) || ((pn->pn_flags & PN_NO_CHECKSUM) != 0)) goto not_found; /* XXXgpf: What if user wants integrity checking for .pefs.db or .conf? */ - /* XXXgpf: [TODO] move this check to a mini function */ if (strncmp(enc_name, ".pefs.db", enc_name_len) == 0 || strncmp(enc_name, ".pefs.conf", enc_name_len) == 0 || strncmp(enc_name, ".pefs.checksum", enc_name_len) == 0) @@ -200,12 +266,12 @@ if (r <= 0) { /* XXXgpf: I sincerely doubt an error can occur here */ error = EINVAL; - printf("name_pton error: %d\n", error); + dprintf(("name_pton error: %d\n", error)); } else { memcpy(&(pcie.pcie_file_id), buf, sizeof(pcie.pcie_file_id)); pcie.pcie_file_id = be64toh(pcie.pcie_file_id); - printf("id to lookup: %llu\n", pcie.pcie_file_id); + dprintf(("id to lookup: %llu\n", pcie.pcie_file_id)); error = pefs_checksum_index_lookup(&pcie, vp); if (error != 0) { free(buf, M_TEMP); @@ -234,9 +300,10 @@ dig = malloc(*digest_len, M_TEMP, M_WAITOK); /* * XXXgpf: Does this interface work for any length input? - * Also, I should either use a different interface or store the checksums - * in hex during .pefs.checksum creation because turning them to hex - * at this point every single time we have a read is just silly. + * Also, I should either use a different interface or store the + * checksums in hex during .pefs.checksum creation because turning + * them to hex at this point every single time we have a read is + * just silly. */ SHA256_Data(data, data_len, dig); break; @@ -246,7 +313,7 @@ SHA512_Data(data, data_len, dig); break; default: - printf("pefs_sanitize invalid algo %s\n", pcs->pcs_hash_algo_name); + dprintf(("pefs_sanitize invalid algo %s\n", pcs->pcs_hash_algo_name)); return (ENODEV); } @@ -275,7 +342,7 @@ /* XXXgpf: gleb says I should use vn_rdwr instead of VOP_READ */ error = VOP_READ(pcs->pcs_checksumvp, puio, IO_UNIT, cred); if (error != 0) { - printf("pefs_retrieve_checksum read error %d\n", error); + dprintf(("pefs_retrieve_checksum read error %d\n", error)); return (error); } @@ -296,12 +363,12 @@ { int error; - printf("compare dig1: %s\n", digest1); - printf("compare dig2: %s\n", digest2); + dprintf(("compare dig1: %s\n", digest1)); + dprintf(("compare dig2: %s\n", digest2)); error = memcmp(digest1, digest2, digest_len); if (error != 0) { - printf("checksum mismatch!\n"); + dprintf(("checksum mismatch!\n")); error = EAUTH; } @@ -320,21 +387,21 @@ long *p; int error; - printf("integrity checking!\noffset %llu\n", offset); + dprintf(("integrity checking!\noffset %llu\n", offset)); if ((pn->pn_flags & PN_WRONG_CHECKSUM) != 0) return (EAUTH); pefs_get_index_entry(pn->pn_checksum_index_entry, &pcie); - printf("id: %llu\n", pcie.pcie_file_id); + dprintf(("id: %llu\n", pcie.pcie_file_id)); buf = (char *)pc->pc_base; end = buf + pc->pc_size; if ((fsize > pcie.pcie_nhashes * PEFS_SECTOR_SIZE) || (fsize < (pcie.pcie_nhashes - 1) * PEFS_SECTOR_SIZE)) { - printf("file size differs from the one in .pefs.checksum\n"); + dprintf(("file size differs from the one in .pefs.checksum\n")); pn->pn_flags|= PN_WRONG_CHECKSUM; return (EAUTH); } Modified: soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_checksum.h ============================================================================== --- soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_checksum.h Fri Jul 13 15:25:10 2012 (r239345) +++ soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_checksum.h Fri Jul 13 16:14:37 2012 (r239346) @@ -36,8 +36,16 @@ #define PEFS_SHA256 0 #define PEFS_SHA512 1 -//#define PEFS_EMPTY_INDEX_ENTRY(a) (((struct pefs_checksum_index_entry *)a->pcie_nhashes == 0) ? 1 : 0) -//#define PEFS_NEEDS_CHECKING(a) (((struct pefs_node *)a->pn_checksum_index_entry != NULL) ? 1 : 0) +/* + * XXXgpf: use this instead of PEFS_DEBUG so as to lower the number of debugging + * messages during code development. + */ +//#define PEFS_INTEGRITY_DEBUG +#if defined (PEFS_INTEGRITY_DEBUG) +#define dprintf(a) printf a +#else +#define dprintf(a) (void)0 +#endif struct pefs_checksum_index_entry { uint32_t pcie_nhashes; Modified: soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_vfsops.c ============================================================================== --- soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_vfsops.c Fri Jul 13 15:25:10 2012 (r239345) +++ soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_vfsops.c Fri Jul 13 16:14:37 2012 (r239346) @@ -45,6 +45,7 @@ #include #include #include +#include #include #include @@ -129,74 +130,12 @@ { if (vp == NULL) return; - printf("%s is locked: %d\n", str, VOP_ISLOCKED(vp)); - printf("%s usecount: %d\n", str, vp->v_usecount); - printf("%s holdcnt: %d\n", str, vp->v_holdcnt); - printf("%s writecount: %d\n", str, vp->v_writecount); + dprintf(("%s is locked: %d\n", str, VOP_ISLOCKED(vp))); + dprintf(("%s usecount: %d\n", str, vp->v_usecount)); + dprintf(("%s holdcnt: %d\n", str, vp->v_holdcnt)); + dprintf(("%s writecount: %d\n", str, vp->v_writecount)); } -/* XXXgpf: tmp 4 dbg purposes */ -static void -pefs_dbg_checksum_file(struct pefs_checksum *pcs) -{ - char *p; - int i; - uint32_t nhashes; - uint32_t offset; - uint64_t file_id; - - /* print .pefs.checksum file header info */ - printf("\n+++CHECKSUM FILE HEADER INFO+++\n"); - printf("version = %x\nreserved = %d\nhash len = %d\noffset = %d\nsize = %d\nalgo = %s\n\n", - pcs->pcs_version, pcs->pcs_reserved, pcs->pcs_hash_len, pcs->pcs_offset_to_hash_table, - pcs->pcs_hash_table_size, pcs->pcs_hash_algo_name); - - /* print table1 */ - printf("+++HASH TABLE 1+++\n\n"); - for (i = 0; i < pcs->pcs_hash_table_size; i++) { - p = &(pcs->pcs_table1[i * PEFS_HT_CELL_SIZE]); - - memcpy(&nhashes, p, sizeof(nhashes)); - nhashes = le32toh(nhashes); - if (nhashes != 0) { - p+=sizeof(nhashes); - memcpy(&offset, p, sizeof(offset)); - offset = le32toh(offset); - p+=sizeof(offset); - memcpy(&file_id, p, sizeof(file_id)); - file_id = le64toh(file_id); - printf("cell %d:\n", i); - printf("\thashes = %d\n\toffset = %d\n\tfile id = %llu\n", - nhashes, offset, file_id); - } - else - printf("cell %d: empty\n", i); - } - - /* print table2 */ - printf("\n+++HASH TABLE 2+++\n\n"); - for (i = 0; i < pcs->pcs_hash_table_size; i++) { - p = &(pcs->pcs_table2[i * PEFS_HT_CELL_SIZE]); - - memcpy(&nhashes, p, sizeof(nhashes)); - nhashes = le32toh(nhashes); - if (nhashes != 0) { - p+=sizeof(nhashes); - memcpy(&offset, p, sizeof(offset)); - offset = le32toh(offset); - p+=sizeof(offset); - memcpy(&file_id, p, sizeof(file_id)); - file_id = le64toh(file_id); - printf("cell %d:\n", i); - printf("\thashes = %d\n\toffset = %d\n\tfile id = %llu\n", - nhashes, offset, file_id); - } - else - printf("cell %d: empty\n", i); - } -} - -/* XXXgpf: [TODO] move this to pefs_checksum.c */ static int pefs_checksum_load(struct mount *mp) { @@ -217,14 +156,15 @@ pathlen = MAXPATHLEN + 1; path = malloc(pathlen, M_TEMP, M_WAITOK); - snprintf(path, pathlen, "%s/%s", mp->mnt_stat.f_mntfromname, PEFS_FILE_CHECKSUM); + snprintf(path, pathlen, "%s/%s", mp->mnt_stat.f_mntfromname, + PEFS_FILE_CHECKSUM); /* grab a vp for our checksum file */ NDINIT(ndp, LOOKUP, LOCKLEAF, UIO_SYSSPACE, path, curthread); error = namei(ndp); free(path, M_TEMP); if (error != 0) { - printf("pefs_checksum_load: namei error %d\n", error); + dprintf(("pefs_checksum_load: namei error %d\n", error)); return (error); } @@ -239,7 +179,7 @@ /* XXXgpf: gleb says I should use vn_rdwr instead of VOP_READ */ error = VOP_READ(checksumvp, puio, IO_UNIT, cred); if (error != 0) { - printf("pefs_checksum_load: vop_read1 error %d\n", error); + dprintf(("pefs_checksum_load: vop_read1 error %d\n", error)); pefs_chunk_free(&pc, NULL); vput(checksumvp); return (error); @@ -254,14 +194,15 @@ bufp+=sizeof(pcs->pcs_hash_len); memcpy(&(pcs->pcs_hash_algo_name), bufp, sizeof(pcs->pcs_hash_algo_name)); bufp+=sizeof(pcs->pcs_hash_algo_name); - memcpy(&(pcs->pcs_offset_to_hash_table), bufp, sizeof(pcs->pcs_offset_to_hash_table)); + memcpy(&(pcs->pcs_offset_to_hash_table), bufp, + sizeof(pcs->pcs_offset_to_hash_table)); bufp+=sizeof(pcs->pcs_offset_to_hash_table); memcpy(&(pcs->pcs_hash_table_size), bufp, sizeof(pcs->pcs_hash_table_size)); pcs->pcs_hash_table_size = le32toh(pcs->pcs_hash_table_size); error = pefs_sanitize_checksum_header(pcs); if (error != 0) { - printf("pefs_checksum_load: sanitize error %d\n", error); + dprintf(("pefs_checksum_load: sanitize error %d\n", error)); pefs_chunk_free(&pc, NULL); vput(checksumvp); return (error); @@ -276,7 +217,7 @@ error = VOP_READ(checksumvp, puio, IO_UNIT, cred); if (error != 0) { - printf("pefs_checksum_load: vop_read2 error %d\n", error); + dprintf(("pefs_checksum_load: vop_read2 error %d\n", error)); pefs_chunk_free(&pc, NULL); vput(checksumvp); return (error); @@ -287,11 +228,12 @@ pefs_chunk_free(&pc, NULL); pefs_chunk_create(&pc, NULL, buflen); - puio = pefs_chunk_uio(&pc, pcs->pcs_offset_to_hash_table + buflen, UIO_READ); + puio = pefs_chunk_uio(&pc, pcs->pcs_offset_to_hash_table + + buflen, UIO_READ); error = VOP_READ(checksumvp, puio, IO_UNIT, cred); if (error != 0) { - printf("pefs_checksum_load: vop_read3 error %d\n", error); + dprintf(("pefs_checksum_load: vop_read3 error %d\n", error)); pefs_chunk_free(&pc, NULL); free(pcs->pcs_table1, M_PEFSCSTABLE); vput(checksumvp); @@ -302,9 +244,6 @@ memcpy(pcs->pcs_table2, pc.pc_base, buflen); pefs_chunk_free(&pc, NULL); - /* print everything */ - pefs_dbg_checksum_file(pcs); - pefs_dbg_vnode(checksumvp, "before VOP_UNLOCK checksumvp"); /* keep the reference for checksumvp */ VOP_UNLOCK(checksumvp, 0); @@ -353,7 +292,7 @@ opt_checksum = -1; if (vfs_flagopt(mp->mnt_optnew, "checksum", NULL, 0)) { vfs_deleteopt(mp->mnt_optnew, "checksum"); - printf("checksum!\n"); + dprintf(("checksum!\n")); opt_checksum = 1; } Modified: soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_vnops.c ============================================================================== --- soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_vnops.c Fri Jul 13 15:25:10 2012 (r239345) +++ soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_vnops.c Fri Jul 13 16:14:37 2012 (r239346) @@ -486,9 +486,8 @@ int nokey_lookup, skip_lookup; int error; - /* XXXgpf: [TODO] PEFSDEBUGs instead of printfs */ - printf("pefs_lookup: op=%lx, name=%.*s\n", - cnp->cn_nameiop, (int)cnp->cn_namelen, cnp->cn_nameptr); + dprintf(("pefs_lookup: op=%lx, name=%.*s\n", + cnp->cn_nameiop, (int)cnp->cn_namelen, cnp->cn_nameptr)); pefs_enccn_init(&enccn); @@ -566,12 +565,17 @@ pm = VFS_TO_PEFS(vp->v_mount); if ((pm->pm_flags & PM_CHECKSUM) != 0) { if (nokey_lookup) { - printf("cnp name=%.*s\n",(int)cnp->cn_namelen, cnp->cn_nameptr); - pefs_checksum_lookup(cnp->cn_nameptr, cnp->cn_namelen, cnp, vp); + dprintf(("cnp name=%.*s\n",(int)cnp->cn_namelen, + cnp->cn_nameptr)); + pefs_checksum_lookup(cnp->cn_nameptr, + cnp->cn_namelen, cnp, vp); } else { - printf("enccnp name=%.*s\n",(int)enccn.pec_cn.cn_namelen, enccn.pec_cn.cn_nameptr); - pefs_checksum_lookup(enccn.pec_cn.cn_nameptr, enccn.pec_cn.cn_namelen, cnp, vp); + dprintf(("enccnp name=%.*s\n", + (int)enccn.pec_cn.cn_namelen, + enccn.pec_cn.cn_nameptr)); + pefs_checksum_lookup(enccn.pec_cn.cn_nameptr, + enccn.pec_cn.cn_namelen, cnp, vp); } } *ap->a_vpp = vp; @@ -2503,7 +2507,7 @@ vn_lock(vp, LK_EXCLUSIVE); if (vp->v_type != VREG) { - printf("pefs_ioctl: PEFS_GETSECTORCTEXT vp is not a reg file\n"); + dprintf(("pefs_ioctl: PEFS_GETSECTORCTEXT vp is not a reg file\n")); VOP_UNLOCK(vp, 0); return (EOPNOTSUPP); } @@ -2514,17 +2518,18 @@ return (error); } - if (xsct->pxsct_ctext_len > PEFS_SECTOR_SIZE || xsct->pxsct_ctext_len == 0 - || xsct->pxsct_ctext_len > fsize) { - printf("pefs_ioctl: PEFS_GETSECTORCTEXT invalid len: %d\n", - xsct->pxsct_ctext_len); + if (xsct->pxsct_ctext_len > PEFS_SECTOR_SIZE || + xsct->pxsct_ctext_len == 0 || + xsct->pxsct_ctext_len > fsize) { + dprintf(("pefs_ioctl: PEFS_GETSECTORCTEXT invalid len: %d\n", + xsct->pxsct_ctext_len)); VOP_UNLOCK(vp, 0); return (EINVAL); } if (xsct->pxsct_offset > (fsize - xsct->pxsct_ctext_len)) { - printf("pefs_ioctl: PEFS_GETSECTORCTEXT invalid offset: %llu\n", - xsct->pxsct_offset); + dprintf(("pefs_ioctl: PEFS_GETSECTORCTEXT invalid offset: %llu\n", + xsct->pxsct_offset)); VOP_UNLOCK(vp, 0); return (EINVAL); } @@ -2543,23 +2548,23 @@ break; case PEFS_GETNAMECSUM: vn_lock(vp, LK_EXCLUSIVE); - /* XXXgpf: should I change printf to something else? e.g. PEFSDEBUG */ if (vp->v_type != VDIR) { - printf("pefs_ioctl: PEFS_GETNAMEMAC vp is not a directory\n"); + dprintf(("pefs_ioctl: PEFS_GETNAMEMAC vp is not a directory\n")); VOP_UNLOCK(vp, 0); return (ENOTDIR); } if (strnlen(xncs->pxnc_filename, sizeof(xncs->pxnc_filename)) != xncs->pxnc_namelen) { - printf("pefs_ioctl: PEFS_GETNAMEMAC incorrect pxnc_namelen %d\n", xncs->pxnc_namelen); + dprintf(("pefs_ioctl: PEFS_GETNAMEMAC incorrect pxnc_namelen %d\n", + xncs->pxnc_namelen)); VOP_UNLOCK(vp, 0); return (EINVAL); } if (strchr(xncs->pxnc_filename, '/') != NULL) { - printf("pefs_ioctl: PEFS_GETNAMEMAC pxnc_filename contains '/'\n"); - VOP_UNLOCK(vp, 0); + dprintf(("pefs_ioctl: PEFS_GETNAMEMAC pxnc_filename contains '/'\n"); + VOP_UNLOCK(vp, 0)); return (EINVAL); } @@ -2610,43 +2615,45 @@ break; case PEFS_GETSLINKCTEXT: if (vp->v_type != VDIR) { - printf("pefs_ioctl: PEFS_GETSLINKCTEXT vp is not a directory\n"); + dprintf(("pefs_ioctl: PEFS_GETSLINKCTEXT vp is not a directory\n")); VOP_UNLOCK(vp, 0); return (ENOTDIR); } if (strnlen(xsl->pxsl_filename, sizeof(xsl->pxsl_filename)) != xsl->pxsl_namelen) { - printf("pefs_ioctl: PEFS_GETSLINKCTEXT incorrect namelen %d\n", xsl->pxsl_namelen); + dprintf(("pefs_ioctl: PEFS_GETSLINKCTEXT incorrect namelen %d\n", + xsl->pxsl_namelen)); VOP_UNLOCK(vp, 0); return (EINVAL); } if (strchr(xsl->pxsl_filename, '/') != NULL) { - printf("pefs_ioctl: PEFS_GETSLINKCTEXT filename contains '/'\n"); + dprintf(("pefs_ioctl: PEFS_GETSLINKCTEXT filename contains '/'\n")); VOP_UNLOCK(vp, 0); return (EINVAL); } /* grab a vnodep for our symlink */ - NDINIT_ATVP(ndp, LOOKUP, MPSAFE | LOCKPARENT | LOCKLEAF | NOFOLLOW, UIO_SYSSPACE, xsl->pxsl_filename, vp, td); + NDINIT_ATVP(ndp, LOOKUP, MPSAFE | LOCKPARENT | LOCKLEAF | NOFOLLOW, + UIO_SYSSPACE, xsl->pxsl_filename, vp, td); error = namei(ndp); if (error != 0) { - printf("pefs_ioctl: PEFS_GETSLINKCTEXT namei error %d\n", error); + dprintf(("pefs_ioctl: PEFS_GETSLINKCTEXT namei error %d\n", error)); return (error); } NDFREE(ndp, NDF_ONLY_PNBUF); svp = ndp->ni_vp; if (ndp->ni_dvp != vp) { - printf("pefs_ioctl: PEFS_GETSLINKCTEXT namei returned wrong parent\n"); + dprintf(("pefs_ioctl: PEFS_GETSLINKCTEXT namei wrong parent\n")); vput(svp); VOP_UNLOCK(vp, 0); return (ENOENT); } if (svp->v_type != VLNK) { - printf("pefs_ioctl: PEFS_GETSLINKCTEXT svp is not a symlink\n"); + dprintf(("pefs_ioctl: PEFS_GETSLINKCTEXT svp is not a symlink\n")); vput(svp); VOP_UNLOCK(vp, 0); return (EFTYPE); @@ -2661,9 +2668,9 @@ error = VOP_READLINK(slvp, puio, cred); - xsl->pxsl_slink_len = pc.pc_size - pc.pc_uio.uio_resid; + xsl->pxsl_target_len = pc.pc_size - pc.pc_uio.uio_resid; if (error == 0) - memcpy(xsl->pxsl_slink, pc.pc_base, xsl->pxsl_slink_len); + memcpy(xsl->pxsl_target, pc.pc_base, xsl->pxsl_target_len); pefs_chunk_free(&pc, pn); vput(svp); Modified: soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_xbase64.c ============================================================================== --- soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_xbase64.c Fri Jul 13 15:25:10 2012 (r239345) +++ soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_xbase64.c Fri Jul 13 16:14:37 2012 (r239346) @@ -48,6 +48,7 @@ #include #include #include +#include #include From owner-svn-soc-all@FreeBSD.ORG Fri Jul 13 16:18:07 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 99F46106566C for ; Fri, 13 Jul 2012 16:18:05 +0000 (UTC) (envelope-from gpf@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Fri, 13 Jul 2012 16:18:05 +0000 Date: Fri, 13 Jul 2012 16:18:05 +0000 From: gpf@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120713161805.99F46106566C@hub.freebsd.org> Cc: Subject: socsvn commit: r239347 - soc2012/gpf/pefs_kmod/sys/fs/pefs X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Jul 2012 16:18:07 -0000 Author: gpf Date: Fri Jul 13 16:18:05 2012 New Revision: 239347 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239347 Log: - +1 size for a few buffers/string lengths Modified: soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs.h soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_vnops.c Modified: soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs.h ============================================================================== --- soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs.h Fri Jul 13 16:14:37 2012 (r239346) +++ soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs.h Fri Jul 13 16:18:05 2012 (r239347) @@ -51,7 +51,7 @@ struct pefs_xnamecsum { uint32_t pxnc_namelen; char pxnc_csum[PEFS_NAME_CSUM_SIZE]; - char pxnc_filename[MAXNAMLEN]; + char pxnc_filename[MAXNAMLEN + 1]; }; struct pefs_xsector_ctext { @@ -63,7 +63,7 @@ struct pefs_xslink_ctext { uint32_t pxsl_namelen; uint32_t pxsl_target_len; - char pxsl_filename[MAXPATHLEN]; + char pxsl_filename[MAXPATHLEN + 1]; char pxsl_target[PEFS_SECTOR_SIZE]; }; Modified: soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_vnops.c ============================================================================== --- soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_vnops.c Fri Jul 13 16:14:37 2012 (r239346) +++ soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_vnops.c Fri Jul 13 16:18:05 2012 (r239347) @@ -2663,7 +2663,7 @@ slvp = PEFS_LOWERVP(svp); pn = VP_TO_PN(svp); - pefs_chunk_create(&pc, pn, MAXPATHLEN); + pefs_chunk_create(&pc, pn, MAXPATHLEN + 1); puio = pefs_chunk_uio(&pc, 0, UIO_READ); error = VOP_READLINK(slvp, puio, cred); From owner-svn-soc-all@FreeBSD.ORG Fri Jul 13 17:33:36 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 3B5E5106564A for ; Fri, 13 Jul 2012 17:33:34 +0000 (UTC) (envelope-from vbotton@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Fri, 13 Jul 2012 17:33:34 +0000 Date: Fri, 13 Jul 2012 17:33:34 +0000 From: vbotton@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120713173334.3B5E5106564A@hub.freebsd.org> Cc: Subject: socsvn commit: r239348 - soc2012/vbotton/head/sys/fs/ntfs X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Jul 2012 17:33:36 -0000 Author: vbotton Date: Fri Jul 13 17:33:32 2012 New Revision: 239348 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239348 Log: Add bootsector read, and VFS macros Modified: soc2012/vbotton/head/sys/fs/ntfs/ntfs_vfsops.c Modified: soc2012/vbotton/head/sys/fs/ntfs/ntfs_vfsops.c ============================================================================== --- soc2012/vbotton/head/sys/fs/ntfs/ntfs_vfsops.c Fri Jul 13 16:18:05 2012 (r239347) +++ soc2012/vbotton/head/sys/fs/ntfs/ntfs_vfsops.c Fri Jul 13 17:33:32 2012 (r239348) @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -51,7 +52,7 @@ #include #include - +#define DEBUG 1 #include "ntfs.h" #include "ntfs_attr.h" #include "ntfs_attr_list.h" @@ -130,6 +131,11 @@ } #endif +static uint64_t vfs_devblocksize(struct mount *mp) +{ + return (mp->mnt_stat.f_bsize); +} + /** * ntfs_boot_sector_is_valid - check if @b contains a valid ntfs boot sector * @mp: Mount of the device to which @b belongs. @@ -141,7 +147,6 @@ * * @mp is only needed for warning/error output, i.e. it can be NULL. */ -#if defined (UNUSED) static BOOL ntfs_boot_sector_is_valid(const mount_t mp, const NTFS_BOOT_SECTOR *b) { @@ -226,7 +231,6 @@ ntfs_debug("Not an NTFS boot sector."); return FALSE; } -#endif /** * ntfs_boot_sector_read - read the ntfs boot sector of a device @@ -253,8 +257,8 @@ * invalidating them when we release them. This is needed because the * buffer(s) may get read later using a different vnode ($Boot for example). */ -#if defined (DIRTY_HACK) -static errno_t ntfs_boot_sector_read(ntfs_volume *vol, kauth_cred_t cred, + +static errno_t ntfs_boot_sector_read(ntfs_volume *vol, struct ucred *cred, buf_t *buf, NTFS_BOOT_SECTOR **bs) { daddr_t nr_blocks = vol->nr_blocks; @@ -262,22 +266,24 @@ "Unable to read %s boot sector (error %d)."; mount_t mp = vol->mp; vnode_t dev_vn = vol->dev_vn; - buf_t primary, backup; + buf_t primary = NULL, backup = NULL; NTFS_BOOT_SECTOR *bs1, *bs2; - errno_t err, err2; + errno_t err/*, err2*/; u32 blocksize = vfs_devblocksize(mp); ntfs_debug("Entering."); /* Try to read primary boot sector. */ - err = buf_meta_bread(dev_vn, 0, blocksize, cred, &primary); - buf_setflags(primary, B_NOCACHE); + err = bread(dev_vn, 0, blocksize, cred, &primary); + //buf_setflags(primary, B_NOCACHE); + primary->b_flags |= B_NOCACHE; if (!err) { - err = buf_map(primary, (caddr_t*)&bs1); - if (err) { - ntfs_error(mp, "Failed to map buffer of primary boot " - "sector (error %d).", err); - bs1 = NULL; - } else { + // err = buf_map(primary, (caddr_t*)&bs1); + // if (err) { + // ntfs_error(mp, "Failed to map buffer of primary boot " + // "sector (error %d).", err); + // bs1 = NULL; + // } else { + bs1 = (NTFS_BOOT_SECTOR*)primary->b_data; if (ntfs_boot_sector_is_valid(mp, bs1)) { *buf = primary; *bs = bs1; @@ -286,7 +292,7 @@ } ntfs_error(mp, "Primary boot sector is invalid."); err = EIO; - } + // } } else { ntfs_error(mp, read_err_str, "primary", err); bs1 = NULL; @@ -294,66 +300,61 @@ if (!(vol->on_errors & ON_ERRORS_RECOVER)) { ntfs_error(mp, "Mount option errors=recover not used. " "Aborting without trying to recover."); - if (bs1) { - err2 = buf_unmap(primary); - if (err2) - ntfs_error(mp, "Failed to unmap buffer of " - "primary boot sector (error " - "%d).", err2); - } - buf_brelse(primary); + brelse(primary); return err; } /* Try to read NT4+ backup boot sector. */ - err = buf_meta_bread(dev_vn, nr_blocks - 1, blocksize, cred, &backup); - buf_setflags(backup, B_NOCACHE); + err = bread(dev_vn, nr_blocks - 1, blocksize, cred, &backup); + backup->b_flags |= B_NOCACHE; if (!err) { - err = buf_map(backup, (caddr_t*)&bs2); - if (err) - ntfs_error(mp, "Failed to map buffer of backup boot " - "sector (error %d).", err); - else { + //err = buf_map(backup, (caddr_t*)&bs2); + //if (err) + // ntfs_error(mp, "Failed to map buffer of backup boot " + // "sector (error %d).", err); + //else { + bs2 = (NTFS_BOOT_SECTOR*)backup->b_data; if (ntfs_boot_sector_is_valid(mp, bs2)) goto hotfix_primary_boot_sector; - err = buf_unmap(backup); - if (err) - ntfs_error(mp, "Failed to unmap buffer of " - "backup boot sector (error " - "%d).", err); - } + //err = buf_unmap(backup); + //if (err) + // ntfs_error(mp, "Failed to unmap buffer of " + // "backup boot sector (error " + // "%d).", err); + //} } else ntfs_error(mp, read_err_str, "backup", err); - buf_brelse(backup); + brelse(backup); /* Try to read NT3.51- backup boot sector. */ - err = buf_meta_bread(dev_vn, nr_blocks >> 1, blocksize, cred, &backup); - buf_setflags(backup, B_NOCACHE); + err = bread(dev_vn, nr_blocks >> 1, blocksize, cred, &backup); + backup->b_flags |= B_NOCACHE; if (!err) { - err = buf_map(backup, (caddr_t*)&bs2); - if (err) - ntfs_error(mp, "Failed to map buffer of old backup " - "boot sector (error %d).", err); - else { + //err = buf_map(backup, (caddr_t*)&bs2); + //if (err) + // ntfs_error(mp, "Failed to map buffer of old backup " + // "boot sector (error %d).", err); + //else { + bs2 = (NTFS_BOOT_SECTOR*)backup->b_data; if (ntfs_boot_sector_is_valid(mp, bs2)) goto hotfix_primary_boot_sector; - err = buf_unmap(backup); + /* err = buf_unmap(backup); if (err) ntfs_error(mp, "Failed to unmap buffer of old " "backup boot sector (error " - "%d).", err); + "%d).", err);*/ err = EIO; - } + //} ntfs_error(mp, "Could not find a valid backup boot sector."); } else ntfs_error(mp, read_err_str, "backup", err); - buf_brelse(backup); + brelse(backup); /* We failed. Clean up and return. */ - if (bs1) { + /*if (bs1) { err2 = buf_unmap(primary); if (err2) ntfs_error(mp, "Failed to unmap buffer of primary " "boot sector (error %d).", err2); - } - buf_brelse(primary); + }*/ + brelse(primary); return err; hotfix_primary_boot_sector: ntfs_warning(mp, "Using backup boot sector."); @@ -368,31 +369,30 @@ ntfs_warning(mp, "Hot-fix: Recovering invalid primary boot " "sector from backup copy."); memcpy(bs1, bs2, blocksize); - err = buf_bwrite(primary); - if (err) - ntfs_error(mp, "Hot-fix: Device write error while " - "recovering primary boot sector " - "(error %d).", err); + bdwrite(primary); + //if (err) + // ntfs_error(mp, "Hot-fix: Device write error while " + // "recovering primary boot sector " + // "(error %d).", err); } else { if (bs1) { ntfs_warning(mp, "Hot-fix: Recovery of primary boot " "sector failed: Read-only mount."); - err = buf_unmap(primary); + /*err = buf_unmap(primary); if (err) ntfs_error(mp, "Failed to unmap buffer of " "primary boot sector (error " - "%d).", err); + "%d).", err);*/ } else ntfs_warning(mp, "Hot-fix: Recovery of primary boot " "sector failed as it could not be " "mapped."); - buf_brelse(primary); + brelse(primary); } *buf = backup; *bs = bs2; return 0; } -#endif /** * ntfs_boot_sector_parse - parse the boot sector and store the data in @vol @@ -407,7 +407,7 @@ * EINVAL - Boot sector is invalid. * ENOTSUP - Volume is not supported by this ntfs driver. */ -#if defined (UNUSED) + static errno_t ntfs_boot_sector_parse(ntfs_volume *vol, const NTFS_BOOT_SECTOR *b) { @@ -423,15 +423,13 @@ ntfs_debug("vol->sector_size = %u (0x%x)", vol->sector_size, vol->sector_size); ntfs_debug("vol->sector_size_shift = %u", vol->sector_size_shift); -#if defined (DIRTY_HACK) if (vol->sector_size < (u32)vfs_devblocksize(mp)) { ntfs_error(mp, "Sector size (%u) is smaller than the device " "block size (%d). This is not supported. " "Sorry.", vol->sector_size, - vfs_devblocksize(mp)); + (int)vfs_devblocksize(mp)); return ENOTSUP; } -#endif ntfs_debug("sectors_per_cluster = %u", b->bpb.sectors_per_cluster); sectors_per_cluster_shift = ffs(b->bpb.sectors_per_cluster) - 1; ntfs_debug("sectors_per_cluster_shift = %u", sectors_per_cluster_shift); @@ -589,7 +587,6 @@ ntfs_debug("Done."); return 0; } -#endif /** * ntfs_setup_allocators - initialize the cluster and mft allocators @@ -2097,7 +2094,7 @@ do { if (*kaddr) { ntfs_debug("hiberfil.sys is larger than 4kiB " - "(0x%llx), does not contain the " + "(0x%lx), does not contain the " "\"hibr\" magic, and does not have a " "zero header. Windows is hibernated " "on the volume. This is not the " @@ -4128,11 +4125,11 @@ * unloaded automatically while in use. If the mount fails, we must call * OSKextReleaseKextWithLoadTag() to allow the KEXT to be unloaded. */ -/* + static struct statfs *vfs_statfs(struct mount *mp) { return (&mp->mnt_stat); -}*/ +} static void vfs_setfsprivate(struct mount *mp, void *data) { @@ -4149,26 +4146,25 @@ return (mp->mnt_flag & MNT_UPDATE); } -static uint64_t vfs_devblocksize(struct mount *mp) -{ - return (mp->mnt_stat.f_bsize); -} + static int ntfs_mount(mount_t mp /*, vnode_t dev_vn, user_addr_t data, vfs_context_t context*/) { daddr_t nr_blocks = 0; - //struct statfs *sfs = vfs_statfs(mp); - //struct vnode *dev_vn = mp->mnt_vnodecovered; + struct statfs *sfs = vfs_statfs(mp); + struct vnode *dev_vn; ntfs_volume *vol; buf_t buf; - //kauth_cred_t cred; + struct ucred *cred = curthread->td_ucred; //dev_t dev; NTFS_BOOT_SECTOR *bs; errno_t err/*, err2*/; u32 blocksize = 0; //ntfs_mount_options_header opts_hdr; ntfs_mount_options_1_0 opts; + struct nameidata ndp; + char *from; ntfs_debug("Entering."); #if defined (DIRTY_HACK) @@ -4250,8 +4246,23 @@ * other way round. */ #endif + from = vfs_getopts(mp->mnt_optnew, "from", &err); + if (err) + return (err); if (vfs_isupdate(mp)) return ntfs_remount(mp, &opts); + NDINIT(&ndp, LOOKUP, FOLLOW | LOCKLEAF, UIO_SYSSPACE, from, curthread); + err = namei(&ndp); + if (err) + return (err); + NDFREE(&ndp, NDF_ONLY_PNBUF); + dev_vn = ndp.ni_vp; + + if (!vn_isdisk(dev_vn, &err)) { + vput(dev_vn); + return (err); + } + /* We know this is a real mount request thus @dev_vn is not NULL. */ //dev = vnode_specrdev(dev_vn); /* Let the VFS do advisory locking for us. */ @@ -4274,8 +4285,9 @@ * value to satisfy the ATTR_CMN_DEVID request in getattrlist() and * getvolattrlist() thus it must be the device. */ - //sfs->f_fsid.val[0] = (int32_t)dev; - //sfs->f_fsid.val[1] = (int32_t)vfs_typenum(mp); + sfs->f_fsid.val[0] = dev2udev(dev_vn->v_rdev); + sfs->f_fsid.val[1] = mp->mnt_vfc->vfc_typenum; + mp->mnt_maxsymlinklen = 0; /* * Allocate and initialize an ntfs volume and attach it to the vfs * mount. @@ -4360,7 +4372,7 @@ /* Get the size of the device in units of blocksize bytes. */ //err = VNOP_IOCTL(dev_vn, DKIOCGETBLOCKCOUNT, (caddr_t)&nr_blocks, 0, // context); - err = 1; + err = 0; if (err) { ntfs_error(mp, "Failed to determine the size of the device " "(DKIOCGETBLOCKCOUNT ioctl returned error " @@ -4404,7 +4416,6 @@ /* Read the boot sector and return the buffer containing it. */ buf = NULL; bs = NULL; - #if defined (DIRTY_HACK) err = ntfs_boot_sector_read(vol, cred, &buf, &bs); if (err) { ntfs_error(mp, "Not an NTFS volume."); @@ -4415,17 +4426,16 @@ * using it. */ err = ntfs_boot_sector_parse(vol, bs); - err2 = buf_unmap(buf); + /*err2 = buf_unmap(buf); if (err2) ntfs_error(mp, "Failed to unmap buffer of boot sector (error " - "%d).", err2); - buf_brelse(buf); + "%d).", err2);*/ + brelse(buf); if (err) { ntfs_error(mp, "%s NTFS file system.", err == ENOTSUP ? "Unsupported" : "Invalid"); goto err; } - #endif /* * If the boot sector indicates a sector size bigger than the current * device block size, switch the device block size to the sector size. @@ -4444,7 +4454,7 @@ if (vol->sector_size > blocksize) { ntfs_debug("Setting device block size to sector size."); //err = ntfs_blocksize_set(mp, dev_vn, vol->sector_size, context); - err = 1; + err = 0; if (err) { ntfs_error(mp, "Failed to set device block size to " "sector size (%u bytes) because " @@ -4559,6 +4569,7 @@ * it in the vfs mount structure. */ //ntfs_statfs(vol, sfs); + vfs_mountedfrom(mp, from); ntfs_debug("Done."); return 0; unload: @@ -4575,7 +4586,6 @@ */ ntfs_unmount(mp, MNT_FORCE/*, context*/); return err; - return 0; } /** @@ -5620,6 +5630,9 @@ //.vfs_setattr = ntfs_setattr, }; +VFS_SET(ntfs_vfsops, ntfs, 0); +MODULE_VERSION(ntfs, 1); + #if defined (DIRTY_HACK) static struct vnodeopv_desc *ntfs_vnodeopv_desc_list[1] = { &ntfs_vnodeopv_desc, From owner-svn-soc-all@FreeBSD.ORG Fri Jul 13 18:05:40 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id CC7C91065674 for ; Fri, 13 Jul 2012 18:05:39 +0000 (UTC) (envelope-from jhagewood@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Fri, 13 Jul 2012 18:05:39 +0000 Date: Fri, 13 Jul 2012 18:05:39 +0000 From: jhagewood@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120713180539.CC7C91065674@hub.freebsd.org> Cc: Subject: socsvn commit: r239349 - soc2012/jhagewood X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Jul 2012 18:05:40 -0000 Author: jhagewood Date: Fri Jul 13 18:05:39 2012 New Revision: 239349 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239349 Log: Deleted: soc2012/jhagewood/ From owner-svn-soc-all@FreeBSD.ORG Fri Jul 13 18:05:52 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id C66F61065670 for ; Fri, 13 Jul 2012 18:05:51 +0000 (UTC) (envelope-from jhagewood@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Fri, 13 Jul 2012 18:05:51 +0000 Date: Fri, 13 Jul 2012 18:05:51 +0000 From: jhagewood@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120713180551.C66F61065670@hub.freebsd.org> Cc: Subject: socsvn commit: r239350 - soc2012/jhagewood X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Jul 2012 18:05:53 -0000 Author: jhagewood Date: Fri Jul 13 18:05:51 2012 New Revision: 239350 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239350 Log: Added: soc2012/jhagewood/ From owner-svn-soc-all@FreeBSD.ORG Fri Jul 13 18:07:13 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 85998106566B for ; Fri, 13 Jul 2012 18:07:11 +0000 (UTC) (envelope-from jhagewood@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Fri, 13 Jul 2012 18:07:11 +0000 Date: Fri, 13 Jul 2012 18:07:11 +0000 From: jhagewood@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120713180711.85998106566B@hub.freebsd.org> Cc: Subject: socsvn commit: r239351 - in soc2012/jhagewood: . diff diff/diff diff/diff-orig diff/gabor_diff diff3 diff3/diff3 diff3/diff3-orig mdocml mdocml/mdocml-1.12.1 mdocml/mdocml-1.12.1-orig mdocml/ports-... X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Jul 2012 18:07:13 -0000 Author: jhagewood Date: Fri Jul 13 18:07:11 2012 New Revision: 239351 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239351 Log: Added: soc2012/jhagewood/Milestones soc2012/jhagewood/diff/ soc2012/jhagewood/diff/TODO soc2012/jhagewood/diff/diff/ soc2012/jhagewood/diff/diff-orig/ soc2012/jhagewood/diff/diff-orig/Makefile soc2012/jhagewood/diff/diff-orig/diff (contents, props changed) soc2012/jhagewood/diff/diff-orig/diff.1 soc2012/jhagewood/diff/diff-orig/diff.1.gz (contents, props changed) soc2012/jhagewood/diff/diff-orig/diff.c soc2012/jhagewood/diff/diff-orig/diff.h soc2012/jhagewood/diff/diff-orig/diffdir.c soc2012/jhagewood/diff/diff-orig/diffreg.c soc2012/jhagewood/diff/diff-orig/pathnames.h soc2012/jhagewood/diff/diff-test.sh soc2012/jhagewood/diff/diff/Makefile soc2012/jhagewood/diff/diff/diff (contents, props changed) soc2012/jhagewood/diff/diff/diff.1 soc2012/jhagewood/diff/diff/diff.1.gz (contents, props changed) soc2012/jhagewood/diff/diff/diff.c soc2012/jhagewood/diff/diff/diff.h soc2012/jhagewood/diff/diff/diffdir.c soc2012/jhagewood/diff/diff/diffreg.c soc2012/jhagewood/diff/diff/pathnames.h soc2012/jhagewood/diff/gabor_diff/ soc2012/jhagewood/diff/gabor_diff/Makefile soc2012/jhagewood/diff/gabor_diff/diff.1 soc2012/jhagewood/diff/gabor_diff/diff.c soc2012/jhagewood/diff/gabor_diff/diff.h soc2012/jhagewood/diff/gabor_diff/diffdir.c soc2012/jhagewood/diff/gabor_diff/diffreg.c soc2012/jhagewood/diff/gabor_diff/pathnames.h soc2012/jhagewood/diff/hagewood-diff.patch soc2012/jhagewood/diff/hagewood-fidd.patch soc2012/jhagewood/diff3/ soc2012/jhagewood/diff3/diff3/ soc2012/jhagewood/diff3/diff3-orig/ soc2012/jhagewood/diff3/diff3-orig/Makefile soc2012/jhagewood/diff3/diff3-orig/diff3.1 soc2012/jhagewood/diff3/diff3-orig/diff3.ksh soc2012/jhagewood/diff3/diff3-orig/diff3.sh soc2012/jhagewood/diff3/diff3-orig/diff3prog.c soc2012/jhagewood/diff3/diff3/Makefile soc2012/jhagewood/diff3/diff3/diff3.1 soc2012/jhagewood/diff3/diff3/diff3.ksh soc2012/jhagewood/diff3/diff3/diff3.sh soc2012/jhagewood/diff3/diff3/diff3prog.c soc2012/jhagewood/diff3/hagewood-diff3.patch soc2012/jhagewood/mdocml/ soc2012/jhagewood/mdocml/hagewood-mdocml-ns.patch soc2012/jhagewood/mdocml/hagewood-mdocml-ti.patch soc2012/jhagewood/mdocml/manpaths.txt soc2012/jhagewood/mdocml/mdocml-1.12.1/ soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/ soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/Makefile soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/TODO soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/apropos.1 soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/apropos.c soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/apropos_db.c soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/apropos_db.h soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/arch.c soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/arch.in soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/att.c soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/att.in soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/catman.8 soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/catman.c soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/cgi.c soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/chars.c soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/chars.in soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/compat_fgetln.c soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/compat_getsubopt.c soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/compat_strlcat.c soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/compat_strlcpy.c soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/config.h.post soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/config.h.pre soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/demandoc.1 soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/demandoc.c soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/eqn.7 soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/eqn.c soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/eqn_html.c soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/eqn_term.c soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/example.style.css soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/external.png (contents, props changed) soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/html.c soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/html.h soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/index.css soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/index.sgml soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/lib.c soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/lib.in soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/libman.h soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/libmandoc.h soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/libmdoc.h soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/libroff.h soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/main.c soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/main.h soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/man-cgi.css soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/man.7 soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/man.c soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/man.cgi.7 soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/man.h soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/man_hash.c soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/man_html.c soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/man_macro.c soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/man_term.c soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/man_validate.c soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/mandoc.1 soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/mandoc.3 soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/mandoc.c soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/mandoc.h soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/mandoc_char.7 soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/mandocdb.8 soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/mandocdb.c soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/mandocdb.h soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/manpath.c soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/manpath.h soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/mdoc.7 soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/mdoc.c soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/mdoc.h soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/mdoc_argv.c soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/mdoc_hash.c soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/mdoc_html.c soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/mdoc_macro.c soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/mdoc_man.c soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/mdoc_term.c soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/mdoc_validate.c soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/msec.c soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/msec.in soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/out.c soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/out.h soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/preconv.1 soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/preconv.c soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/predefs.in soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/read.c soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/roff.7 soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/roff.c soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/st.c soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/st.in soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/style.css soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/tbl.7 soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/tbl.c soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/tbl_data.c soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/tbl_html.c soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/tbl_layout.c soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/tbl_opts.c soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/tbl_term.c soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/term.c soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/term.h soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/term_ascii.c soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/term_ps.c soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/test-fgetln.c soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/test-getsubopt.c soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/test-mmap.c soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/test-strlcat.c soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/test-strlcpy.c soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/test-strptime.c soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/tree.c soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/vol.c soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/vol.in soc2012/jhagewood/mdocml/mdocml-1.12.1-orig/whatis.1 soc2012/jhagewood/mdocml/mdocml-1.12.1/Makefile soc2012/jhagewood/mdocml/mdocml-1.12.1/TODO soc2012/jhagewood/mdocml/mdocml-1.12.1/apropos.1 soc2012/jhagewood/mdocml/mdocml-1.12.1/apropos.c soc2012/jhagewood/mdocml/mdocml-1.12.1/apropos_db.c soc2012/jhagewood/mdocml/mdocml-1.12.1/apropos_db.h soc2012/jhagewood/mdocml/mdocml-1.12.1/arch.c soc2012/jhagewood/mdocml/mdocml-1.12.1/arch.in soc2012/jhagewood/mdocml/mdocml-1.12.1/att.c soc2012/jhagewood/mdocml/mdocml-1.12.1/att.in soc2012/jhagewood/mdocml/mdocml-1.12.1/catman.8 soc2012/jhagewood/mdocml/mdocml-1.12.1/catman.c soc2012/jhagewood/mdocml/mdocml-1.12.1/cgi.c soc2012/jhagewood/mdocml/mdocml-1.12.1/chars.c soc2012/jhagewood/mdocml/mdocml-1.12.1/chars.in soc2012/jhagewood/mdocml/mdocml-1.12.1/compat_fgetln.c soc2012/jhagewood/mdocml/mdocml-1.12.1/compat_getsubopt.c soc2012/jhagewood/mdocml/mdocml-1.12.1/compat_strlcat.c soc2012/jhagewood/mdocml/mdocml-1.12.1/compat_strlcpy.c soc2012/jhagewood/mdocml/mdocml-1.12.1/config.h.post soc2012/jhagewood/mdocml/mdocml-1.12.1/config.h.pre soc2012/jhagewood/mdocml/mdocml-1.12.1/demandoc.1 soc2012/jhagewood/mdocml/mdocml-1.12.1/demandoc.c soc2012/jhagewood/mdocml/mdocml-1.12.1/eqn.7 soc2012/jhagewood/mdocml/mdocml-1.12.1/eqn.c soc2012/jhagewood/mdocml/mdocml-1.12.1/eqn_html.c soc2012/jhagewood/mdocml/mdocml-1.12.1/eqn_term.c soc2012/jhagewood/mdocml/mdocml-1.12.1/example.style.css soc2012/jhagewood/mdocml/mdocml-1.12.1/external.png (contents, props changed) soc2012/jhagewood/mdocml/mdocml-1.12.1/html.c soc2012/jhagewood/mdocml/mdocml-1.12.1/html.h soc2012/jhagewood/mdocml/mdocml-1.12.1/index.css soc2012/jhagewood/mdocml/mdocml-1.12.1/index.sgml soc2012/jhagewood/mdocml/mdocml-1.12.1/lib.c soc2012/jhagewood/mdocml/mdocml-1.12.1/lib.in soc2012/jhagewood/mdocml/mdocml-1.12.1/libman.h soc2012/jhagewood/mdocml/mdocml-1.12.1/libmandoc.h soc2012/jhagewood/mdocml/mdocml-1.12.1/libmdoc.h soc2012/jhagewood/mdocml/mdocml-1.12.1/libroff.h soc2012/jhagewood/mdocml/mdocml-1.12.1/main.c soc2012/jhagewood/mdocml/mdocml-1.12.1/main.h soc2012/jhagewood/mdocml/mdocml-1.12.1/man-cgi.css soc2012/jhagewood/mdocml/mdocml-1.12.1/man.7 soc2012/jhagewood/mdocml/mdocml-1.12.1/man.c soc2012/jhagewood/mdocml/mdocml-1.12.1/man.cgi.7 soc2012/jhagewood/mdocml/mdocml-1.12.1/man.h soc2012/jhagewood/mdocml/mdocml-1.12.1/man.h.orig soc2012/jhagewood/mdocml/mdocml-1.12.1/man_hash.c soc2012/jhagewood/mdocml/mdocml-1.12.1/man_html.c soc2012/jhagewood/mdocml/mdocml-1.12.1/man_macro.c soc2012/jhagewood/mdocml/mdocml-1.12.1/man_term.c soc2012/jhagewood/mdocml/mdocml-1.12.1/man_term.c.orig soc2012/jhagewood/mdocml/mdocml-1.12.1/man_validate.c soc2012/jhagewood/mdocml/mdocml-1.12.1/mandoc.1 soc2012/jhagewood/mdocml/mdocml-1.12.1/mandoc.3 soc2012/jhagewood/mdocml/mdocml-1.12.1/mandoc.c soc2012/jhagewood/mdocml/mdocml-1.12.1/mandoc.h soc2012/jhagewood/mdocml/mdocml-1.12.1/mandoc_char.7 soc2012/jhagewood/mdocml/mdocml-1.12.1/mandocdb.8 soc2012/jhagewood/mdocml/mdocml-1.12.1/mandocdb.c soc2012/jhagewood/mdocml/mdocml-1.12.1/mandocdb.h soc2012/jhagewood/mdocml/mdocml-1.12.1/manpath.c soc2012/jhagewood/mdocml/mdocml-1.12.1/manpath.h soc2012/jhagewood/mdocml/mdocml-1.12.1/mdoc.7 soc2012/jhagewood/mdocml/mdocml-1.12.1/mdoc.c soc2012/jhagewood/mdocml/mdocml-1.12.1/mdoc.h soc2012/jhagewood/mdocml/mdocml-1.12.1/mdoc_argv.c soc2012/jhagewood/mdocml/mdocml-1.12.1/mdoc_hash.c soc2012/jhagewood/mdocml/mdocml-1.12.1/mdoc_html.c soc2012/jhagewood/mdocml/mdocml-1.12.1/mdoc_macro.c soc2012/jhagewood/mdocml/mdocml-1.12.1/mdoc_man.c soc2012/jhagewood/mdocml/mdocml-1.12.1/mdoc_term.c soc2012/jhagewood/mdocml/mdocml-1.12.1/mdoc_validate.c soc2012/jhagewood/mdocml/mdocml-1.12.1/msec.c soc2012/jhagewood/mdocml/mdocml-1.12.1/msec.in soc2012/jhagewood/mdocml/mdocml-1.12.1/out.c soc2012/jhagewood/mdocml/mdocml-1.12.1/out.h soc2012/jhagewood/mdocml/mdocml-1.12.1/preconv.1 soc2012/jhagewood/mdocml/mdocml-1.12.1/preconv.c soc2012/jhagewood/mdocml/mdocml-1.12.1/predefs.in soc2012/jhagewood/mdocml/mdocml-1.12.1/read.c soc2012/jhagewood/mdocml/mdocml-1.12.1/roff.7 soc2012/jhagewood/mdocml/mdocml-1.12.1/roff.c soc2012/jhagewood/mdocml/mdocml-1.12.1/st.c soc2012/jhagewood/mdocml/mdocml-1.12.1/st.in soc2012/jhagewood/mdocml/mdocml-1.12.1/style.css soc2012/jhagewood/mdocml/mdocml-1.12.1/tbl.7 soc2012/jhagewood/mdocml/mdocml-1.12.1/tbl.c soc2012/jhagewood/mdocml/mdocml-1.12.1/tbl_data.c soc2012/jhagewood/mdocml/mdocml-1.12.1/tbl_html.c soc2012/jhagewood/mdocml/mdocml-1.12.1/tbl_layout.c soc2012/jhagewood/mdocml/mdocml-1.12.1/tbl_opts.c soc2012/jhagewood/mdocml/mdocml-1.12.1/tbl_term.c soc2012/jhagewood/mdocml/mdocml-1.12.1/term.c soc2012/jhagewood/mdocml/mdocml-1.12.1/term.h soc2012/jhagewood/mdocml/mdocml-1.12.1/term_ascii.c soc2012/jhagewood/mdocml/mdocml-1.12.1/term_ps.c soc2012/jhagewood/mdocml/mdocml-1.12.1/test-fgetln.c soc2012/jhagewood/mdocml/mdocml-1.12.1/test-getsubopt.c soc2012/jhagewood/mdocml/mdocml-1.12.1/test-mmap.c soc2012/jhagewood/mdocml/mdocml-1.12.1/test-strlcat.c soc2012/jhagewood/mdocml/mdocml-1.12.1/test-strlcpy.c soc2012/jhagewood/mdocml/mdocml-1.12.1/test-strptime.c soc2012/jhagewood/mdocml/mdocml-1.12.1/tree.c soc2012/jhagewood/mdocml/mdocml-1.12.1/vol.c soc2012/jhagewood/mdocml/mdocml-1.12.1/vol.in soc2012/jhagewood/mdocml/mdocml-1.12.1/whatis.1 soc2012/jhagewood/mdocml/mdocml-manpage-errors.txt soc2012/jhagewood/mdocml/ports-textproc-patches/ soc2012/jhagewood/mdocml/ports-textproc-patches/patch-config.txt soc2012/jhagewood/mdocml/ports-textproc-patches/patch-lib.in.txt soc2012/jhagewood/mdocml/ports-textproc-patches/patch-mdoc_validate.c soc2012/jhagewood/mdocml/ports-textproc-patches/patch-msec.in.txt soc2012/jhagewood/mdocml/tests/ soc2012/jhagewood/mdocml/tests/compile-man-pages.sh (contents, props changed) soc2012/jhagewood/mdocml/tests/mdocml-test.sh (contents, props changed) soc2012/jhagewood/sdiff/ soc2012/jhagewood/sdiff/TODO soc2012/jhagewood/sdiff/hagewood-sdiff.patch soc2012/jhagewood/sdiff/sdiff/ soc2012/jhagewood/sdiff/sdiff-orig/ soc2012/jhagewood/sdiff/sdiff-orig/Makefile soc2012/jhagewood/sdiff/sdiff-orig/common.c soc2012/jhagewood/sdiff/sdiff-orig/common.h soc2012/jhagewood/sdiff/sdiff-orig/edit.c soc2012/jhagewood/sdiff/sdiff-orig/extern.h soc2012/jhagewood/sdiff/sdiff-orig/sdiff.1 soc2012/jhagewood/sdiff/sdiff-orig/sdiff.c soc2012/jhagewood/sdiff/sdiff-test.sh soc2012/jhagewood/sdiff/sdiff/Makefile soc2012/jhagewood/sdiff/sdiff/common.c soc2012/jhagewood/sdiff/sdiff/common.h soc2012/jhagewood/sdiff/sdiff/edit.c soc2012/jhagewood/sdiff/sdiff/extern.h soc2012/jhagewood/sdiff/sdiff/sdiff.1 soc2012/jhagewood/sdiff/sdiff/sdiff.c Added: soc2012/jhagewood/Milestones ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/jhagewood/Milestones Fri Jul 13 18:07:11 2012 (r239351) @@ -0,0 +1,30 @@ +May 21 - June 17 + + Implement missing features of mdocml, including legacy features. + Testing of mdocml. + +June 18 - July 1 + + Complete diff + Debugging and testing of diff + +July 2 - July 18 + + Mid-term evaluations. + Complete sdiff + Debugging and testing of sdiff + +July 19 - August 5 + + Complete diff3 + Debugging and testing of diff3 + +August 6 – August 12 + + Thouroughly test and benchmark all utilities. + +August 13 - August 20 + + "Pencils down" period. + Finish cleaning up code and do any testing that might be left. + Write documentation. Added: soc2012/jhagewood/diff/TODO ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/jhagewood/diff/TODO Fri Jul 13 18:07:11 2012 (r239351) @@ -0,0 +1,75 @@ +TASK STATUS NOTE + +--unified GNU compatibility COMPLETE Fixed timestamp. +--context GNU compatibility COMPLETE Fixed timestamp, will test more. +--ignore-blank-lines IN PROGRESS Was already implemented in check(), but has weird outputs. +--left-column COMPLETE Because side-by-side mode is executed by sdiff, option is simply passed to sdiff. +--show-function-line INCOMPLETE +--unidirectional-new-file INCOMPLETE +--normal COMPLETE Sets format to D_NORMAL in getopt_long(). +--suppress-common-lines COMPLETE Because side-by-side mode is executed by sdiff, option is simply passed to sdiff. +--GTYPE-group-format IN PROGRESS Added options for various GTYPEs. +--line-format IN PROGRESS Added new-line-format, old-line-format, and unchanged-line-format for compatibility +--LTYPE-line-format INCOMPLETE +--from-file COMPLETE Checks for flag then calls diffreg() with input files diff'd against optarg. +--to-file COMPLETE Checks for flag then calls diffreg() with optarg diff'd against input files. +--horizon-lines INCOMPLETE +--speed-large-file INCOMPLETE +--ignore-tab-expansion IN PROGRESS Functionality implemented in check(), needs debugging. (Same problem as --ignore-blank-lines?) +--width INCOMPLETE +--help COMPLETE +Fix non-ascii character diffs COMPLETE Changed name of asciifile() to istextfile() and detects if file is binary. +Test script COMPLETE + +Notes: + +- When using text files with non-ascii characters, diff will interpret them as binary files and output "Files [file1] and [file2] differ." + Very important compatibility problem with GNU diff, which will diff files that aren't strictly ascii. + - Error is associated with asciifile() in diffreg.c + - FIX: Changed name of asciifile() to istextfile() (more appropriate), and instead of checking if every character is ASCII, it checks the first 32kb of data in the file for a null character. If a null character is found, diff assumes that the file is a text file. +- With some files, modification times displayed in the timestamp for file1 are different than the time outputted by GNU diff. +- The -ignore-*-* options need some work. +- BUG: BSD diff seg faults when another longopt is used with '--side-by-side'. FIX: When passing args to sdiff for side-by-side mode, only the + short option '-y' was excluded. Added '--side-by-side' as an exception also. +- --ignore-*-* options + -WORKING + --ignore-all-space + --ignore-case + --ignore-file-name-case + --ignore-matching-lines + --ignore-space-change + -NOT WORKING + --ignore-blank-lines + --ignore-tab-expansion + +- line formats: + + %l Only includes contents of a line, excluding trailing new line. + %L Only includes contents of a line, including trailing new line. + %% Stand for '%' + %c'C' Where C is a character. + %c'\O' where O is a string of 1, 2, or 3 octal digits, stands for the character with octal code O. + Fn Where n is: + -'e' + -'f' + -'l' + -'m' + -'n' + -'E, F, L, M, N' + +- group formats: + + %< Stands for the lines from the first file, including trailing new lines. + %> Stands for the lines from the second file, including trailing new lines. + %= Stands for lines common to both files, including trailing new lines. + %% Stands for '%' + %c'C' Where C is a character. + %c'\O' where O is a string of 1, 2, or 3 octal digits, stands for the character with octal code O. + Fn Where n is: + -'e' + -'f' + -'l' + -'m' + -'n' + -'E, F, L, M, N' + Added: soc2012/jhagewood/diff/diff-orig/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/jhagewood/diff/diff-orig/Makefile Fri Jul 13 18:07:11 2012 (r239351) @@ -0,0 +1,10 @@ +# $FreeBSD$ +# $OpenBSD: Makefile,v 1.2 2003/06/25 02:42:50 deraadt Exp $ + +DEBUG_FLAGS+= -g + +PROG= diff +SRCS= diff.c diffdir.c diffreg.c +CFLAGS+= -std=c99 -Wall -pedantic + +.include Added: soc2012/jhagewood/diff/diff-orig/diff ============================================================================== Binary file. No diff available. Added: soc2012/jhagewood/diff/diff-orig/diff.1 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/jhagewood/diff/diff-orig/diff.1 Fri Jul 13 18:07:11 2012 (r239351) @@ -0,0 +1,511 @@ +.\" $FreeBSD$ +.\" $OpenBSD: diff.1,v 1.33 2007/05/31 19:20:09 jmc Exp $ +.\" +.\" Copyright (c) 1980, 1990, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" @(#)diff.1 8.1 (Berkeley) 6/30/93 +.\" +.Dd Apr 7, 2008 +.Dt DIFF 1 +.Os +.Sh NAME +.Nm diff +.Nd differential file and directory comparator +.Sh SYNOPSIS +.Nm diff +.Op Fl abdilpqTtw +.Op Fl I Ar pattern +.Oo +.Fl c | e | f | +.Fl n | u +.Oc +.Op Fl L Ar label +.Ar file1 file2 +.Nm diff +.Op Fl abdilpqTtw +.Op Fl I Ar pattern +.Op Fl L Ar label +.Fl C Op Ar number +.Ar file1 file2 +.Nm diff +.Op Fl abdilqtw +.Op Fl I Ar pattern +.Fl D Ar string +.Ar file1 file2 +.Nm diff +.Op Fl abdilpqTtw +.Op Fl I Ar pattern +.Op Fl L Ar label +.Fl U Ar number +.Ar file1 file2 +.Nm diff +.Op Fl abdilNPpqrsTtw +.Op Fl I Ar pattern +.Oo +.Fl c | e | f | +.Fl n | u +.Oc +.Bk -words +.Op Fl L Ar label +.Op Fl S Ar name +.Op Fl X Ar file +.Op Fl x Ar pattern +.Ek +.Ar dir1 dir2 +.Nm diff +.Op Fl v +.Sh DESCRIPTION +The +.Nm +utility compares the contents of +.Ar file1 +and +.Ar file2 +and writes to the standard output the list of changes necessary to +convert one file into the other. +No output is produced if the files are identical. +.Pp +Output options (mutually exclusive): +.Bl -tag -width Ds +.It Fl C Op Ar number , Fl Fl context Ns = Ns Op Ar number +Like +.Fl c +but produces a diff with +.Ar number +lines of context. +.It Fl c +Produces a diff with 3 lines of context. +With +.Fl c +the output format is modified slightly: +the output begins with identification of the files involved and +their creation dates and then each change is separated +by a line with fifteen +.Li * Ns 's . +The lines removed from +.Ar file1 +are marked with +.Sq \&-\ \& ; +those added to +.Ar file2 +are marked +.Sq \+\ \& . +Lines which are changed from one file to the other are marked in +both files with +.Sq !\ \& . +Changes which lie within 3 lines of each other are grouped together on +output. +.It Fl D Ar string , Fl Fl ifdef Ns = Ns Ar string +Creates a merged version of +.Ar file1 +and +.Ar file2 +on the standard output, with C preprocessor controls included so that +a compilation of the result without defining +.Ar string +is equivalent to compiling +.Ar file1 , +while defining +.Ar string +will yield +.Ar file2 . +.It Fl e , Fl Fl ed +Produces output in a form suitable as input for the editor utility, +.Xr ed 1 , +which can then be used to convert file1 into file2. +.Pp +Extra commands are added to the output when comparing directories with +.Fl e , +so that the result is a +.Xr sh 1 +script for converting text files which are common to the two directories +from their state in +.Ar dir1 +to their state in +.Ar dir2 . +.It Fl f +Identical output to that of the +.Fl e +flag, but in reverse order. +It cannot be digested by +.Xr ed 1 . +.It Fl n , Fl Fl rcs +Produces a script similar to that of +.Fl e , +but in the opposite order and with a count of changed lines on each +insert or delete command. +This is the form used by +.Xr rcsdiff 1 . +.It Fl q , Fl Fl brief +Just print a line when the files differ. +Does not output a list of changes. +.It Fl U Op Ar number , Fl Fl unified Ns = Ns Op Ar number +Like +.Fl u +but produces a diff with +.Ar number +lines of context. +.It Fl u +Produces a +.Em unified +diff with 3 lines of context. +A unified diff is similar to the context diff produced by the +.Fl c +option. +However, unlike with +.Fl c , +all lines to be changed (added and/or removed) are present in +a single section. +.El +.Pp +Comparison options: +.Bl -tag -width Ds +.It Fl a , Fl Fl text +Treat all files as +.Tn ASCII +text. +Normally +.Nm +will simply print +.Dq Binary files ... differ +if files contain binary characters. +Use of this option forces +.Nm +to produce a diff. +.It Fl b , Fl Fl ignore-space-change +Causes trailing blanks (spaces and tabs) to be ignored, and other +strings of blanks to compare equal. +.It Fl d , Fl Fl minimal +Try very hard to produce a diff as small as possible. +This may consume a lot of processing power and memory when processing +large files with many changes. +.It Fl I Ar pattern , Fl Fl ignore-matching-lines Ns = Ns Ar pattern +Ignores changes, insertions, and deletions whose lines match the +extended regular expression +.Ar pattern . +Multiple +.Fl I +patterns may be specified. +All lines in the change must match some pattern for the change to be +ignored. +See +.Xr re_format 7 +for more information on regular expression patterns. +.It Fl i , Fl Fl ignore-case +Ignores the case of letters. +E.g., +.Dq A +will compare equal to +.Dq a . +.It Fl L Ar label +Print +.Ar label +instead of the first (and second, if this option is specified twice) +file name and time in the context or unified diff header. +.It Fl l , Fl Fl paginate +Long output format; each text file +.Nm diff Ns \'d +is piped through +.Xr pr 1 +to paginate it; +other differences are remembered and summarized +after all text file differences are reported. +.It Fl p , Fl Fl show-c-function +With unified and context diffs, show with each change +the first 40 characters of the last line before the context beginning +with a letter, an underscore or a dollar sign. +For C source code following standard layout conventions, this will +show the prototype of the function the change applies to. +.It Fl T , Fl Fl initial-tab +Print a tab rather than a space before the rest of the line for the +normal, context or unified output formats. +This makes the alignment of tabs in the line consistent. +.It Fl t , Fl Fl expand-tabs +Will expand tabs in output lines. +Normal or +.Fl c +output adds character(s) to the front of each line which may screw up +the indentation of the original source lines and make the output listing +difficult to interpret. +This option will preserve the original source's indentation. +.It Fl w , Fl Fl ignore-all-space +Is similar to +.Fl b +but causes whitespace (blanks and tabs) to be totally ignored. +E.g., +.Dq if (\ \&a == b \&) +will compare equal to +.Dq if(a==b) . +.El +.Pp +Directory comparison options: +.Bl -tag -width Ds +.It Fl N , Fl Fl new-file +If a file is found in only one directory, act as if it was found in the +other directory too but was of zero size. +.It Fl P +If a file is found only in +.Ar dir2 , +act as if it was found in +.Ar dir1 +too but was of zero size. +.It Fl r , Fl Fl recursive +Causes application of +.Nm +recursively to common sub7 directories encountered. +.It Fl S Ar name , Fl starting-file Ns = Ns Ar name +Re-starts a directory +.Nm +in the middle, beginning with file +.Ar name . +.It Fl s , Fl Fl report-identical-files +Causes +.Nm +to report files which are the same, which are otherwise not mentioned. +.It Fl X Ar file , Fl Fl exclude-from Ns = Ns Ar file +Exclude files and subdirectories from comparison whose basenames match +lines in +.Ar file . +Multiple +.Fl X +options may be specified. +.It Fl x Ar pattern , Fl Fl exclude Ns = Ns Ar pattern +Exclude files and subdirectories from comparison whose basenames match +.Ar pattern . +Patterns are matched using shell-style globbing via +.Xr fnmatch 3 . +Multiple +.Fl x +options may be specified. +.It Fl v , Fl Fl version +Print version ino. +.El +.Pp +If both arguments are directories, +.Nm +sorts the contents of the directories by name, and then runs the +regular file +.Nm +algorithm, producing a change list, +on text files which are different. +Binary files which differ, +common subdirectories, and files which appear in only one directory +are described as such. +In directory mode only regular files and directories are compared. +If a non-regular file such as a device special file or +.Tn FIFO +is encountered, a diagnostic message is printed. +.Pp +If only one of +.Ar file1 +and +.Ar file2 +is a directory, +.Nm +is applied to the non-directory file and the file contained in +the directory file with a filename that is the same as the +last component of the non-directory file. +.Pp +If either +.Ar file1 +or +.Ar file2 +is +.Sq Fl , +the standard input is +used in its place. +.Ss Output Style +The default (without +.Fl e , +.Fl c , +or +.Fl n +.\" -C +options) +output contains lines of these forms, where +.Va XX , YY , ZZ , QQ +are line numbers respective of file order. +.Pp +.Bl -tag -width "XX,YYcZZ,QQ" -compact +.It Li XX Ns Ic a Ns Li YY +At (the end of) line +.Va XX +of +.Ar file1 , +append the contents +of line +.Va YY +of +.Ar file2 +to make them equal. +.It Li XX Ns Ic a Ns Li YY,ZZ +Same as above, but append the range of lines, +.Va YY +through +.Va ZZ +of +.Ar file2 +to line +.Va XX +of file1. +.It Li XX Ns Ic d Ns Li YY +At line +.Va XX +delete +the line. +The value +.Va YY +tells to which line the change would bring +.Ar file1 +in line with +.Ar file1 . +.It Li XX,YY Ns Ic d Ns Li ZZ +Delete the range of lines +.Va XX +through +.Va YY +in +.Ar file1 . +.It Li XX Ns Ic c Ns Li YY +Change the line +.Va XX +in +.Ar file1 +to the line +.Va YY +in +.Ar file2 . +.It Li XX,YY Ns Ic c Ns Li ZZ +Replace the range of specified lines with the line +.Va ZZ . +.It Li XX,YY Ns Ic c Ns Li ZZ,QQ +Replace the range +.Va XX , Ns Va YY +from +.Ar file1 +with the range +.Va ZZ , Ns Va QQ +from +.Ar file2 . +.El +.Pp +These lines resemble +.Xr ed 1 +subcommands to convert +.Ar file1 +into +.Ar file2 . +The line numbers before the action letters pertain to +.Ar file1 ; +those after pertain to +.Ar file2 . +Thus, by exchanging +.Ic a +for +.Ic d +and reading the line in reverse order, one can also +determine how to convert +.Ar file2 +into +.Ar file1 . +As in +.Xr ed 1 , +identical +pairs (where num1 = num2) are abbreviated as a single +number. +.Sh ENVIRONMENT +.Bl -tag -width TMPDIR +.It Ev TMPDIR +If the environment variable +.Ev TMPDIR +exists, +.Nm +will use the directory specified by +.Ev TMPDIR +as the temporary directory. +.El +.Sh FILES +.Bl -tag -width /tmp/diff.XXXXXXXX -compact +.It Pa /tmp/diff. Ns Ar XXXXXXXX +Temporary file used when comparing a device or the standard input. +Note that the temporary file is unlinked as soon as it is created +so it will not show up in a directory listing. +.El +.Sh DIAGNOSTICS +The +.Nm +utility exits with one of the following values: +.Pp +.Bl -tag -width Ds -compact -offset indent +.It 0 +No differences were found. +.It 1 +Differences were found. +.It \*(Gt1 +An error occurred. +.El +.Sh SEE ALSO +.Xr cmp 1 , +.Xr comm 1 , +.Xr diff3 1 , +.Xr ed 1 , +.Xr pr 1 , +.Xr sdiff 1 , +.Xr fnmatch 3 , +.Xr re_format 7 +.Sh STANDARDS +The +.Nm +utility is compliant with the +St -p1003.1-2004 +specification. +.Pp +The flags +.Op Fl aDdIiLlNnPpqSsTtUuwXx +are extensions to that specification. +.Sh HISTORY +A +.Nm +command appeared in +.At v6 . +.Sh BUGS +When comparing directories with the +.Fl b , +.Fl w +or +.Fl i +options specified, +.Nm +first compares the files ala +.Xr cmp 1 , +and then decides to run the +.Nm +algorithm if they are not equal. +This may cause a small amount of spurious output if the files +then turn out to be identical because the only differences are +insignificant whitespace or case differences. Added: soc2012/jhagewood/diff/diff-orig/diff.1.gz ============================================================================== Binary file. No diff available. Added: soc2012/jhagewood/diff/diff-orig/diff.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/jhagewood/diff/diff-orig/diff.c Fri Jul 13 18:07:11 2012 (r239351) @@ -0,0 +1,599 @@ +/*- + * Copyright (c) 2003 Todd C. Miller + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Sponsored in part by the Defense Advanced Research Projects + * Agency (DARPA) and Air Force Research Laboratory, Air Force + * Materiel Command, USAF, under agreement number F39502-99-1-0512. + */ + +#include + +#ifndef lint +#if 0 +__RCSID("$OpenBSD: diff.c,v 1.50 2007/05/29 18:24:56 ray Exp $"); +#else +__FBSDID("$FreeBSD$"); +#endif +#endif /* not lint */ + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "diff.h" +#include "pathnames.h" + +int aflag, bflag, dflag, iflag, lflag, Nflag, Pflag, pflag, rflag; +int sflag, tflag, Tflag, wflag; +int Bflag, yflag; +int strip_cr, tabsize=8; +char ignore_file_case = 0; +int format, context, status; +char *start, *ifdefname, *diffargs, *label[2], *ignore_pats; +struct stat stb1, stb2; +struct excludes *excludes_list; +regex_t ignore_re; + +int flag_opts = 0; + +#define OPTIONS "0123456789aBbC:cdD:efhI:iL:lnNPpqrS:sTtU:uvwXy:x" + + +/* Options which exceed manageable alphanumeric assignments */ +enum +{ + OPT_IGN_FN_CASE = CHAR_MAX + 1, + OPT_NIGN_FN_CASE, + OPT_STRIPCR, + OPT_NORMAL, + OPT_LEFTC, + OT_SUPCL, + OPT_GTYPE, + OPT_LF, + OPT_LLF, + OPT_TSIZE, + OPT_UNINF, + OPT_FFILE, + OPT_TOFILE, + OPT_HLINES, + OPT_LFILES, + OPT_HELP, +}; + + +static struct option longopts[] = { +/* XXX: UNIMPLEMENTED + { "normal", no_argument, NULL, OPT_NORMAL }, + { "left-column", no_argument, NULL, OPT_LEFTC }, + { "suppress-common-lines", no_argument, NULL, OT_SUPCL }, + { "GTYPE-group-format", required_argument, NULL, OPT_GTYPE }, + { "line-format", required_argument, NULL, OPT_LF }, + { "LTYPE-line-format", required_argument, NULL, OPT_LLF }, + { "unidirectional-new-file", no_argument, NULL, OPT_UNINF }, + { "from-file", required_argument, NULL, OPT_FFILE }, + { "to-file", required_argument, NULL, OPT_TOFILE }, + { "horizon-lines", required_argument, NULL, OPT_HLINES }, + { "speed-large-files", no_argument, NULL, OPT_LFILES }, */ + { "tabsize", optional_argument, NULL, OPT_TSIZE }, + { "strip-trailing-cr", no_argument, NULL, OPT_STRIPCR }, + { "help", no_argument, NULL, OPT_HELP }, + { "ignore-file-name-case", no_argument, NULL, OPT_IGN_FN_CASE }, + { "no-ignore-file-name-case", no_argument, NULL, OPT_NIGN_FN_CASE }, + { "text", no_argument, NULL, 'a' }, +/* XXX: UNIMPLEMENTED */ + { "ignore-blank-lines", no_argument, NULL, 'B' }, + { "ignore-space-change", no_argument, NULL, 'b' }, +/* XXX: -c is incompatible with GNU version */ + { "context", optional_argument, NULL, 'C' }, + { "ifdef", required_argument, NULL, 'D' }, + { "minimal", no_argument, NULL, 'd' }, +/* XXX: UNIMPLEMENTED + { "ignore-tab-expansion", no_argument, NULL, 'E' }, */ + { "ed", no_argument, NULL, 'e' }, +/* XXX: UNIMPLEMENTED + { "show-function-line", required_argument, NULL, 'F' }, */ + { "forward-ed", no_argument, NULL, 'f' }, + { "ignore-matching-lines", required_argument, NULL, 'I' }, + { "ignore-case", no_argument, NULL, 'i' }, + { "label", required_argument, NULL, 'L' }, + { "paginate", no_argument, NULL, 'l' }, + { "new-file", no_argument, NULL, 'N' }, + { "rcs", no_argument, NULL, 'n' }, + { "unidirectional-new-file", no_argument, NULL, 'P' }, + { "show-c-function", no_argument, NULL, 'p' }, + { "brief", no_argument, NULL, 'q' }, + { "recursive", no_argument, NULL, 'r' }, + { "starting-file", required_argument, NULL, 'S' }, + { "report-identical-files", no_argument, NULL, 's' }, + { "initial-tab", no_argument, NULL, 'T' }, + { "expand-tabs", no_argument, NULL, 't' }, +/* XXX: -u is incompatible with GNU version */ + { "unified", optional_argument, NULL, 'U' }, + { "version", no_argument, NULL, 'v' }, +/* XXX: UNIMPLEMENTED + { "width", optional_argument, NULL, 'W' }, */ + { "ignore-all-space", no_argument, NULL, 'w' }, + { "exclude-from", required_argument, NULL, 'X' }, + { "exclude", required_argument, NULL, 'x' }, + { "side-by-side", no_argument, NULL, 'y' }, + { NULL, 0, NULL, '\0'} +}; + +static const char *help_msg[] = { +"-a --text treat files as ASCII text", +"-B --ignore-blank-lines Ignore blank newlines in the comparison", +"-b --ignore-space-change Ignore all changes due to whitespace", +"-C NUM --context=[NUM] Show NUM lines before and after change (default 3)", +"-D --ifdef=NAME", +NULL, +}; +char **help_strs = (char **)help_msg; + +void set_argstr(char **, char **); + + +void usage(void); +void push_excludes(char *); +void push_ignore_pats(char *); +void read_excludes_file(char *); + +int +main(int argc, char **argv) +{ + char *ep, **oargv; + long l; + int ch, lastch, gotstdin, prevoptind, newarg; + int oargc; + + oargv = argv; + oargc = argc; + gotstdin = 0; + + lastch = '\0'; + prevoptind = 1; + newarg = 1; + while ((ch = getopt_long(argc, argv, OPTIONS, longopts, NULL)) != -1) { + switch (ch) { + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + if (newarg) + usage(); /* disallow -[0-9]+ */ + else if (lastch == 'c' || lastch == 'u') + context = 0; + else if (!isdigit(lastch) || context > INT_MAX / 10) + usage(); + context = (context * 10) + (ch - '0'); + break; + case 'a': + aflag = 1; + break; + case 'b': + bflag = 1; + break; + case 'B': + Bflag = 1; + break; + case 'C': + case 'c': + format = D_CONTEXT; + if (optarg != NULL) { + l = strtol(optarg, &ep, 10); + if (*ep != '\0' || l < 0 || l >= INT_MAX) + usage(); + context = (int)l; + } else + context = 3; + break; + case 'D': + format = D_IFDEF; + ifdefname = optarg; + break; + case 'd': + dflag = 1; + break; + case 'e': + format = D_EDIT; + break; + case 'f': + format = D_REVERSE; + break; + case 'h': + /* silently ignore for backwards compatibility */ + break; + case 'I': + push_ignore_pats(optarg); + break; + case 'i': + iflag = 1; + break; + case 'L': + if (label[0] == NULL) + label[0] = optarg; + else if (label[1] == NULL) + label[1] = optarg; + else + usage(); + break; + case 'l': + lflag = 1; + signal(SIGPIPE, SIG_IGN); + break; + case 'N': + Nflag = 1; + break; + case 'n': + format = D_NREVERSE; + break; + case 'P': + Pflag = 1; + break; + case 'p': + pflag = 1; + break; + case 'r': + rflag = 1; + break; + case 'q': + format = D_BRIEF; + break; + case 'S': + start = optarg; + break; + case 's': + sflag = 1; + break; + case 'T': + Tflag = 1; + break; + case 't': + tflag = 1; + break; + case 'U': + case 'u': + format = D_UNIFIED; + if (optarg != NULL) { + l = strtol(optarg, &ep, 10); + if (*ep != '\0' || l < 0 || l >= INT_MAX) + usage(); + context = (int)l; + } else + context = 3; + break; + case 'v': + printf("FreeBSD diff 2.8.7\n"); + exit(0); + case 'w': + wflag = 1; + break; + case 'X': + read_excludes_file(optarg); + break; + case 'x': + push_excludes(optarg); + break; + case 'y': + yflag = 1; + break; + case OPT_TSIZE: + if (optarg != NULL) { + l = strtol(optarg, &ep, 10); + if (*ep != '\0' || l < 1 || l >= INT_MAX) + usage(); + tabsize = (int)l; + } else + tabsize = 8; + break; + case OPT_STRIPCR: + strip_cr=1; + break; + case OPT_IGN_FN_CASE: + ignore_file_case = 1; + break; + case OPT_NIGN_FN_CASE: + ignore_file_case = 0; + break; + case OPT_HELP: + for(;*help_strs;help_strs++) + { + printf("%s\n", *help_strs); + } + exit(2); + break; + default: + usage(); + break; + } + lastch = ch; + newarg = optind != prevoptind; + prevoptind = optind; + } + argc -= optind; + argv += optind; + + if(yflag) { + /* remove y flag from args and call sdiff */ + for(argv=oargv; argv && strcmp(*argv, "-y") != 0; argv++); + while(argv != &oargv[oargc]){ + *argv=*(argv+1); + argv++; + } + oargv[0] = _PATH_SDIFF; + *argv= "\0"; + + execv(_PATH_SDIFF, oargv); + _exit(127); + } + + /* + * Do sanity checks, fill in stb1 and stb2 and call the appropriate + * driver routine. Both drivers use the contents of stb1 and stb2. + */ + if (argc != 2) + usage(); + if (ignore_pats != NULL) { + char buf[BUFSIZ]; + int error; + + if ((error = regcomp(&ignore_re, ignore_pats, *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-soc-all@FreeBSD.ORG Fri Jul 13 19:29:28 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id DF05A106566B for ; Fri, 13 Jul 2012 19:29:25 +0000 (UTC) (envelope-from gmiller@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Fri, 13 Jul 2012 19:29:25 +0000 Date: Fri, 13 Jul 2012 19:29:25 +0000 From: gmiller@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120713192925.DF05A106566B@hub.freebsd.org> Cc: Subject: socsvn commit: r239352 - in soc2012/gmiller/locking-head: . lib/libthr/thread X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Jul 2012 19:29:28 -0000 Author: gmiller Date: Fri Jul 13 19:29:25 2012 New Revision: 239352 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239352 Log: r239325@FreeBSD-dev: root | 2012-07-13 13:47:28 -0500 Correct the logic for detecting the last unlock call for a recursive mutex. Modified: soc2012/gmiller/locking-head/ (props changed) soc2012/gmiller/locking-head/lib/libthr/thread/thr_mutex.c Modified: soc2012/gmiller/locking-head/lib/libthr/thread/thr_mutex.c ============================================================================== --- soc2012/gmiller/locking-head/lib/libthr/thread/thr_mutex.c Fri Jul 13 18:07:11 2012 (r239351) +++ soc2012/gmiller/locking-head/lib/libthr/thread/thr_mutex.c Fri Jul 13 19:29:25 2012 (r239352) @@ -769,10 +769,6 @@ PMUTEX_TYPE(m->m_flags) == PTHREAD_MUTEX_RECURSIVE && m->m_count > 0)) { m->m_count--; - - if (m->m_count == 0) { - LOCK_PROFILE_RELEASE(m); - } } else { LOCK_PROFILE_RELEASE(m); From owner-svn-soc-all@FreeBSD.ORG Sat Jul 14 03:49:03 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id B1F15106564A for ; Sat, 14 Jul 2012 03:49:01 +0000 (UTC) (envelope-from jhagewood@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Sat, 14 Jul 2012 03:49:01 +0000 Date: Sat, 14 Jul 2012 03:49:01 +0000 From: jhagewood@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120714034901.B1F15106564A@hub.freebsd.org> Cc: Subject: socsvn commit: r239364 - soc2012/jhagewood/sdiff X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Jul 2012 03:49:03 -0000 Author: jhagewood Date: Sat Jul 14 03:49:00 2012 New Revision: 239364 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239364 Log: replaced gotos in sdiff Modified: soc2012/jhagewood/sdiff/hagewood-sdiff.patch Modified: soc2012/jhagewood/sdiff/hagewood-sdiff.patch ============================================================================== --- soc2012/jhagewood/sdiff/hagewood-sdiff.patch Sat Jul 14 02:59:11 2012 (r239363) +++ soc2012/jhagewood/sdiff/hagewood-sdiff.patch Sat Jul 14 03:49:00 2012 (r239364) @@ -1,6 +1,6 @@ diff -rupN jhagewood/sdiff/sdiff-orig/sdiff.1 jhagewood/sdiff/sdiff/sdiff.1 ---- jhagewood/sdiff/sdiff-orig/sdiff.1 2012-07-07 19:37:22.000000000 -0400 -+++ jhagewood/sdiff/sdiff/sdiff.1 2012-07-07 19:37:23.000000000 -0400 +--- jhagewood/sdiff/sdiff-orig/sdiff.1 2012-07-14 03:47:32.000000000 -0400 ++++ jhagewood/sdiff/sdiff/sdiff.1 2012-07-14 03:47:32.000000000 -0400 @@ -1,9 +1,10 @@ +.\" $FreeBSD$ .\" $OpenBSD: sdiff.1,v 1.15 2007/06/29 14:48:07 jmc Exp $ @@ -111,8 +111,8 @@ -may not work with binary data. + diff -rupN jhagewood/sdiff/sdiff-orig/sdiff.c jhagewood/sdiff/sdiff/sdiff.c ---- jhagewood/sdiff/sdiff-orig/sdiff.c 2012-07-07 19:37:22.000000000 -0400 -+++ jhagewood/sdiff/sdiff/sdiff.c 2012-07-13 05:13:38.000000000 -0400 +--- jhagewood/sdiff/sdiff-orig/sdiff.c 2012-07-14 03:47:32.000000000 -0400 ++++ jhagewood/sdiff/sdiff/sdiff.c 2012-07-14 03:47:32.000000000 -0400 @@ -5,6 +5,15 @@ * Public domain. */ From owner-svn-soc-all@FreeBSD.ORG Sat Jul 14 13:00:14 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id EF113106566B for ; Sat, 14 Jul 2012 13:00:12 +0000 (UTC) (envelope-from rudot@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Sat, 14 Jul 2012 13:00:12 +0000 Date: Sat, 14 Jul 2012 13:00:12 +0000 From: rudot@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120714130012.EF113106566B@hub.freebsd.org> Cc: Subject: socsvn commit: r239377 - soc2012/rudot/sys/kern X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Jul 2012 13:00:14 -0000 Author: rudot Date: Sat Jul 14 13:00:12 2012 New Revision: 239377 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239377 Log: supporting both schedulers - fixing %cpu calculations Modified: soc2012/rudot/sys/kern/kern_racct.c Modified: soc2012/rudot/sys/kern/kern_racct.c ============================================================================== --- soc2012/rudot/sys/kern/kern_racct.c Sat Jul 14 12:15:20 2012 (r239376) +++ soc2012/rudot/sys/kern/kern_racct.c Sat Jul 14 13:00:12 2012 (r239377) @@ -145,10 +145,13 @@ RACCT_IN_MILLIONS, [RACCT_PCTCPU] = RACCT_RECLAIMABLE | RACCT_DENIABLE }; +#ifdef SCHED_4BSD /* * Contains intermediate values for %cpu calculations to avoid using floating * point in the kernel. - * ccpu_exp[k] = FSCALE * exp(-k/20) + * ccpu_exp[k] = FSCALE * (ccpu/FSCALE)^k = FSCALE * exp(-k/20) + * It is needed only for the 4BSD scheduler, because in ULE, the ccpu equals to + * zero so the calculations are more straightforward. */ fixpt_t ccpu_exp[] = { [0] = FSCALE * 1, @@ -263,9 +266,18 @@ [109] = FSCALE * 0.00429630469075234057, [110] = FSCALE * 0.00408677143846406699, }; +#endif #define CCPU_EXP_MAX 110 +/* + * This function is analogical to the getpcpu() function in the ps(1) command. + * They should both calculate in the same way so that the racct %cpu + * calculations are consistent with the values showed by the ps(1) tool. + * The calculations are more complex in the 4BSD scheduler because of the value + * of the ccpu variable. In ULE it is defined to be zero which saves us some + * work. + */ u_int racct_getpcpu(struct proc *p) { @@ -290,14 +302,22 @@ pctcpu_next += sched_pctcpu_delta(td); p_pctcpu += max(pctcpu, pctcpu_next); #else + /* + * In ULE the %cpu statistics are updated on every + * sched_pctcpu() call. So special calculations to + * account for the latest (unfinished) second are + * not needed. + */ p_pctcpu += sched_pctcpu(td); #endif thread_unlock(td); } +#ifdef SCHED_4BSD if (swtime <= CCPU_EXP_MAX) { return ((100 * p_pctcpu) / (FSCALE - ccpu_exp[swtime])); } +#endif return ((100 * p_pctcpu) / FSCALE); } From owner-svn-soc-all@FreeBSD.ORG Sat Jul 14 19:24:17 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id E49B01065673 for ; Sat, 14 Jul 2012 19:24:14 +0000 (UTC) (envelope-from tzabal@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Sat, 14 Jul 2012 19:24:14 +0000 Date: Sat, 14 Jul 2012 19:24:14 +0000 From: tzabal@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120714192414.E49B01065673@hub.freebsd.org> Cc: Subject: socsvn commit: r239381 - soc2012/tzabal/client-side/akcrs-head/usr.sbin/crashreport X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Jul 2012 19:24:17 -0000 Author: tzabal Date: Sat Jul 14 19:24:14 2012 New Revision: 239381 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239381 Log: Host public key and User private key of the new test server (akcrs.dyndns.org) added. Modified: soc2012/tzabal/client-side/akcrs-head/usr.sbin/crashreport/crashreport.sh Modified: soc2012/tzabal/client-side/akcrs-head/usr.sbin/crashreport/crashreport.sh ============================================================================== --- soc2012/tzabal/client-side/akcrs-head/usr.sbin/crashreport/crashreport.sh Sat Jul 14 18:10:44 2012 (r239380) +++ soc2012/tzabal/client-side/akcrs-head/usr.sbin/crashreport/crashreport.sh Sat Jul 14 19:24:14 2012 (r239381) @@ -388,38 +388,16 @@ # Host public key host_public_key_file=`mktemp /tmp/crashreport.XXXXXX` echo "akcrs.dyndns.org ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzd\ -HAyNTYAAAAIbmlzdHAyNTYAAABBBIhASIzluEhQKC/R3aVYpdV7IU14XCDKnXp8c1/Bc\ -2m6ri7SaW0sJxihnGjgm4n3XFa+s5FpjHbN4snK4NAuDEY=" > ${host_public_key_file} +HAyNTYAAAAIbmlzdHAyNTYAAABBBIOyU/PBNKT4Ygcjj0SkkVy5dzv07WQYb9RajtWF6\ +SH0nGjy9HZUcSXbPzt/GXp/dzMHSdUahC2vMBPBWDoIkVI=" > ${host_public_key_file} # User private key user_private_key_file=`mktemp /tmp/crashreport.XXXXXX` -echo "-----BEGIN RSA PRIVATE KEY----- -MIIEowIBAAKCAQEAxpufuG9WyYDhq/96/EmIrLd+ent/nZns7eHA41zeiSObGgTO -Rml6w6aXSWglUzv3RHDilXYWcUpZ61ke5bf+coVARmfqp5qhpwxvoGr2//jD4R0x -PLCY1U2bZKxEJhhresWQIhhF9TZ6zYRpkm3to9PpsqTfR812gDcKjBAZ3+RGGBhR -7q/LNiXVasMyIplSobcZvC+5klh4J/N2u4teC9BruxVTBScyqsayJg1V4g4OmzZY -VY0tHKOivn55X2tb5a9mKpKWxJY6OYo0r/3bqqfFC+b58hYSy51HR3mCpJBQJGgH -a2uab/TEJ3i/A4Hnfv6iRDqhdxXfgPc3WetVrwIDAQABAoIBAFpXYfDwXGbuhDjL -zrLB9DS0hwjJ8oPLB7YxcZ86mFODacMNGpN22Yvz1G9ku03AQjrUqozYGV9RNdPT -RzWxW0HWkSU1kczJjuzAwGoVHePT0a4trD7yCaNFWQETRzCY/RLsmSKZLgFb1cJ0 -j902udlCxNQpIRO1R0kNQHPzwwFPNGUCbAjMgVzuCK0sf1705fMXaI87oYiPZWXS -80UJEUjS/oSqcMQyRZIAZhKysbGikXpujc91YZHJ3rIgyswPxsoHdZVPT1F0W/ip -H7F+lOI+ipwcl4J2ZOYSTFu7GXeQbx2kqPiN1oMLa4hPdEDi14B3lBM8qrljsIKE -1ZPSszECgYEA8S+H5sCJXX1fAhWBPtE7FpRNiwJ7HuG2bjC/pUXfRl/U2F1+UVUt -x10hbsfdtAays25i3L+1SJiyNHDzzN/aN08V6vXULSeYhJiAMFwnoFYM6KtdrU+E -06jpR/EjhVl+JbuzeYzwbIipaODsqFOTVotuddieLb0hIlmoNWWoVlkCgYEA0s6W -tn+u499fr2sppLIsBB0qzbVvlsxYYFPbm3ZFPO8BV+0hEldwAUoBN32cBy+N7TRU -zIEuKWkysyX72Sd7EN+KAF+ULshi2T/jf80HaKOoPcdcS73Q7Y0KJJJ2D9G5B+U7 -zQ22tPNTcOJFmR5s8+baY9qUhrRCTSvvLfwgG0cCgYEA6KEbx+n1lIMUXII5g0l0 -YLbyhB4EeyjiOS4z60mVrd9JANhMuk4aNa0STjPhF39OZdsW6CzQwhDl8cbwoK9Z -XvedAF/UIymJ5nrhScPZRME6+kAvvrZwO2c0evuPc1N6ZRLCbX8Pdt/p5wrruP/D -oTojdO9Wwm8lwmgP4lEHKSECgYB6LFzQfAOB8U1lPvgtiU1VPQo3mjWH8fouKauW -196cx+/BY57NIHu7Y4Z9AIFS8M6ScMfMlfmI6n0FsrfZTLZYOxWhzcL1shEH060n -vk3S6TZyR35IL0RMyHbeZzuhQ2y3FLWpy47eJD9xptGrQiTm3h4nzOBTiVj7nMDL -p9l7tQKBgB9cgiwW0wqTk+Rz+vG4dlBn8P+qzSFo5qoSxa7siIRJf5/R3Cz6QRSy -/Fn0mQpcI8AZkF96dt5thwIA5X2HmpxURI4gbmUHbXIq8+H9pHzQ8wPK6JeqEzxC -4A2OywvWcs45QnlxYmKUIL6x8stKQAbtuHkbda3v/4ts/+6Y0jss ------END RSA PRIVATE KEY-----" > ${user_private_key_file} +echo "-----BEGIN EC PRIVATE KEY----- +MHcCAQEEIFpCoJVsxQKmmL86e2Qy730Gjr7h+1Yx8Ipo3QjHaPrQoAoGCCqGSM49 +AwEHoUQDQgAELxqi+e3OH1LwxH4iMhd+PVnsQpsMA6+uNWn9iTi93LK4NJ6clBlg +FUqAG7jvtFV2AJcfIWDLOsYuTbBaEWajiA== +-----END EC PRIVATE KEY-----" > ${user_private_key_file} scp -o GlobalKnownHostsFile="${host_public_key_file}" -o BatchMode=yes \ -i "${user_private_key_file}" -q "${report}" "${user}@${host}:${file}"