The Graham Utilities for OS/2 - Version 2


[Warpspeed]

[Table of Contents] [Index] [Previous] [Next]


Appendix A - Extended Attributes

Extended Attributes - Overview

Extended Attributes are a method which OS/2 uses to store information about a file without modifying the contents of the file. The information is not stored within the file itself. This applies equally to directories.

The file system itself stores this information. On a FAT partition the data is stored in a file called "EA DATA . SF". This is normally a hidden, system file in the root directory. A HPFS partition stores the data in a different manner. The HPFS file system has separate structures within the file system which allow for the storage of extended attribute data to be separate and distinct from the file data. To a program there is no difference in how this data is manipulated, and the data itself is identical.

The DIR command on a FAT partition will report something similar to:

The volume label in drive C is SYSTEM DISK.
The Volume Serial Number is 3A1F:1BEB
Directory of C:\

IO SYS 33430 9-04-91 5:00 MSDOS SYS 37394 9-04-91 5:00 OS2 <DIR> 28-07-93 20:45 EA DATA SF 940032 28-07-93 20:47 WP ROOT SF 224 3-01-94 20:09 STARTUP CMD 118 3-01-94 19:24

With the DIR command on any other type of partition (HPFS, LAN, CD-ROM etc) you will notice that you get an extra column of numbers. This extra column is the size of the Extended Attributes associated with that file or directory.
The volume label in drive E is DEVELOPMENT.
The Volume Serial Number is A608:DC15
Directory of E:\

21-12-93 20:38 DIR 0 . 21-12-93 20:38 DIR 0 .. 10-01-93 0:48 37754 0 ALLFILES.LST 23-12-92 21:15 234402 0 OLVR11G.LZH 6-01-94 0:00 DIR 10858 OS2UTILS

It can be seen from the above that the directory OS2UTILS has 10,858 bytes of extended attributes associated with it.

The size of extended attributes can be displayed on FAT partitions by using the DIR /N command.

Extended Attributes - Details

Each extended attribute has two parts - a name and data. The name is just a string and the data can be anything. There is a limit of 64K of extended attribute data per file. There is no limit to the number of extended attributes per file - so long as the 64K restriction is observed.

There are some predefined types of extended attributes, although applications may define and use their own. The predefined attributes are listed below:

EAT_BINARY
The data is binary. The first word is the length.
EAT_ASCII
The data is ASCII text. The first word is the length.
EAT_BITMAP
The data is a BITMAP. The first word is the length.
EAT_METAFILE
The data is a METAFILE. The first word is the length.
EAT_ICON
The data is an ICON. The first word is the length.
EAT_EA
The data is an ASCII name of associated data. The first word is the length.
EAT_MVMT
The data consists of two or more consecutive extended attribute values. Each value has an explicitly specified type.
EAT_MVST
The data consists of two or more consecutive extended attribute values. Each value has the same type.
EAT_ASN1
ASN.1 field data.

There are also some standard extended attribute names which are in common use. Although they all use a .Name format, this is not a requirement for extended attributes.

.TYPE
Specifies the type of the file. Some examples are:
Plain Text
OS/2 Command File
DOS Command File
Executable
Metafile
Bitmap
Icon
and so on
.COMMENTS
This field is intended to be a short note or reminder to the user as to what the file is about.
.ICON
This field is used by the File or Desktop Manager to display the icon. The extended attribute data is the icon itself.
.LONGNAME
Some file systems, such as HPFS support file names up to 254 characters long. They may also support abnormal characters, such as spaces. When a file with a long name is copied to a file system which may not support long names (FAT), applications should save the original name in this field. In this way the name is kept in case it is ever copied back to a file system which supports long names.

Extended Attributes - Usage

OS/2 itself, as well as other applications, use extended attributes. For example, OS/2 uses extended attributes to display icons, for example. The extended attribute name is .ICON and the type is EAT_ICON.

In addition, applications such as FI use extended attributes to save the information about a file without modifying the file itself. FI uses the .COMMENTS extended attribute of type EAT_ASCII to save its information.

If the .LONGNAME extended attribute is present, the OS/2 File Manager will use it to display the name of the file.