On Mon, Jul 31, 2006 at 09:47:24PM +0600, Alexander E. Patrakov wrote:
> Dan Nicholson wrote:
> 
> >Looks like the /dev/fd issue is the culprit. Nice job, fellas. Now,
> >can anyone look at the configure macro to see how this issue is
> >decided? There might be an easy workaround. I don't have the source
> >handy.
> 
> Sledgehammer approach follows (untested):
> 
> ./configure --whatever-else-is-in-the-book bash_cv_dev_fd=standard
> 
> or the equivalent config.cache entry.
> 
 Sounds good as a solution, but I'd like to understand what is wrong
- it looks like a side-effect of su'ing to lfs.

 For people who haven't read the configure script, the relevant part
is here:

echo "$as_me:$LINENO: checking whether /dev/fd is available" >&5
echo $ECHO_N "checking whether /dev/fd is available... $ECHO_C" >&6
if test "${bash_cv_dev_fd+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  if test -d /dev/fd  && test -r /dev/fd/0 < /dev/null; then
# check for systems like FreeBSD 5 that only provide /dev/fd/[012]
   exec 3<&0
   if test -r /dev/fd/3; then
     bash_cv_dev_fd=standard
   else
     bash_cv_dev_fd=absent
   fi
   exec 3<&-
 elif test -d /proc/self/fd && test -r /proc/self/fd/0 < /dev/null;
then
   bash_cv_dev_fd=whacky
 else
   bash_cv_dev_fd=absent
 fi

fi

 I've broken this out into parts to see where it fails (attached),
and it is because it cannot read /dev/fd/3.  I have three users here
(ken, lfs, root) and I'm logged in as ken.  If I su to 'lfs',
/dev/fd/3 is not readable. [ this is on an LFS udev system from
March, similar results on a fairly recent CLFS system ].

 If I go to a tty and log in directly as 'lfs', the test works.  If
I then su to 'ken', the test fails.  If I su to root, it works again.

 In an xterm, for user ken (who is logged in) I get the following:

[EMAIL PROTECTED] ~ $ls -l /dev/fd
lrwxrwxrwx 1 root root 13 2006-07-31 12:24 /dev/fd -> /proc/self/fd
[EMAIL PROTECTED] ~ $ls -l /proc/self/fd
total 4
lrwx------ 1 ken goodusers 64 2006-07-31 18:59 0 -> /dev/pts/2
lrwx------ 1 ken goodusers 64 2006-07-31 18:59 1 -> /dev/pts/2
lrwx------ 1 ken goodusers 64 2006-07-31 18:59 2 -> /dev/pts/2
lr-x------ 1 ken goodusers 64 2006-07-31 18:59 3 -> /proc/3860/fd
[EMAIL PROTECTED] ~ $ls -l /dev/pts/2
crw--w---- 1 ken tty 136, 2 2006-07-31 19:00 /dev/pts/2
[EMAIL PROTECTED] ~ $

 After 'su lfs' I get:

[EMAIL PROTECTED] /home/ken$ ls -l /proc/self/fd
total 4
lrwx------ 1 lfs goodusers 64 Jul 31 19:03 0 -> /dev/pts/2
lrwx------ 1 lfs goodusers 64 Jul 31 19:03 1 -> /dev/pts/2
lrwx------ 1 lfs goodusers 64 Jul 31 19:03 2 -> /dev/pts/2
lr-x------ 1 lfs goodusers 64 Jul 31 19:03 3 -> /proc/3865/fd
[EMAIL PROTECTED] /home/ken$

 The link for /proc/self/fd/3 seems to point to a transient process
(ls -l, I guess).

 I'll test the bash_cv_dev_fd stuff after I've eaten, because people
are seeing the problem in c++-types-check.out, but I'm now wondering
if there is something wrong in the build method ?

 Oh, and it does seem to affect LFS too.  I haven't built a recent
LFS, but back in March on the udev branch in my log for ch5 bash -
checking whether /dev/fd is available... absent
 Strangely, I don't have any test results from glibc for that build
(an error in my script, I think) so I can't be sure if glibc-2.3.6
shows the problem in c++-types-check.

Ken
-- 
das eine Mal als Tragödie, das andere Mal als Farce
#!/bin/bash
# tests from line 23098 of bash-3.1 configure script
# to determine if /dev/fd is available.
echo -n "testing if /dev/fd is a directory... "
test -d /dev/fd
if [ $? -eq 0 ]; then
        echo "yes"
        ISDIR=yes
else
        echo "no"
fi

echo -n "testing if /dev/fd/0 is readable... "
test -r /dev/fd/0 </dev/null
if [ $? -eq 0 ]; then
        echo "yes"
        CANREAD=yes
else
        echo "no"
fi

if [ "$ISDIR" == "yes" ] && [ "$CANREAD" == "yes" ]; then
        exec 3<&0
        test -r /dev/fd/3
        if [ $? -eq 0 ];then
                echo "Result is standard"
        else
                echo "Result is absent because cannot read /dev/fd/3"
        fi
else
        if [ -d /proc/self/fd ]; then
                echo "/proc/self/fd exists"
                test -r /proc/self/fd/0 < /dev/null
                if [ $? -eq 0 ]; then
                        echo "Result is whacky"
                else
                        echo "Result is absent because cannot read 
/proc/self/fd/0"
                fi
        else
                echo "Result is absent because /proc/self/fd is missing or not 
a directory"
        fi
fi

_______________________________________________
Clfs-dev mailing list
[email protected]
http://lists.cross-lfs.org/cgi-bin/mailman/listinfo/clfs-dev

Reply via email to