[ale] chroot and /proc?

Jerry Yu jjj863 at gmail.com
Tue Apr 1 15:12:47 EDT 2008


can a regular file  ./proc/cpuinfo  containing the correct info fool  it?
I'd think fopen won't care if the file is on real fs or not.

2008/4/1 Jeff Lightner <jlightner at water.com>:

>   I guess I should have mentioned the OP on the BIND list specifically
> stated that using "-n 4" still only resulted in BIND finding 1 CPU.
>
>
>
> Later discussion on the BIND list (after I'd posted here) indicates:
>
> After quick look into bind and glibc code /proc has to be mounted.
>
> named calls sysconf(3) function and internal glibc implementation looks
> like this:
>
>
>
> __get_nprocs () {
>
> ..
>
>   FILE *fp = fopen ("/proc/stat", "rc");
>
>   if (fp != NULL) {
>
>     ..
>
>   } else {
>
>     fp = fopen ("/proc/cpuinfo", "rc");
>
>     if (fp != NULL) {
>
>       ..
>
>     }
>
>     ..
>
>   }
>
>
>
>   return 1;
>
> }
>
>
>
> So if you don't have /proc mounted in chroot glibc is not able to get
> number of CPUs and returns 1. When you don't need detect correct number of
> CPUs (always use one CPU) then you don't have to mount /proc
>
>
>
> The poster was from RedHat and in a later post indicated he was going to
> work on a patch to determine number of CPUs BEFORE BIND starts the chroot
> environment as suggested in response to the above.
>
>
>
> That seems to sum it up nicely for me.
>
>
>  ------------------------------
>
> *From:* ale-bounces at ale.org [mailto:ale-bounces at ale.org] *On Behalf Of *Jason
> Fritcher
> *Sent:* Tuesday, April 01, 2008 2:20 PM
> *To:* ale at ale.org
> *Subject:* Re: [ale] chroot and /proc?
>
>
>
>
>
> On Apr 1, 2008, at 12:09 PM, Jeff Lightner wrote:
>
>  Alternatively I'm wondering if there isn't a better way to let the chroot
> environment BIND know that there are 4 CPUs?
>
>
>
> Sure, there is a command-line option to tell it how many CPUs there are...
>
>
>
>        -n #cpus
>
>           Create #cpus worker threads to take advantage of multiple CPUs.
> If
>
>           not specified, named will try to determine the number of CPUs
>
>           present and create one thread per CPU. If it is unable to
> determine
>
>           the number of CPUs, a single worker thread will be created.
>
>
>
> --
>
> Jason Fritcher
>
> jkf at wolfnet.org
>
>
>
>
>
>
>   ----------------------------------
> CONFIDENTIALITY NOTICE: This e-mail may contain privileged or confidential
> information and is for the sole use of the intended recipient(s). If you are
> not the intended recipient, any disclosure, copying, distribution, or use of
> the contents of this information is prohibited and may be unlawful. If you
> have received this electronic transmission in error, please reply
> immediately to the sender that you have received the message in error, and
> delete it. Thank you.
> ----------------------------------
>
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://mail.ale.org/mailman/listinfo/ale
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.ale.org/pipermail/ale/attachments/20080401/bab65c4d/attachment.html 


More information about the Ale mailing list