Библиотека сайта rus-linux.net
There is a vast proliferation of audio hardware on the market and
each sound card has its own particular configuration. For details on how
to set up a particular sound card we can turn to the Sound-HOWTO
available from The Linux Documentation
Project. In a broader sense, however, we can treat a sound card
like any other piece of new hardware. To add new hardware to a GNU/Linux
system we will need configure the kernel to recognize it and configure
/dev files on the root disk to access it.
In order to support sound cards, a new kernel will have to be built. It is very important that audio hardware support be configured as built-in, because Pocket Linux is not set up to handle kernel modules.
Probably the easiest way to create more space for the mp3blaster
program is to mount an additional storage device. There are several
choices for mount points. So far
/opt are all empty
directories and any one of them could be used to mount a floppy, CD-ROM
or additional compressed ramdisk image. The
directory is a logical choice for a place to put an application, but
what about the choice of media? Mp3blaster and its required libraries
are too big to fit on a 1.44M floppy and burning a CD-ROM seems like a
lot of work for one little program. So given these constraints, the best
choice would be to put the program on a compressed floppy.
Mounting CDs and uncompressed diskettes is easy, but what about loading compressed images from floppy into ramdisk? It will have to be done manually, because automatic mounting of compressed floppies only works for the root diskette. And using mount /dev/fd0 will not work because there is no filesystem on the diskette, there are only the contents of a gzip file. The actual filesystem is contained inside the gzip file. So how can we mount the filesystem buried beneath the gzip file? This puzzle can be solved by examining at the steps used to create the familiar compressed root disk floppy.
A ramdisk is created, mounted and filled with files.
The ramdisk device is unmounted.
The contents of the ramdisk are dumped to an image file using dd.
The image file is compressed with gzip.
The compressed image file is written to floppy with dd.
If that is how the compressed image makes its way from ramdisk to compressed floppy, then going from compressed floppy to ramdisk should be as simple as running through the steps in reverse.
The compressed image file is read from floppy with dd.
The image file is uncompressed with gunzip.
The contents of the image file are dumped into ramdisk using dd.
The ramdisk device is mounted.
The files are available.
We can cut out the intermediate image file by using a pipe to combine dd and gunzip like this: dd if=/dev/fd0 | gunzip -cq > /dev/ram1. Now the compressed floppy goes straight into ramdisk, decompressing on the fly.
We already have kernel support for ramdisks, because we are
using a compressed root disk, but we will need to create more ramdisks
/dev. Typically the kernel supports eight
used for the rootdisk. The
included in the Linux source code documentation will be helpful for
matching devices to their major and minor numbers.
The sample mp3 file that we will be using in our example is small enough to fit on an uncompressed floppy disk so that there is no need to burn a CD. However, serious music lovers may want to have the capability to mount a custom CD-ROM full of tunes and that option will require support for additional hardware.
Most modern CD-ROM drives will use IDE devices like
support these CD-ROM drives we will have to configure IDE support in
the kernel and create the appropriate device files on the root
CD-ROMs have different filesystems than hard disks and floppies. Most CD burning applications use a filesystem called ISO-9660 and have the capability to support Joliet or Rockridge extensions. We will have to include support for these filesystems in the kernel in order to mount CD-ROMs.
We will want to have all of mp3blaster's required libraries and
other supporting files available as part of the compressed
/usr image so that mp3blaster can run correctly.
The familiar ldd command can be used to determine
which libraries mp3blaster requires. Any additional libraries can be
/usr/lib. Even though some of the
libraries may appear in
/lib on the development
system, they can still go in
/usr/lib on the Pocket
Linux system. The dynamic linker,
smart enough to look in both places when loading libraries.
Because mp3blaster uses the curses (or ncurses) screen control
library there is one additional file we need. The curses library needs
to know the characteristics of the terminal it is controlling and it
gets that information from the terminfo database. The terminfo database
consists of all the files under the
/usr/share/terminfo directory and is very large
compared to our available disk space. But, since Pocket Linux only
supports the PC console, we only have one terminal type to worry about
and therefore need only one file. The piece of the terminfo database we
need is the file
because we are using a "Linux" terminal. For more information about the
subject of curses, see John Strang's book entitled "Programming with
Curses" available from O'Reilly
Between sound cards, ramdisks, CD-ROMs and terminfo there is quite a bit to keep track of. So let's take a moment to organize and summarize the tasks necessary to make the pocket jukebox a reality.
Create a new kernel disk that includes built-in support for audio hardware, IDE devices and CD-ROM filesystems.
Create the appropriate
/devfiles on the root disk to support audio hardware, additional ramdisks and IDE CD-ROMs.
Install the gunzip utility to enable decompression of the usr image.
Create a startup script to load a compressed image from floppy into a ramdisk and mount the ramdisk on
Create a compressed floppy that holds the mp3blaster program, its required libraries and terminfo files.
Только зарегистрированные пользователи могут оценивать и комментировать статьи.