Host Protection Area was introduced in ATA-4 to allow computer vendor to save data that would not be erased when a user formats the hard disk. It is intended manufacturer to stow diagnosis tool and backup image so that they do not need to ship an install CD.
HPA was an area set aside at the end of the disk using SET_MAX_ADDRESS command. The command featured a "volatile" bit which allow the HPA to be effected at the next reboot. This allows user to read/write the HPA in the current session and lock the content after reboot.
HPA is invisible to both BIOS and OS. It is managed by low level ATA commands.
Saturday, June 20, 2009
Disk Password
There are 2 passwords in harddisk - user and master. The master password allows administrator to access the disk if user password is lost.
There are 2 operating modes. In high security mode, both user and master password can unlock the disk. In maximum security mode, the master password can unlock the disk only after the disk has been wiped.
Security is implemented using the ATA SECURITY_UNLOCK command which must be executed before any READ/WRITE ATA command. Some ATA commands are still usable without SECURITY_UNLOCK command and thus the disk may be recognizable by the system.
There are 2 operating modes. In high security mode, both user and master password can unlock the disk. In maximum security mode, the master password can unlock the disk only after the disk has been wiped.
Security is implemented using the ATA SECURITY_UNLOCK command which must be executed before any READ/WRITE ATA command. Some ATA commands are still usable without SECURITY_UNLOCK command and thus the disk may be recognizable by the system.
IDE/ATA
IDE (Integrated Disk Electronics) refers to disk with a logic board built-in, as comparing to older disk. ATA (AT Attachement) refer to the interface of IDE disk. ATA disks requries a controller which is built into the motherboard. ATA cables has a maximum length of 18 inches and uses 40-pins. The cable contains an extra 40-wires which do not connect to the pin to improve insulation.
Early ATA disks were addressed by CHS (Cylinder/Head/Sector). The disparaty between the ATA standard and older BIOS on the number of bits used for CHS has limited the size of IDE disk to 504MB. Newer BIOS translate the CHS address to ATA standard and this extended the addressability to 8.1GB. To overcome the limitation, CHS was replaced by LBA (Logical Block Address) in later ATA standard.
ATA-1 (1994) - support CHS and 28-bit LBA
ATA-3 (1997) - added Self-Monitoring Analysis amd Reporting Technology (SMART) which allows monitoring of several parts of the disks. Another feature was Password Protection.
ATA/ATAPI-4 - ATA Packet Interface for removable media. ATAPI used the same cable and controller but required special drivers. 80-wire cable was introduced. Add HPA (Host Protection Area) for vendor to keep data that would not be erased by formatting the disk.
ATA/ATAPI-6 (2002) - Added 48-bit LBA and removed support for CHS. Add DCO (Disk Configuration Overlay).
ATA/ATAPI-7 - Included serial ATA
Early ATA disks were addressed by CHS (Cylinder/Head/Sector). The disparaty between the ATA standard and older BIOS on the number of bits used for CHS has limited the size of IDE disk to 504MB. Newer BIOS translate the CHS address to ATA standard and this extended the addressability to 8.1GB. To overcome the limitation, CHS was replaced by LBA (Logical Block Address) in later ATA standard.
ATA-1 (1994) - support CHS and 28-bit LBA
ATA-3 (1997) - added Self-Monitoring Analysis amd Reporting Technology (SMART) which allows monitoring of several parts of the disks. Another feature was Password Protection.
ATA/ATAPI-4 - ATA Packet Interface for removable media. ATAPI used the same cable and controller but required special drivers. 80-wire cable was introduced. Add HPA (Host Protection Area) for vendor to keep data that would not be erased by formatting the disk.
ATA/ATAPI-6 (2002) - Added 48-bit LBA and removed support for CHS. Add DCO (Disk Configuration Overlay).
ATA/ATAPI-7 - Included serial ATA
Unicode
Unicode uses 4 bytes. There are 3 ways to store unicode character. UTF-32 uses 4 bytes for each character. UTF-16 stores most frequently used character in 2-byte values and less frequently used in 4-bytes value. UTF-8 uses 1-, 2- or 4-bytes values. UTF-8 and UTF-16 uses more processing comparing to UTG-32.
Sunday, February 22, 2009
ttymon login
Beside getty login, SVR4 also supports another login via ttymon. Typically getty login is used for console and ttymon login is used for terminal. In ttymon login, init fork-exec program sac (sevice access controller). sac fork-exec ttymon when system enters multiuser state. ttymon monitors all terminal ports listed in the configuration file. When user logs in, ttymon fork-exec program login. Note that the parent of login is now ttymon while the parent for getty is init.
getty login
Login in from terminal or modem (remote) connecting via RS232 connection comes from terminal driver in the kernel. Terminal device configuration are defined in /etc/ttys by the administrator. When the system boots, it creates the first process, init (PID=1). init reads /etc/ttys and for each termial devices that allows login, init fork-exec program getty.
getty is run with superuser privilege (UID=0). It open the terminal in RW mode. getty sets file descriptor 0, 1 and 2 to the terminal device driver. It then outputs the login prompt. Once the user enters its userid, getty exec program login to handle the input.
login prompts the user for the password and uses crypt to encrypt the password entered for checking. If the password is invalid, login will exit with code 1 after a few tries. Control passed back to init and it fork-exec the getty again to restart the process. If the password check is successful, login will set up the user environment and changes to the user's ID before it invoke the shell using execl call - ("/bin/sh", "-sh", (char *) 0). The minus sign is a flag to tell all shells that they are being invoked as a login shell. Finally, the login shell reads the start up files (e.g. .profile) before displaying the first prompt for user.
getty is run with superuser privilege (UID=0). It open the terminal in RW mode. getty sets file descriptor 0, 1 and 2 to the terminal device driver. It then outputs the login prompt. Once the user enters its userid, getty exec program login to handle the input.
login prompts the user for the password and uses crypt to encrypt the password entered for checking. If the password is invalid, login will exit with code 1 after a few tries. Control passed back to init and it fork-exec the getty again to restart the process. If the password check is successful, login will set up the user environment and changes to the user's ID before it invoke the shell using execl call - ("/bin/sh", "-sh", (char *) 0). The minus sign is a flag to tell all shells that they are being invoked as a login shell. Finally, the login shell reads the start up files (e.g. .profile) before displaying the first prompt for user.
Sunday, February 15, 2009
Unbuffered I/O and effect of buffer size
Most UNIX I/O can be accomplished by 5 system calls - open, lseek, read, write and close. They are unbuffered I/O calls. Programmer needs to allocate a buffer and pass it as one of the arguments to these I/O functions. If the buffer size picked is small, more I/O read/wrtie calls will have be made to transfer the same amount of data in and out of the program. A small buffer size results in higer CPU utilization (System and User) as well as longer total run time. Using larger buffer size will decrease CPU time. This is an example of trading CPU with memory usage. The CPU improvement will taper off at a certain buffer size beyond which further CPU utilization decrease will not be significant when the number of I/O call has already become quite small.
UNIX standard I/O packages provides a buffered I/O call interface for program. When using these calls, programmer no longer needs to concern with buffer size as it will be taken care by the standard I/O calls.
UNIX standard I/O packages provides a buffered I/O call interface for program. When using these calls, programmer no longer needs to concern with buffer size as it will be taken care by the standard I/O calls.
Subscribe to:
Posts (Atom)