Posts tagged ‘man page’

Indexing your man pages

Its not as boring as you think, but you’ll HAVE to do it when you don’t have a windex file and want to search using man -k :

anton@opensolaris:/$ man -k grub
/usr/share/man/windex: No such file or directory

To get round this, we simply go ahead and create the index with catman:

anton@opensolaris:/$ pfexec time catman -w

real        2.9
user        1.8
sys         0.1

Its pretty quick, and you get left with a little index in /usr/share/man/windex. Its just an ascii version of all the names of your manpages, plus a one line summary of what each one does:

1        1 (3openssl)    - OpenSSL configuration functions
1        1 (3openssl)    - OpenSSL configuration functions
1394        ieee1394 (7d)    - Solaris IEEE-1394 Architecture
2        2 (3openssl)    - \& OpenSSL configuration cleanup functions
2        2 (3openssl)    - \& OpenSSL configuration cleanup functions
2        2 (3openssl)    - \& OpenSSL configuration cleanup functions
2.1        EasyTAG (1)    - Tag editor for MP3 and Ogg Vorbis files
2_F32_Sat    mlib_SignalConvertShift_U8_S8_Sat (3mlib)   – data type convert
with shifting
5.0        MySQL (1)    - MySQL RDBMS version 5.0 for Solaris
6to4        tun (7m)    - tunneling STREAMS module
6to4relay    6to4relay (1m)    - administer configuration for 6to4 relay router
communication
6to4tun     tun (7m)    - tunneling STREAMS module
7-Zip        7-Zip (1)    - A file archiver with highest compression ratio

So now when you do your man -k , you’ll get something useful!:

anton@opensolaris:/$ man -k grub
bootadm     bootadm (1m)    - manage bootability of GRUB-enabled operating system
grub        grub (5)    - GRand Unified Bootloader software on Solaris
installgrub    installgrub (1m)    – install GRUB in a disk partition or a floppy

Crucially you only want to do catman -w , otherwise you’ll be reformatting all your manpages!

From the man page of catman:

-w                  Only create the windex database that  is
used  by whatis(1) and the man(1) -f and
-k options.  No manual  reformatting  is
done.

cd needs execute permissions to work?!

You need execute permission on a directory to cd to it! Is read not enough? In practice, no. The chdir system call requires execute permission to make that directory the starting point for path searches. According to the chdir (system call, section 2) man page:

For a directory to become the current directory, a process
must have execute (search) access to the directory.

So when trussing the output of a failed cd to a directory with no execute permissions we see:

chdir("lala") Err#13 EACCES [file_dac_search]
chdir("lala") Err#13 EACCES [file_dac_search]

and as the man page goes on to say:

EACCES Search permission is denied for any com-
ponent of the path name.

Reading this article explains, that of course you can’t execute a directory but rather, that the execute permission bit is reused for different purposes. Without execute permission on the directory, you can’t stat() any files within the directory. Opening, deleting and other operations on a file first require you to stat() it first, as stat() gives you the files inode. Without the files inode, theres very little you can do with it!

Armed with this knowledge you might feel inspired to check out the source code of this call for yourself!