[comp.os.os2] Extended Attribute questions

dbaum@camilla.East.Sun.COM (Derek Baum - Sun PC Distributed Systems) (04/06/90)

In article <PREECE.90Apr4171214@etude.urbana.mcd.mot.com> preece@urbana.mcd.mot.com (Scott E. Preece) writes:
>
>1. Which standard commands and utilities know about and preserve extended
>attributes?
All utilities supplied with OS|2 1.2 seem to preserve EAs, most
importantly: COPY and XCOPY as well as the File Manager.
If you need to copy a file to a system that does NOT preserve EAs,
you can use EAUTIL to split or combine the EAs into a visible file.

>2. The API seems to only allow you to pull out a list of specified
>attributes; is there a way of retrieving the whole list, without
>specifying the names in advance?  If not, how would you duplicate a
>file, preserving its attributes, without knowing in advance what
>attributes it had?
The family API function DosEnumAttribute enumerates all extended attributes
for a specified file, however the DosCopy API provides a simpler method
of duplicating a file (or sub-tree) and preserves extended attributes.
Derek Baum consulting at:
Sun Microsystems    Internet: dbaum@East.Sun.COM
(508)671-0456       UUCP: ...!sun!suneast!dbaum

alistair@microsoft.UUCP (Alistair BANKS) (04/10/90)

| 1. Which standard commands and utilities know about and preserve extended
| attributes?

There was a new API added to 1.2 called DosCopy which will copy whole
files and their attributes to a target. In fact, this API will copy whole
subdirectories as well.

USHORT DosCopy(pszSrc, pszDest, usOpt, ulReserved);
PSZ pszSrc;          /* pointer to name of source file */
PSZ pszDest;         /* pointer to name of target file */
USHORT usOpt;        /* options                        */
ULONG ulReserved;    /* must be zero                   */

The "standard commands & utilties" in os/2 1.2 have been re-coded to preserve
or recognise extended attributes including xcopy, copy etc.

The PM File Manager allows you to browse certain Extended Attributes (EAs)
such as the file type ".TYPE", .SUBJECT, .ICON etc in the File.Properties
menu.

| 2. The API seems to only allow you to pull out a list of specified
| attributes; is there a way of retrieving the whole list, without
| specifying the names in advance?  If not, how would you duplicate a
| file, preserving its attributes, without knowing in advance what
| attributes it had?

The EA retrieval APIs are specified by name (DosQPathInfo, DosFindFirst2),
but you can get the names of EAs attached to a file using:

USHORT DosEnumAttribute(usRefType, pvFile, ulEntry, pvBuf, cbBuf, pulCount,
    ulInfoLevel, ulReserved);

The DosEnumAttribute function enumerates extended attributes for a specified
file or subdirectory.

Also: I would point out that EAs are available in _all_ OS/2 file systems,
including HPFS _AND_ FAT and are fully supported by LanManager 2.0. This 
is very often misunderstood and/or mis-quoted.

On a FAT file system a file's EAs are pointed to in its directory entry
using some of the her-to reserved bits, and the data is owned and stored 
in a hidden system read-only file in the root called "EA DATA. SF" - it 
is meant to be very hard to delete since it is so important, but it is 
fully downward compatible with any version of DOS or chkdsk. Please dont 
remove or backup this file seperately. The OS/2 EA APIs give full 
supportable access to EAs on all file systems.

"In other words, EAs are fully supported and accesible in OS/2 1.2"

Alistair Banks
OS/2 Group
Microsoft

kevinro@microsoft.UUCP (Kevin ROSS) (04/11/90)

In article <54014@microsoft.UUCP> alistair@microsoft.UUCP (Alistair BANKS) writes:
|| 2. The API seems to only allow you to pull out a list of specified
|| attributes; is there a way of retrieving the whole list, without
|| specifying the names in advance?  If not, how would you duplicate a
|| file, preserving its attributes, without knowing in advance what
|| attributes it had?
|
|The EA retrieval APIs are specified by name (DosQPathInfo, DosFindFirst2),
|but you can get the names of EAs attached to a file using:
|
|USHORT DosEnumAttribute(usRefType, pvFile, ulEntry, pvBuf, cbBuf, pulCount,
|    ulInfoLevel, ulReserved);
|
|The DosEnumAttribute function enumerates extended attributes for a specified
|file or subdirectory.

Once you read the spec for DosEnumAttribute,n you may be wondering why
you have to call DosEnumAttribute, instead of a call that returns all
extended attributes.  The reason for this is that a file could have more
than 64k worth of extended attribute information, which would not fit
into a segment.  Therefore, it may not be possible to return all
attributes in one system call. Alot of people miss that, and claim that
EnumAttribute it is a poor way of getting to the EA's, when in fact it
is a good way of insuring you get everything.