From owner-p4-projects@FreeBSD.ORG Mon Aug 13 07:02:37 2007 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 45E2616A419; Mon, 13 Aug 2007 07:02:37 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E2A5B16A421 for ; Mon, 13 Aug 2007 07:02:36 +0000 (UTC) (envelope-from zec@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id D1FF713C4B6 for ; Mon, 13 Aug 2007 07:02:36 +0000 (UTC) (envelope-from zec@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id l7D72a1q000776 for ; Mon, 13 Aug 2007 07:02:36 GMT (envelope-from zec@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id l7D72aHi000773 for perforce@freebsd.org; Mon, 13 Aug 2007 07:02:36 GMT (envelope-from zec@FreeBSD.org) Date: Mon, 13 Aug 2007 07:02:36 GMT Message-Id: <200708130702.l7D72aHi000773@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to zec@FreeBSD.org using -f From: Marko Zec To: Perforce Change Reviews Cc: Subject: PERFORCE change 125099 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Aug 2007 07:02:37 -0000 http://perforce.freebsd.org/chv.cgi?CH=125099 Change 125099 by zec@zec_tpx32 on 2007/08/13 07:01:54 A hack to resolve character "@" to vimage name when following symbolic links. This is controlled on per-vimage basis via the new vfs.morphing_symlinks sysctl and is off by default. The primary use of this will be in IMUNES network topology emulator to allow running of multiple instances of unmodified applications with some hard coded filesystem paths, most notably quagga. While here, slightly change the format of warning messages displayed if / when vnet "stacking" occurs. Affected files ... .. //depot/projects/vimage/src/sys/kern/vfs_lookup.c#6 edit .. //depot/projects/vimage/src/sys/sys/vimage.h#33 edit Differences ... ==== //depot/projects/vimage/src/sys/kern/vfs_lookup.c#6 (text+ko) ==== @@ -40,6 +40,7 @@ #include "opt_ktrace.h" #include "opt_mac.h" #include "opt_vfs.h" +#include "opt_vimage.h" #include #include @@ -53,6 +54,7 @@ #include #include #include +#include #ifdef KTRACE #include #endif @@ -65,6 +67,15 @@ #define NAMEI_DIAGNOSTIC 1 #undef NAMEI_DIAGNOSTIC +#ifdef VIMAGE +#define IMUNES_SYMLINK_HACK +#endif + +#ifdef IMUNES_SYMLINK_HACK +SYSCTL_V_INT(V_PROCG, vprocg, _vfs, OID_AUTO, morphing_symlinks, CTLFLAG_RW, + morphing_symlinks, 0, "Resolve @ to vimage name in symlinks"); +#endif + /* * Allocation zone for namei */ @@ -129,6 +140,9 @@ struct thread *td = cnp->cn_thread; struct proc *p = td->td_proc; int vfslocked; +#ifdef IMUNES_SYMLINK_HACK + INIT_VPROCG(td->td_ucred->cr_vimage->v_procg); +#endif KASSERT((cnp->cn_flags & MPSAFE) != 0 || mtx_owned(&Giant) != 0, ("NOT MPSAFE and Giant not held")); @@ -284,6 +298,26 @@ error = ENOENT; break; } +#ifdef IMUNES_SYMLINK_HACK + if (V_morphing_symlinks) { + char *sp = strchr(cp, '@'); + int vnamelen = strlen(td->td_ucred->cr_vimage->vi_name); + + if (sp) { + if (vnamelen >= auio.uio_resid) { + if (ndp->ni_pathlen > 1) + uma_zfree(namei_zone, cp); + error = ENAMETOOLONG; + break; + } + bcopy(sp + 1, sp + vnamelen, + vnamelen - (sp - cp)); + bcopy(td->td_ucred->cr_vimage->vi_name, sp, + vnamelen); + linklen += (vnamelen - 1); + } + } +#endif /* IMUNES_SYMLINK_HACK */ if (linklen + ndp->ni_pathlen >= MAXPATHLEN) { if (ndp->ni_pathlen > 1) uma_zfree(namei_zone, cp); ==== //depot/projects/vimage/src/sys/sys/vimage.h#33 (text+ko) ==== @@ -197,9 +197,9 @@ #define CURVNET_SET_VERBOSE(arg) \ CURVNET_SET_QUIET(arg) \ if (saved_vnet) \ - printf("curvnet_set(%p) in %s() on cpu %d, prev %s(%p)\n", \ + printf("curvnet_set(%p) in %s() on cpu %d, prev %p in %s()\n", \ curvnet, curthread->td_vnet_lpush, curcpu, \ - saved_vnet_lpush, saved_vnet); + saved_vnet, saved_vnet_lpush); #define CURVNET_SET(arg) CURVNET_SET_VERBOSE(arg) @@ -291,6 +291,7 @@ #define V_cp_time VPROCG(cp_time) #define V_hostname VPROCG(hostname) #define V_domainname VPROCG(domainname) +#define V_morphing_symlinks VPROCG(morphing_symlinks) #ifdef VIMAGE void vnet_mod_register(const struct vnet_modinfo *); @@ -355,6 +356,8 @@ char _hostname[MAXHOSTNAMELEN]; char _domainname[MAXHOSTNAMELEN]; + int _morphing_symlinks; + #if 0 struct loadavg averunnable; /* from kern/kern_synch.c */ int nrun; @@ -374,9 +377,6 @@ struct timeval boottime; long boottdelta_sec; - int hostnamelen; - int domainnamelen; - char chroot[MAXPATHLEN]; /* assigned/inherited from parent */ int big_brother; /* manage procs in all child vprocgs */