5.7. Installing Fileutils-4.1

Estimated build time:           3 minutes
Estimated required disk space:  25 MB

5.7.1. Installation of Fileutils

The programs from a statically linked fileutils package may cause segmentation faults on certain systems, if your distribution has Glibc-2.2.3 or higher installed. It also seems to happen mostly on machines powered by an AMD CPU, but there is a case or two where an Intel system is affected as well. If your system falls under this category, try the following fix.

Note that in some cases using these sed commands will result in problems not being able to compile this at package at all, even when your system has and AMD CPU and has Glibc-2.2.3 (or higher) installed. If that's the case, you'll need to remove the fileutils-4.1 directory and unpack it again from the tarball before continuing. We believe this may be the case when your distribution has altered Glibc-2.2.3 somehow, but details are unavailable at the time.

To fix this package to compile properly on AMD/Glibc-2.2.3 machines, run the following commands. Do not attempt this fix if you don't have Glibc-2.2.3 installed. It will more than likely result in all kinds of compile time problems.

cp lib/Makefile.in lib/Makefile.in.backup &&
sed -e 's/\(.*\)\(fopen-safer\.c \)\\/\1\2atexit.c \\/' \
   -e 's/\(.*\)\(idcache\$U\.\$.*\)\\/\1\2atexit$U.$(OBJEXT) \\/' \
   lib/Makefile.in > lib/Makefile.in~ &&
mv lib/Makefile.in~ lib/Makefile.in

Install fileutils by running the following commands:

./configure --disable-nls \
   --prefix=$LFS/usr --libexecdir=$LFS/bin --bindir=$LFS/bin &&
make LDFLAGS=-static &&
make install &&
cd $LFS/usr/bin &&
ln -sf ../../bin/install

Once you have installed fileutils, you can test whether the segmentation fault problem has been avoided by running $LFS/bin/ls. If this works, then you are OK. If not, then you need to re-do the installation using the sed commands if you didn't use them, or without the sed commands if you did use them.

5.7.2. Command explanations

cp lib/Makefile.in lib/Makefile.in.backup : We run this command in order to keep a backup of the file we are about to change.

cp lib/Makefile.in lib/Makefile.in.backup &&
sed -e 's/\(.*\)\(fopen-safer\.c \)\\/\1\2atexit.c \\/' \
   -e 's/\(.*\)\(idcache\$U\.\$.*\)\\/\1\2atexit$U.$(OBJEXT) \\/' \
   lib/Makefile.in > lib/Makefile.in~ &&
mv lib/Makefile.in~ lib/Makefile.in:
This is used to fix a problem with building fileutils statically on glibc 2.2.3 systems. If this isn't done, then there is the possibility of all of the fileutils programs causing segmentation faults once chroot is entered in chapter 6.

--libexecdir=$LFS/bin: This configure option will set the program executable directory to $LFS/bin. This is normally set to /usr/libexec, but nothing is placed in it. Changing it just prevents that directory from being created.

5.7.3. Contents

The Fileutils package contains the chgrp, chmod, chown, cp, dd, df, dir, dircolors, du, install, ln, ls, mkdir, mkfifo, mknod, mv, rm, rmdir, sync, touch and vdir programs.

5.7.4. Description

5.7.4.1. chgrp

chgrp changes the group ownership of each given file to the named group, which can be either a group name or a numeric group ID.

5.7.4.2. chmod

chmod changes the permissions of each given file according to mode, which can be either a symbolic representation of changes to make, or an octal number representing the bit pattern for the new permissions.

5.7.4.3. chown

chown changes the user and/or group ownership of each given file.

5.7.4.4. cp

cp copies files from one place to another.

5.7.4.5. dd

dd copies a file (from the standard input to the standard output, by default) with a user-selectable blocksize, while optionally performing conversions on it.

5.7.4.6. df

df displays the amount of disk space available on the filesystem containing each file name argument. If no file name is given, the space available on all currently mounted filesystems is shown.

5.7.4.7. ls, dir and vdir

dir and vdir are versions of ls with different default output formats. These programs list each given file or directory name. Directory contents are sorted alphabetically. For ls, files are by default listed in columns, sorted vertically, if the standard output is a terminal; otherwise they are listed one per line. For dir, files are by default listed in columns, sorted vertically. For vdir, files are by default listed in long format.

5.7.4.8. dircolors

dircolors outputs commands to set the LS_COLOR environment variable. The LS_COLOR variable is use to change the default color scheme used by ls and related utilities.

5.7.4.9. du

du displays the amount of disk space used by each argument and for each subdirectory of directory arguments.

5.7.4.10. install

install copies files and sets their permission modes and, if possible, their owner and group.

5.7.4.11. ln

ln makes hard or soft (symbolic) links between files.

5.7.4.12. mkdir

mkdir creates directories with a given name.

5.7.4.13. mkfifo

mkfifo creates a FIFO with each given name.

5.7.4.14. mknod

mknod creates a FIFO, character special file, or block special file with the given file name.

5.7.4.15. mv

mv moves files from one directory to another or renames files, depending on the arguments given to mv.

5.7.4.16. rm

rm removes files or directories.

5.7.4.17. rmdir

rmdir removes directories, if they are empty.

5.7.4.18. shred

shred deletes a file securely, overwriting it first so that its contents can't be recovered.

5.7.4.19. sync

sync forces changed blocks to disk and updates the super block.

5.7.4.20. touch

touch changes the access and modification times of each given file to the current time. Files that do not exist are created empty.

5.7.5. Dependencies

Fileutils-4.1 needs the following to be installed:


sh from the bash package

ar from the binutils package
as from the binutils package
ld from the binutils package

cmp from the diffutils package

chmod from the fileutils package
cp from the fileutils package
install from the fileutils package
ln from the fileutils package
ls from the fileutils package
mkdir from the fileutils package
mv from the fileutils package
rm from the fileutils package

cc from the gcc package

egrep from the grep package
grep from the grep package

make from the make package

sed from the sed package

basename from the sh-utils package
expr from the sh-utils package
sleep from the sh-utils package
uname from the sh-utils package

cat from the textutils package
tr from the textutils package
uniq from the textutils package