Quick viewing(Text Mode)

OS/2'S Extended Attributes

OS/2'S Extended Attributes

OS/2 INSIGHTS OS/2's Extended Attributes

BY MICHAEL NORT O N

s many of you can attest, from a tech- a l l ow operating systems wh i ch do not sup- h ex string para m e t e r, c o n c at e n ated on the nician's pers p e c t ive, i n fo rm at i o n p o rt EAs to actually operate on the EA dat a ; p revious line into the "subject" va ri abl e, t o Aabout a file is often more important the sep a rate "hold" file containing the function pro p e rly. than the contents of the file.The archive extended at t ri butes can be operated on inde- attribute, for example, allows my backup soft- p e n d e n t ly of the ori ginal file by any pro c e s s , THE STRUCTURE OF EAS ware to copy only those files which have been then rejoined to the ori ginal fi l e. Th e re fo re, The hex string represents the EA type. modified since the last backup. Comparing the .SUBJECT EA, for ex a m p l e, could be There are nine standard EA types which are file dates and sizes is a routine activity. In fact, a l t e red by a DOS utility to maintain fi l e identified to the by a word there isn't a technician who hasn't developed comments and full compatibility with OS/2 (two-byte) identifier. As demonstrated in the an intensely personal and zealously enforced once the EA had been re j o i n e d. table containing the C DEFINE label, which is naming convention for files. Nevertheless, the This approach, to my knowledge, is not used to refer to the types (Figure 2), the EA standard file stamps and attributes established used, probably due to the inherent cumber- types may be grouped into two categories: under DOS aren't very flexible and provide someness of the procedure, and EAUTIL is Single-Valued, which contain only one data only primitive information. OS/2 provides a primarily used to backup EAs, an awkward item per EA, and Multi-Valued, which may facility for attaching more varied information enough procedure, since the EAUTIL com- contain multiple items. to a file or direc t o ry : extended att ri bu t e s , or EAs. mand does not accept generic or wildcard A programmer may define his own EA type U n fo rt u n at e ly, the cap abilities that EAs characters in its file specification parameters. by simply specifying a value between 0x0000 provide often remain unexploited in many Thus, EAUTIL is often used as a call from a and 0x7FFF for the hex identifier.Values shops, and the only exposure many users have REXX program for mass file operations, as in above this range are reserved. to EAs are when a problem occurs: the dread- the REXX example shown in Figure 1 which For all Single-Valued EAs, the fi rst wo rd ed "cross-linked extended attributes" or "cor- will back up all EAs on a drive. fo l l owing the hex type identifier indicat e s rupted extended attributes" system error mes- the length of the data wh i ch fo l l ows. Fo r s ages. Th u s , EAs are viewed somewh at M u l t i - Valued EAs, the fi rst wo rd fo l l ow i n g ambivalently by many users. The truth is, OS/2 the hex type identifier indicates the code The truth is, OS/2 (or, more accurately, the p age to be used. The is fo l l owe d OS/2 Workplace Shell) could not run without (or, more accurately, by a wo rd specifying the number of entri e s EAs. EAs are the "glue" that holds the the OS/2 Workplace Shell) in the EA. Workplace Shell together, since they contain For Multi-Va l u e d, S i n g l e - Typed EAs, the information the system needs to associate could not run without EAs. the next wo rd indicates the type of entri e s files with programs, icons with objects, long EAs are the “glue” that contained in the EA. Although this sounds file names with files copied from HPFS to s l i g h t ly confusing, it is actually quite FAT, and a variety of other system functions. holds the Workplace s i m p l e : The fi rst type specifi c ation denotes Anyone who has ever made the mistake of Shell together. t h at the EA contains multiple va l u e s , using a DOS defragger which does not sup- or entries; the second type specifi c at i o n port extended attributes on their OS/2 boot i n d i c ates the type of those entries. This sec- volume knows how critical EAs are to the REXX ond type specifi c ation is fo l l owed by a seri e s operation of OS/2. REXX provides two EA manipulation of "re c o rd s " , e a ch consisting of two by t e s A m a z i n g ly, the only nat ive OS/2 utility functions as part of its standard REXXUTIL i n d i c ating the length of the data fo l l owed by for managing EAs is EAUTIL.EXE. EAU- utility functions. SysGetEA will an the data itself. TIL allows you to split EAs from a file or EA for a specified fi l e. SysPutEA will Since Multi-Typed EAs contain, as their d i re c t o ry into a sep a rate file wh i ch may sub- w rite an EA to a specified fi l e. The lat t e r name implies, various EA types, each value or s e q u e n t ly be rejoined to the ori ginal file or is utilized in the REXX example in Fi g u re 1. entry must define its type; thus, the "record" m e rged to a diffe rent fi l e. The command wa s The REXX example writes the file specifi - includes two bytes indicating the type, fol- o ri gi n a l ly designed to allow operating sys- c ation to the new "SOURCE" EA of the lowed by the length and data as in the Single- tems (such as DOS) wh i ch do not re c og n i ze b a ckup file; this EA may be re t ri eved and Typed Multi-Valued EA. extended at t ri butes to operate on files fro m used by a REXX program to re - at t a ch the Thus, the SOURCE EA being written in the an OS/2 system in addition to providing sup- EA to the correct fi l e, b a s i c a l ly reve rsing the sample REXX program is an EAT_ASCII p o rt for file tra n s fer operat i o n s , s u ch as p ro c e d u re. The example also demonstrat e s type extended attribute (FFFD). The next two t ra n s fe rring a file via a modem, wh i ch wo u l d t h at you must know something about the c o n c at e n ation elements in the stri n g s t rip a file of its extended at t ri butes. Th e s t ru c t u re of EAs to manipulate them with (d2c(length(files.i)) and '00'x) form the length, d o c u m e n t ation also suggests another use: t o R E X X : The SysPutEA function re q u i res a and the EA data follows.

TECHNICAL SUPPORT JULY 1996 Figure 1: REXX Example Figure 3: GammaTech Sector Editor

***************************************************************************/ * * EA_BACK.CMD Backup all EAs on a drive, and stores them in the backup using the file- * * name and the .EA extension. Multiple instances of a are handled by adding a numeral * * to the extension (e.g., .EA1). The file to which the EA belongs and its path are stored in the * * user-defined SOURCE EA assigned to each .EA file. * * * ***************************************************************************/

/* LOAD REXX UTILITIES */ call rxfuncadd 'sysloadfuncs','rexxutil','sysloadfuncs' call sysloadfuncs

/* CONSTANTS (DEFINE DRIVE TO BE BACKED UP AND BACKUP PATH HERE) */ Drive = 'S:' spec = drive || '\*.*' ea_backup_path = 'R:' || '\ea_back\'

/* READ ALL FILES IN ALL SUBDIRECTORIES */ rc=SysFileTree(spec,'files','so') you will need such a utility to validate EA data. Studying EAs in an /* MAIN LOOP: PROCESS EACH FILE AND */ editor also reveals much about the structure and use of EAs by the do i = 1 to files.0 filespec = '"' || files.i || '"' /* need quotes for HPFS */ operating system. Additionally, armed with a little knowledge and do j = length(files.i) to 1 by -1 /* strip filename from path */ understanding about the structure of EAs you will be able, in many char = substr(files.i,j,1) cases, to use an editor to repair the problem. if char = '\' then do hold_ea = substr(files.i,j + 1) leave j EA STORAGE end end /* j */ Two of the more common problems with extended attributes, how- do j = length(hold_ea) to 1 by -1 /* strip extension */ ever, have nothing to do with the EA itself, but rather the . char = substr(hold_ea,j,1) HPFS rarely has problems with EAs because they are stored in a file's if char = '.' then do hold_ea = left(hold_ea,j-1) F-node, or header. Most EA problems are on FAT volumes. The FAT leave j file system uses a pointer in the (highlighted in end Figure 3) to an entry in the EA DATA. SF file, which is not really a file end /* j */ hold_ea_filespec = ea_backup_path || hold_ea || '.EA' /* construct filespec */ but rather a logical construct used to account for extended attributes in rc = stream(hold_ea_filespec,'C','QUERY EXISTS') /* check if file exists */ the . Extended attributes are assigned sequential if rc \= '' then do k = 1 to 9 /* if file exists, construct extension */ fs = hold_ea_filespec || k pointers at creation. If two files reference the same pointer, cross- rc = stream(fs,'C','QUERY EXISTS') /* check if that file exists */ linked EAs — and trouble — result. Even CHKDSK behaves errati- if rc = '' then do /* file doesn't exist, use name */ cally in this case. During research for this month's column, CHKDSK hold_ea_filespec = fs leave k apparently decided the logical course of action was to simply delete the end cross-linked files! On other occasions, it simply ignored the pointer. end /* k */ The standard procedure for cross-linked EAs is to copy the affected hold_ea = '"' || hold_ea_filespec || '"' /* add quotes for HPFS filenames */ rc = stream(hold_ea_filespec,'C','QUERY EXISTS') /* double check for dupe */ files to another volume, delete the originals, then recopy the EAs back if rc = '' then do /* OK, process... */ to the initial volume. Unfortunately, this is a kludge. The first file 'EAUTIL' filespec hold_ea '/p /s' /* copy EA */ source_ea = 'FFFD'x || d2c(length(files.i)) || '00'x || files.i /* construct EA string */ copied will take the EA with it. Without an editor (and often times even rc = SysPutEA(hold_ea_filespec,"SOURCE",source_ea) /* original file to EA */ with an editor!), it is impossible to determine to which file the shared end EA actually belongs. If there are two files you've got a fifty-fifty shot. end /* i */ With a little patience and a sector editor you can often resolve this problem by correcting the entry in the directory structure. Figure 2: Table Values The other common error is also often a result of the inadequacies of the FAT file system in handling EAs. The "Corrupted Extended Single-Valued: Attributes" error message is most often caused by an allocation error in EAT_BINARY FFFE Binary data the EA DATA. SF file. Again, CHKDSK cannot be depended on to EAT_ASCII FFFD Text resolve this situation. The only sound solution is to restore from a reli- EAT_BITMAP FFFB Bitmap able backup — and next time, use HPFS. ts EAT_METAFILE FFFA Metafile EAT_ICON FFF9 Icon EAT_EA FFFE Another associated EA Michael Norton is the workstation division manager Multi-Valued: at SofTouch Systems, Oklahoma City, Okla., which provides both mainframe and PC software solutions. EAT_MVMT FFDF Multi-Valued, Multi-Typed EAT_MVST FFDE Multi-Valued, Single Typed He has written mainframe manuals in addition EAT_ASN1 FFDD ASN.1 field data to articles for a number of publications. You can reach him at [email protected].

VIEWING AND EDITING EXTENDED ATTRIBUTES Since EAs contain binary data they may not be viewed or edited with an ordinary text editor. Utilities such as UniMaint, the EA editor in the ©1996 Technical Enterprises, Inc. Reprinted with permission GammaTech Power Pack,or PM Control Center, allow you to view and of Technical Support ma gaz i n e . For subscription inform at i o n , edit extended attributes. If you intend on doing much work with EAs, em a i l [email protected] or call 414-768-8000, Ext. 116.

TECHNICAL SUPPORT JULY 1996