return to first page linux journal archive
keywordscontents

Best of Technical Support

Two Monitors?

Is it possible in Linux (I don't care which distribution, I mean the system architecture) to have two screens, i.e., two monitors on the same machine? Also with two graphics cards, of course. Is it possible to have them running together, either in text mode or serving X? And is it possible to have only one actual X desktop, but two virtual ones projected over two different screens?
--
Eduardo Garcia, egarcia@msl.es

The ``two screens'' support you've mentioned is called multi-headed display support. It is the ability to use two (three and so on) monitors simultaneously and usually make them act as one huge virtual desktop. The commercial X servers such as Accelerated X (http://www.xig.com/) and Metro-X (http://www.metrolink.com/) already have such support, and recently XFree supports this too (but it is not stable enough, in my opinion). Be aware, though, that your hardware (graphics card) must also support this.
--
Mario de Mello Bittencourt Neto, mneto@argo.com.br

With XFree 4.0, you can run X on two cards and two monitors, either as independent sessions or as one big screen (Xinerama). It should also be possible to get XFree 4.0 to open one X session on the secondary screen (i.e., not the one Linux is displaying console messages on) and keep text mode in the other monitor, but there isn't a convenient way to switch back and forth between the two screens (you'd have to use CTRL+ALT+FN). Frame buffer (FB) support will also work with two video cards, so my guess is that the FB application gets to say which FB display to write on.
--
Marc Merlin, marc_bts@valinux.com

As installation of XFree86 4.0 is not for the faint-hearted, you may want to hold off until RPM packages start to appear before trying it.
--
Erik Ratcliffe, erik@calderasystems.com

It depends on your X server software. XFree86 version 4 (which is more recent than the version included in your Red Hat distribution) has some support for multi-headed configurations; you can check their release notes under http://www.xfree86.org/.
--
Scott Maxwell, maxwell@ScottMaxwell.org

fopen

What is the scope of fopen? That is, when you use this system call, where exactly does it look for the file we want to open?

--
Kumhaar, kumhaar@yahoo.com

If you supply an absolute file name (that is, one that starts with a "/"), then fopen starts at the root directory. Otherwise, the file name is relative, so fopen starts looking for the file in the process's current working directory. This directory is initially the same as the parent process's current working directory (so if you ran the program from a shell, it's whatever directory you were in when you ran it), but the current working directory can be changed by calling chdir or fchdir. By the way, as a pedantic note, fopen is not a system call; it's a C library function. fopen does part of its work in terms of the system call open.
--
Scott Maxwell, maxwell@ScottMaxwell.org

The fopen library function is the analog of the low-level open system call. You use it mainly for files and terminal input/output. When you need explicit control over devices, you are better off with the low-level system calls, as they eliminate potentially undesirable side effects from libraries, like input/output buffering.

If successful, fopen returns a non-null FILE * pointer. If it fails, it returns the value NULL, defined in stdio.h.

fopen uses the open system call. Here is how the open system call works:

1. When the kernel receives an open system call, it starts the function called sys_open. You can find the code in the kernel source in fs/open.c. sys_open (const char * filename, int flags, int mode)

2. From the file name, sys_open will try to get the associated inode structure. This inode structure is located in the directory where the file is (the directory is a special file). To get the inode of the directory with the relevant information, sys_open will have to recurse by starting to read the current directory to get the inode of the relative directory, and so on.

If the file name starts with a /, the process is the same, except that it will start with inode 2 (inode number of /) on the root partition.

3. Once the inode of the file is found, sys_open will read the file operation associated with the file's inode, and run the open method associated with that inode/file.

This open method may be related to a device module if the file is a device (see major number and /proc/devices) or to a specific file system (df -k filename -> proc swap ext2 ...)

4. This open method returns a ``struct file *'' which is associated with a file descriptor.

sys_open will return a file descriptor, an integer greater than 0. If sys_open fails, it returns an integer less than 0. fopen will then associate this file descriptor (int) to a file stream (FILE *).

I hope this helps.
--
Emmanuel-Robert Mayssat, emayssat@valinux.com

fopen(2) takes two parameters. The first is the file to open, and the second tells the system to open it for reading, writing, reading and writing, and other options. If you do not specify a path to the file to open, fopen() will look for that file in the current directory.
--
Chad Robinson, Chad.Robinson@brt.com

Feel free to refer to the manual pages: use Chapter 2 for the system calls (e.g., man 2 open) and Chapter 3 for library functions (man 3 fopen).
--
Alessandro Rubini, alessandro.rubini@linux.it

Signal-7

I have tried unsuccessfully to install Linux 6.1. Here's what happens:

I put in the CD and the boot disk. The Linux program decompresses all the ``running/sbin/loader''. Then it waits a few minutes and says:

"install exited abnormally -- received signal 7"
sending termination signals.
I have asked everyone I know what ``signal 7'' means, but to no avail.

--
Michael C. Fields, kindra@2fords.net

Signal 7 is ``bus error'', as reported by /usr/include/asm/signal.h (included by /usr/include/signal.h, the first place to look). This is most likely a hardware problem on your box, similar to the ``signal 11'' (segmentation fault) problem. Please refer to the sig11 FAQ at http://www.bitwizard.nl/.
--
Alessandro Rubini, alessandro.rubini@linux.it

You fail to mention which distribution you are trying to install, but luckily, my crystal ball is telling me that it would be Red Hat, or a derivative thereof. Signal 7 is SIGBUS, which means that there are some hardware/driver issues. I'd try a newer version of Red Hat or a different distribution in case a different kernel helps on your machine.
--
Marc Merlin, marc_bts@valinux.com

parport (Parallel Port)

I have been asked by my company to write some code to write to and read from a special printer. As an example, if I shove the string ``^[I'' out the parallel port, I should be able to read back in ``TP96''. However, I am as new as they come. I have been looking at all the parport documentation, but I don't understand. Is parport already part of the kernel? Do I #include parport in my own program? How do I put all the pieces together to get this one seemingly simple task accomplished?

--
Michael J. Conroy, m_j_conroy@yahoo.com

Two web sites may help you. The first contains general parallel port programming information: http://www.lvr.com/parport.htm. The second contains information on I/O port programming under Linux: http://metalab.unc.edu/mdw/HOWTO/mini/IO-Port-Programming.html.
--
Chad Robinson, Chad.Robinson@brt.com

If you want to know more about parport, take a look at the file Documentation/parport.txt in the kernel sources hierarchy. For your personal use, you should use low-level inb/outb functions (try man outb). There is an excellent (of course :-)) article by Alessandro Rubini in LJ #47 about using parallel port.
--
Pierre Ficheux, pficheux@wanadoo.fr

Yes, it's a compile time option.

moremagic:~# cat /proc/parport/0/hardware
base:   0x378
irq:    none
dma:    none
modes:  SPP,ECP,ECPEPP,ECPPS2
moremagic:~# cat /proc/parport/0/autoprobe
MODEL:Unknown device;
MANUFACTURER:Unknown vendor;
I've never done parallel port programming, but you can write to /dev/lp0 (or lp1, lp2...) and you may be able to read back from it. One thing you can do for more information is look at the source code from lpd.
--
Marc Merlin, marc_bts@valinux.com

Athlon

Can Linux be installed on an Athlon platform?
--
Mark MacWilliam, mMacWilliam@infocell.com

Because the Athlon processor has the same instruction set (with enhancements) as the x86 processor series, Linux should run on it without problems.
--
Chad Robinson, Chad.Robinson@brt.com

Yes. The 2.2.14 kernel (or better) recognizes the Athlon, and 2.3.x (soon to be 2.4) has optimized support for the Athlon.
--
Marc Merlin, marc_bts@valinux.com

I am typing this reply using my brand-new 700MHz Athlon system (running Linux, of course!). So not only can Linux be installed on an Athlon, I can add that it runs like a dream.
--
Scott Maxwell, maxwell@ScottMaxwell.org

Trying to Install OpenLinux

I am having problems installing Caldera OpenLinux 2.3 on a PC Pentium III 450, with a SIS 620 video card and operating under Windows 98. I succeeded in making the partition on the disk for where to install OpenLinux, but when trying to install it, first it appears on the screen where the recognition of the hardware of the machine is made, and then the screen becomes frozen after showing vertical gray lines. I don't know what the problem could be. Would you help me?

--
Susana Diaz, subediaz@satlink.com

The SiS 620 chipset is supported by the SVGA server, but for whatever reason, it will not run in 16-color VGA mode (which is what OpenLinux's graphic installer uses). What you'll need to do is use the character-mode installation, then run either lizardx, XF86Setup or xf86config after the installation is done to configure the X Window System. The disk images for the character-mode installation are found in the /col/launch/lisa/floppy directory. Use RAWRITE (in DOS/Windows) or dd (in UNIX/Linux) to transfer the install.144 image to a formatted 1.44MB diskette. Use the new diskette to launch the installation.
--
Erik Ratcliffe, erik@calderasystems.com


Many on-line help resources are available on the SSC web pages. Sunsite mirror sites, FAQs and HOWTOs can all be found at http://www.linuxjournal.com/.

Answers published in Best of Technical Support are provided by a team of Linux experts. If you would like to submit a question for consideration for use in this column, please fill out the web form at http://www.linuxjournal.com/lj-issues/techsup.html or send e-mail with the subject line ``BTS'' to Ellen Dahl at bts@ssc.com.