Win4Lin User's Guide |
Chapter 5 -- Win4Lin resource administration |
(User's Guide Table of Contents) | (Chapter Table of Contents) |
Previous Chapter - Configuring DOS and Windows sessions | Next Chapter - Using Win4Lin from the command line |
Chapter 3 covers how Win4Lin automatically manages access to the most important hardware resources. Chapter 4 covers how you must explicitly request (attach) all other devices via named "device definitions" to use them under DOS or Windows, and that several commonly used resources have preconfigured definitions and can be attached to your DOS and Windows sessions. (These resources include physical and virtual DOS drives, default printer, parallel ports, and a game port.) So this chapter covers setting up and changing device definitions to make them available for attachment to individual Win4Lin sessions.
Most of the system wide resource administration is done via the System-Wide Win4Lin Administration part of the Win4Lin Setup GUI. To start the Win4Lin Setup graphical utility, use the command: "winsetup &". Then select "System-Wide Win4Lin Administration" and click "OK" to bring up the "System-Wide Win4Lin Administration" window.
The actual detailed instructions for using Win4Lin Setup is available via the Help button on each Win4Lin Setup window. Thus this chapter does not go into the details of using the GUI.
(Note, if you really want to you can use Linux command line utilities to accomplish exactly the same things that you can use the Win4Lin Setup GUI to do. The GUI is a lot easier to use. For information on the command-line interface, see Chapter 6, `` Using Win4Lin from the command line ''.)
The top button in the System-Wide administration window brings up the "Device Definition" window, which is the first topic in this chapter. This is the most used system-wide administration tool. Besides "device definitions", there are other system-wide Win4Lin settings that can be adjusted via the System-Wide administration GUI:
A device definition provides the information that Win4Lin needs to access a device. Once a device definition has been created, you can use the device by selecting it to be part of a personal DOS or Windows session configuration. This action is called attaching the device for use in a DOS or Windows session. You use the Personal Win4Lin Session Configuration option of the Win4Lin Setup utility to attach devices. Device attachment is described in detail in Chapter 4, ``Configuring DOS and Windows sessions''.
The Device Definition window of the System-Wide administration has five category (or view) buttons:
You use these category views to inspect, modify or delete existing definitions and to create new ones. Click on the Help buttons to get more info about how to do this.
The following controls appear on the left side of all views of the Device Definition window:
If a user is not allowed to use the definition, the entry for the definition the selection lists in the Personal Win4Lin Session Configuration window for that user has "(unavail)" appended to the description to indicate that device is not currently available for that user.
NOTE: All the default custom device definitions (parallel port and game port definitions) have "Usable by" set to "Root". You must use the Custom view of the Device Definition windows to change the setting to "All" for those devices you want to be usable from DOS and Windows sessions. (And if there are a custom device definition that you will never make available to normal users, then you should delete the definition.)
Note that the specified Failure Action does not apply to printer definitions because those definitions are used at print time and not as the Win4Lin session is starting.
Printer view --
Printer device definitionConfiguring the default printer
When Win4Lin is installed a printer definition named "Default"
is created for printing to the default Linux printer.
This of course only works if there is a default printer to print to.
If printing via this printer definition is not working properly (or you want it to work differently) then you can either change this definition to use different printer command and/or options or you can create a new printer definition. It only matters that you get a printer definition set up so that printing comes out properly. The following section covers how to do this.
Configuring a printer definition
You can print from a Win4Lin session to any number of printers that
is available via the Linux printing system as long has you
have a printer definition defined for Win4Lin.
If needed you can even have multiple printer definitions for
a single Linux printer.
(For instance if you have to use different printer options for
printing letters and for printing envelopes.
Thus you could make two printer definitions, one with the
options for printing letters and another for printing envelopes.)
Before you can start to set up a printer definition you must first be able to print from Linux. Get this working first, then you can continue on and try to print from a Win4Lin session.
To determine the exact printer command:
From your DOS or Windows application in a Win4Lin session, print your document to a file.
With Windows, you set up for printing just as you would do on a normal Windows system using the "Add Printer" utility. Using this, select your printer type to match your printer as your would expect. The only difference is when you select one of the "available ports" to use. What you select here is "FILE: Creates a file on disk" (or similar wording). Then continue on and finish "adding" this printer. Hint: No need to "print a test page". Then from a Windows application, print a document to a file using this "printer".
This is the hardest step. You must determine how to print this "print file" using the Linux printing system commands. One tricky part is that the command needs to be formed to print when the print file is fed to it via "standard in". E.g. if the print file is named "printout.prn", and the Linux print command is "lpr -P printer1" the command must be of this form must work:
cat printout.prn | lpr -P printer1
The printer command can also be any other Linux command that operates on standard input. Some examples: You can run your printer output through a filter before spooling by using the following command:
cat printout.prn | filtername | lpr -P printer2
Something like this could be used to print plain DOS text using the Win4Lin filter "dos2unix" that converts DOS text to Linux text so that printing comes out properly on the Linux printer:
cat printout.prn | dos2unix | lpr -P printer2
If you want you don't even need to use a Linux printer command if you don't want to. For example you could have a command that saves the printout in a file for later processing (perhaps for another Linux program to automatically fax later), or a command that copies the printout to a web page. The point is that all you need is a Linux program that takes it's input from "standard in".
So now that you have determined the Linux command to print
(or whatever) from the "print file",
you have all the information you need for the printer definition.
Go into Win4Lin Setup System-Wide administration to the "Printer" device
definition window to either update an existing definition
or create a new one.
(Click on the Help button if you need to for how to do these things.)
In the "Printer Command" entry type in the printer command
(sans the leading "cat printout.prn | " you used
to test the command).
Using some of the above examples, this would be:
lpr -P printer1
or
dos2unix | lpr -P printer2
Make sure to click the "Save" button.
Now all you have to do is go back into your Windows session and update your Windows icon for the printer to change the setting from "printing to a file" to print to the "port" that you defined or updated in Win4Lin Setup. (All the printer definitions that are defined via Win4Lin Setup automatically appear in the Windows properties for the printer icon as selections in the "Print to the following port:" control in the "Details" tab.)
COM1 & COM2 view --
Serial Port device definition
The Device Definition window has a COM1 and a COM2 button. Attachment of COM1 and COM2 ports is not currently supported, so the COM1 and COM2 button on the Device Definition window are inactive.
DOS Drive view --
A physical DOS drive is a portion of the fixed disk
formatted under DOS and reserved exclusively for
DOS and Windows files.
Your fixed disk may have one or more physical DOS drives of different
sizes.
Physical and virtual DOS drives
Win4Lin can access any physical DOS drive on your fixed disk. During installation, and each time you reboot your system, Win4Lin checks for the existence of physical DOS drives and updates its internal database for the drives it finds.
Win4Lin also allows you to create virtual DOS drives. A virtual DOS drive (sometimes called a virtual DOS volume) is actually a Linux file that has been formatted as a DOS file system and is used to store DOS files. One default virtual DOS volume is provided in each user's home directory.
A DOS volume may be useful with Win4Lin for the following reasons:
You use the DOS Drive view of the Device Definition window to view, create and update device definitions for real and virtual DOS volume. In the upper left of the window is the Token Name selection list. You use this to select which existing definition to view or update. To the right of that is the New button, which is used to create new definitions. For instructions on how to use this view, click on the Help button.
The tokens for physical DOS partitions that are automatically create are named dosc, dosd, and so on, while the default virtual DOS volume token is named homevdrv.
To attach an available physical or virtual DOS volume to your DOS or Windows session, use the Personal Win4Lin Session Configuration option of the Win4Lin Setup utility as described in ``Configuring drives'' in Chapter 4.
Note: Typically, by default, the device definitions for physical DOS volumes have the Usable by setting set to "Root", which means only the root user has permission to use the device definition. In order to make the volume available for normal users, you (when logged in as root) must change this setting to "All".
When the "Usable by" setting is set to "Root", the entry for the definition the selection lists in the Personal Win4Lin Session Configuration window for normal users have "(unavail)" appended to the description to indicate that device is not currently available.
When you change it from "Root" to "All", you also need to make sure the device's Linux access permissions allow the device to be readable and writeable by everyone that you want to be able to use the drive. You use the normal Linux chmod command to change the access permissions of the device.
To restrict access to only certain groups, see the later topic Limit DOS volume access to a group.
Creating and formatting physical DOS drives
If you want to have one or more physical DOS drives
on the same disk that Linux is installed on,
normally you should create them before or
at the time you install the Linux system.
You can also add a second hard disk to your computer and put one or more physical DOS drives on it.
Win4Lin automatically senses these new physical drives the next time you reboot and makes them available by creating device definitions for them as was described above.
Virtual DOS drives are different from physical DOS drives in the following ways:
Win4Lin automatically makes the definition for $HOME/vdrive.dsk (token name homevdrv) available. This is the default virtual DOS drive that is located in each user's home directory.
You use the DOS Drive view of the Device Definition window to create new definitions. For instructions for completing this task, use the Help button on that window.
You can create two types of virtual volumes: One type is for use by all users where the actual volume is shared; the other type is for use by individual users, where each user can have his or her own copy of the defined volume.
Shared volumes are created when you specify the file name using the full Linux path name. In this case, the actual file should be created at device definition time. Personal volumes are created when you specify the file name relative to the user's home directory. Each user creates actual files for personal volumes at the time of attachment.
Once the new virtual volume has been defined, you can attach it to a drive letter using the Personal Win4Lin Session Configuration option of Win4Lin Setup utility.
Default protection of DOS drives
The Linux file system protection mechanisms apply in only a
limited way to DOS drives.
Because DOS
drives are not Linux file systems, access to
individual DOS files in these drives is not
governed by Linux system user or group ownership
or by Linux system read, write, or execute permissions.
However, a DOS drive as a whole is accessed as a Linux file or device and can be protected like any other Linux file or device.
Here are the considerations that affect access to and administration of DOS drives:
Virtual DOS drives created in public directories have the same permissions
as physical DOS drives, i.e., all users have read and write permissions.
However, by default, only the owner can access personal virtual DOS drives created in
a user's home directory.
The user can relax these permissions
at the time the virtual drive is created.
Changing the protection of DOS drives
If you need to restrict access to a DOS drive, you can use
one or all of the following methods:
When a DOS drive is attached to a DOS or Windows session, Win4Lin does not immediately claim the specified device, but waits until DOS or Windows actually attempts to read or write to the device. Meanwhile, the requested device may become unavailable if another session gets control of it.
To avoid this problem, you can request that the device be attached to DOS and Windows sessions immediately and exclusively. Exclusive access to the specified device means that no other session can attach it at the same time.
Specifying read-only access prevents DOS and Windows sessions from making any changes to the DOS drive.
Using the DOS attrib command to make a DOS file read-only can protect individual files on a DOS volume. The protection offered by the DOS attrib command is limited, however, because anyone who can access a DOS file can also use this command to make the file writeable.
To make a DOS file read-only, use the attrib
command to assign the read-only (R) attribute as follows:
attrib +r
filename
When the read-only attribute is assigned, the file cannot be
deleted or changed.
To make the file writable again, type:
attrib -r
filename
Advanced Topic:
--Limit DOS volume access to a group
If for some reason you only want limit access to only some users,
then you can use the Linux permissions to restrict access
to a certain group, as you can do for any other file on the filesystem.
You do this with the Linux chgrp command to change the group
and the Linux chown command to change the ownership so
that only the owner and group have read and write access.
Custom view --
In addition to the standard hardware resources, Win4Lin
allows DOS and Windows to use certain classes of "custom" hardware devices.
These are devices for which attachment is provided by specifying
the I/O ports, interrupts and other related hardware parameters
so the device can be "directly attached" to a Win4Lin session.
Custom device administration
All of the "custom" device definitions show up as selections for attachment to your DOS or Windows session in the Personal Win4Lin Session Configuration window Devices view in the Other Devices section. In this "Other Devices" selection list, device definition that have the "Usable by" setting set to "Root" instead of "All", the selections have "(unavail)" appended as a reminder that the definition is not currently available for general use.
Limitations of direct attachment
Many factors can prevent a directly attached device from
working under Win4Lin. Some reasons
certain devices may fail are:
All the direct attach device tokens are by default set this way. The system administrator (i.e. the "root" user) has to go in and configure the needed device definition to allow it to be used by normal users. This is done with the Win4Lin Setup graphical utility (the command winsetup starts it up.) Navigate to "System Wide Administration" -> "View/Create/Modify Device Definitions" -> "Custom". On the left side, choose the desired "Token Name" from the popup list, and set the "Usable by" setting to "All". This makes that device attachable by all users.
To work around the problem of Windows not knowing the port exists, follow these steps:
There are several custom device definitions that are predefined when you install Win4Lin. These are for the parallel ports and the game port. These are defined regardless of whether those devices actually exist. By default the definitions have the "Usable by" setting set to "Root", so if you want a normal user to be able to use the device you must change that setting to "All". If one or more of these devices do not exist or you never want a normal user to access the device directly then you should remove the device definition, so the user will not have to see in the list the devices that cannot be used.
The two standard parallel ports are some of the custom devices that are predefined by Win4Lin. A parallel port can be in several modes: standard, ECP and EPP. These modes are typically set in your computer system's BIOS setup utility. Win4Lin supplies two device definitions for each parallel port mode for a total of four definitions.
Note that choosing to use one of the parallel port definitions for attachment in a DOS or Windows session does NOT change the mode the parallel port. (Changing the mode has to be done in the BIOS setup of your computer before the operating system boots up.) So when directly attaching a parallel port you should use the definition that matches the mode of the parallel port.
The game port is one of the custom devices that is predefined by Win4Lin. The definition description is "Game/joystick port" (token name "game").
Defining a direct attach custom device
To be able to attach a custom device to a DOS or Windows configuration, you must first create a device definition for it. This is done in the Custom view of the Device Definition window of the System-Wide Setup part of the Win4Lin Setup utility.
You have to specify various hardware characteristics of the device you are defining, so you should have that information ready. The parameters you can specify include:
The address is given in hexadecimal notation, and is typically in the range 0 - 7ff (hex). If this device must use an address range that another device is using, you can remap the address to a virtual address. You cannot choose a virtual address that another device is already using as a physical or virtual address at the same time as this device.
You cannot choose an IRQ that another device will be using at the same time. Consult the manufacturer's documentation for the value to use. If this device must use a physical IRQ that has been assigned to another device, you can remap the IRQ to a virtual IRQ value.
Win4Lin uses the following IRQ numbers:
Valid DMA values are 0 through 7. If this device must use a DMA channel that another device is using, you can remap the DMA channel to a virtual DMA channel.
Win4Lin uses DMA channel 1 for the floppy controller.
For a Memory Mapped I/O device, the range must start on a 4K boundary and be a multiple of 4K. The address is given in hexadecimal notation, and is typically in the range c0000 - effff (hex). If this device must use an address range that another device is using, you can remap the address to a virtual address. You cannot choose a virtual address that another device is already using as a physical or virtual address at the same time as this device.
The preceding part of this chapter covered the device setup you do using the Device Definition part of the Win4Lin Setup GUI utility. There are some administration tasks that cannot be done via this part this GUI. Of interest here are:
Floppy drives
Diskette drives A and B are available to DOS and Windows sessions
as long as they are not otherwise in use.
Win4Lin automatically
assigns the floppy drives on a first-come-first-served
basis to any DOS or Windows session that attempts to
access them whenever they have been unused for several seconds.
On some systems the Linux device permissions might not allow access to the floppy. In this case you must change the access mode using the chmod command to make it readable and writeable. Typically the Linux device names for the first floppy drive is "/dev/fd0" and the second one is "/dev/fd1". If the floppy device names are different from these you will have to configure Win4Lin with the names of the actual devices names. This is via the by putting the settings ADRIVE_AUTOSENSING and BDRIVE_AUTOSENSING in the file /etc/default/merge. For example if the device names for floppy A and B are /dev/flopA and /dev/flopB you will put the following two lines in the file /etc/default/merge:
ADRIVE_AUTOSENSING=/dev/flopA BDRIVE_AUTOSENSING=/dev/flopBYou can also set these in your Linux environment. The settings in your Linux environment override any settings in /etc/default/merge".
On some system that do not have an A and/or B floppy drives (or have floppy drives that can be detached, such as in some laptops), the device names exist but if accessed a bug in the Linux floppy driver will hang or cause large delays to the program that tried the access a floppy drive that is not there. If this is a problem then you can set one or both of ADRIVE_AUTOSENSING and BDRIVE_AUTOSENSING to "/opt/win4lin/diskimages/f.dsk,r". This causes the floppy access to be directed to a empty, read-only virtual floppy drive, instead of to the Linux device.
The virtual mouse
Any mouse that is properly installed and accessible to the
Linux system is also accessible to DOS and Windows sessions.
(If you are running a DOS application in a Win4Lin window
you have to "focus" the mouse to make it usable in the window.
See
``Controlling the
Win4Lin window'' in Chapter 1.)
DOS and Windows sessions always view the mouse as a Microsoft bus mouse. A device driver entry in the system-wide Win4Lin config.sys file supports DOS communication with a mouse. Do not modify this file or a personal config.sys file to specify another mouse driver. In particular, ensure that DOS applications do not modify any config.sys files to specify another mouse driver when you install them.
By default, the mouse uses interrupt (IRQ) 5, which works for almost all applications. If you discover that your mouse does not work, check the following:
winconfig dos set mouse=mouse
n
winconfig win set mouse=mouse
n
Here, n is the interrupt number. (Valid values are 2, 3, 4, or 5; the default is 5.)
About DOS images
The DOS image is a file that reflects the configuration of your
virtual PC environment.
It is a
snapshot of DOS memory that is taken after DOS has been booted,
loaded into memory, and started.
This image includes information DOS needs about the system configuration, which is derived from the hardware installed on the system and the contents of special configuration files at the time the image is made. It allows quick start-up of a DOS program from the Linux environment.
The default DOS images (for monochrome, CGA, and VGA
display modes) are contained in the following files:
/var/win4lin/image/std/mono/*.img
/var/win4lin/image/std/cga/*.img
/var/win4lin/image/std/vga/*.img
(Hercules display mode uses the same files as monochrome mode.)
Win4Lin users use these DOS image files whenever they run a DOS or Windows session.
These standard DOS images are sufficient for most Win4Lin users in most situations. However, you may need to make new DOS images if you want to:
Typically, when new images are required, you create a new DOS image for all of the display modes. The new default images are available automatically to all users.
To create new DOS images, you have to be logged in as root since the new images are used for all DOS and Windows sessions on your system.
To make new DOS images, you use the Win4Lin Setup GUI and choose System-Wide Win4Lin Administration from the list of configuration categories. To make new DOS images, click on the Create DOS images button.
mkimg
command
you can run from a Linux prompt that
does the same thing as the "Create DOS images" button.
Each directory has a file called config.sys. This config.sys file is used in the DOS session from which the DOS image is created, so all configuration parameters specified in it are automatically included in each DOS or Windows session started after the new image is created.
If you want to change the values of certain config.sys commands or add device drivers to your DOS image, log in as root, edit these config.sys files, and create new DOS images following the procedures in ``Steps to making DOS images''.
The following sections describe specific changes you can make to
config.sys files.
Changing special config.sys commands
Win4Lin allows you to use nearly all config.sys
commands as you would on a conventional DOS
computer.
Commands in the system-wide config.sys file affect all users when they start a DOS process. Commands in each user's home directory config.sys file affect only that user's DOS and Windows sessions. To examine or modify these config.sys files, you can use the Personal Win4Lin Session Configuration option of the Win4Lin Setup utility.
However, certain config.sys commands cannot be interpreted unless they are incorporated into the DOS image you are using. These commands include:
The BUFFERS
value is effective only when you use
an actual DOS file system.
It is not used when you
access the shared Linux file system.
The FCBS command is effective only when you use an actual DOS file system. It is not used on any portion of the shared Linux file system.
Do not edit the image configuration file /var/win4lin/image/config.mki. The factory default images are made on the basis of the entries in this file. Altering any of its lines is likely to result in unexpected and undesirable Win4Lin behavior.