From owner-p4-projects@FreeBSD.ORG Tue Jun 13 17:57:12 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 395A116A5A0; Tue, 13 Jun 2006 17:57:09 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 72CC416A4D0; Tue, 13 Jun 2006 17:57:00 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from server.baldwin.cx (66-23-211-162.clients.speedfactory.net [66.23.211.162]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5014843D46; Tue, 13 Jun 2006 17:57:00 +0000 (GMT) (envelope-from jhb@freebsd.org) Received: from localhost.corp.yahoo.com (john@localhost [127.0.0.1]) (authenticated bits=0) by server.baldwin.cx (8.13.4/8.13.4) with ESMTP id k5DHuo2B024438; Tue, 13 Jun 2006 13:56:58 -0400 (EDT) (envelope-from jhb@freebsd.org) From: John Baldwin To: Roman Divacky Date: Tue, 13 Jun 2006 13:44:08 -0400 User-Agent: KMail/1.9.1 References: <200606131712.k5DHCIjF063625@repoman.freebsd.org> In-Reply-To: <200606131712.k5DHCIjF063625@repoman.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200606131344.08736.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH authentication, not delayed by milter-greylist-2.0.2 (server.baldwin.cx [127.0.0.1]); Tue, 13 Jun 2006 13:56:58 -0400 (EDT) X-Virus-Scanned: ClamAV 0.87.1/1537/Tue Jun 13 07:24:06 2006 on server.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-4.4 required=4.2 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.1.0 X-Spam-Checker-Version: SpamAssassin 3.1.0 (2005-09-13) on server.baldwin.cx Cc: Perforce Change Reviews Subject: Re: PERFORCE change 99144 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: Tue, 13 Jun 2006 17:57:12 -0000 On Tuesday 13 June 2006 13:12, Roman Divacky wrote: > http://perforce.freebsd.org/chv.cgi?CH=99144 > > Change 99144 by rdivacky@rdivacky_witten on 2006/06/13 17:12:02 > > Make the LINUXBASE path settable via sysctl. Useful when you have more then one linux bases > installed etc. Since you only check the one global variable, why did you make the sysctl's try to handle per-prison paths? > example: > sysctl compat.linux.emulpath=/tmp/linux/ > /tmp/linux/bin/grep > Usage: grep [OPTION]... PATTERN [FILE]... > > Affected files ... > > .. //depot/projects/soc2006/rdivacky_linuxolator/amd64/linux32/linux32_sysvec.c#2 edit > .. //depot/projects/soc2006/rdivacky_linuxolator/compat/linux/linux_mib.c#2 edit > .. //depot/projects/soc2006/rdivacky_linuxolator/compat/linux/linux_mib.h#2 edit > .. //depot/projects/soc2006/rdivacky_linuxolator/i386/linux/linux_sysvec.c#2 edit > > Differences ... > > ==== //depot/projects/soc2006/rdivacky_linuxolator/amd64/linux32/linux32_sysvec.c#2 (text+ko) ==== > > @@ -1018,7 +1018,7 @@ > ELFOSABI_LINUX, > EM_386, > "Linux", > - "/compat/linux", > + linux_emul_path, > "/lib/ld-linux.so.1", > &elf_linux_sysvec, > NULL, > @@ -1029,7 +1029,7 @@ > ELFOSABI_LINUX, > EM_386, > "Linux", > - "/compat/linux", > + linux_emul_path, > "/lib/ld-linux.so.2", > &elf_linux_sysvec, > NULL, > > ==== //depot/projects/soc2006/rdivacky_linuxolator/compat/linux/linux_mib.c#2 (text+ko) ==== > > @@ -38,7 +38,10 @@ > #include > #include > #include > +#include > +#include > > +extern Elf32_Brandinfo *linux_brandlist[]; > #include "opt_compat.h" > > #ifdef COMPAT_LINUX32 > @@ -52,6 +55,7 @@ > char pr_osname[LINUX_MAX_UTSNAME]; > char pr_osrelease[LINUX_MAX_UTSNAME]; > int pr_oss_version; > + char pr_emul_path[LINUX_NAME_MAX]; > }; > > SYSCTL_NODE(_compat, OID_AUTO, linux, CTLFLAG_RW, 0, > @@ -81,6 +85,32 @@ > 0, 0, linux_sysctl_osname, "A", > "Linux kernel OS name"); > > +char linux_emul_path[LINUX_NAME_MAX] = "/compat/linux/"; > + > +static int > +linux_sysctl_linux_emul_path(SYSCTL_HANDLER_ARGS) > +{ > + char emul_path[LINUX_NAME_MAX]; > + int error; > + Elf32_Brandinfo **brandinfo; > + > + linux_get_emul_path(req->td, emul_path); > + error = sysctl_handle_string(oidp, emul_path, LINUX_NAME_MAX, req); > + if (error || req->newptr == NULL) > + return (error); > + error = linux_set_emul_path(req->td, emul_path); > + for (brandinfo = &linux_brandlist[0]; *brandinfo != NULL; > + ++brandinfo) > + if (elf32_insert_brand_entry(*brandinfo) < 0) > + error = EINVAL; > + return (error); > +} > + > +SYSCTL_PROC(_compat_linux, OID_AUTO, emulpath, > + CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_PRISON, > + 0, 0, linux_sysctl_linux_emul_path, "A", > + "Linux kernel OS emulation path"); > + > static char linux_osrelease[LINUX_MAX_UTSNAME] = "2.4.2"; > > static int > @@ -246,6 +276,51 @@ > return (0); > } > > +void > +linux_get_emul_path(struct thread *td, char *dst) > +{ > + register struct prison *pr; > + register struct linux_prison *lpr; > + > + pr = td->td_ucred->cr_prison; > + if (pr != NULL) { > + mtx_lock(&pr->pr_mtx); > + if (pr->pr_linux != NULL) { > + lpr = (struct linux_prison *)pr->pr_linux; > + if (lpr->pr_emul_path[0]) { > + bcopy(lpr->pr_emul_path, dst, LINUX_NAME_MAX); > + mtx_unlock(&pr->pr_mtx); > + return; > + } > + } > + mtx_unlock(&pr->pr_mtx); > + } > + > + mtx_lock(&osname_lock); > + bcopy(linux_emul_path, dst, LINUX_NAME_MAX); > + mtx_unlock(&osname_lock); > +} > + > +int > +linux_set_emul_path(struct thread *td, char *emul_path) > +{ > + struct prison *pr; > + struct linux_prison *lpr; > + > + pr = linux_get_prison(td); > + if (pr != NULL) { > + lpr = (struct linux_prison *)pr->pr_linux; > + strcpy(lpr->pr_emul_path, emul_path); > + mtx_unlock(&pr->pr_mtx); > + } else { > + mtx_lock(&osname_lock); > + strcpy(linux_emul_path, emul_path); > + mtx_unlock(&osname_lock); > + } > + > + return (0); > +} > + > int > linux_get_oss_version(struct thread *td) > { > > ==== //depot/projects/soc2006/rdivacky_linuxolator/compat/linux/linux_mib.h#2 (text+ko) ==== > > @@ -40,4 +40,7 @@ > int linux_get_oss_version(struct thread *td); > int linux_set_oss_version(struct thread *td, int oss_version); > > +void linux_get_emul_path(struct thread *td, char *dst); > +int linux_set_emul_path(struct thread *td, char *emul_path); > + > #endif /* _LINUX_MIB_H_ */ > > ==== //depot/projects/soc2006/rdivacky_linuxolator/i386/linux/linux_sysvec.c#2 (text+ko) ==== > > @@ -858,7 +858,7 @@ > ELFOSABI_LINUX, > EM_386, > "Linux", > - "/compat/linux", > + linux_emul_path, > "/lib/ld-linux.so.1", > &elf_linux_sysvec, > NULL, > @@ -869,7 +869,7 @@ > ELFOSABI_LINUX, > EM_386, > "Linux", > - "/compat/linux", > + linux_emul_path, > "/lib/ld-linux.so.2", > &elf_linux_sysvec, > NULL, > -- John Baldwin