[comp.binaries.ibm.pc.d] DOS directory attribute question

dbearly@vax1.tcd.ie (10/09/90)

Recent experiments in C programming showed that it is possible to set
the various attribute bits of a DOS directory. I was wondering if 
someone could tell me the (possible) effects and uses of setting these
attributes are ?

	In particular I would like to know about the read-only and
	archive attributes.
-----------------------------------------------------------------------------
dbearly@vax1.tcd.ie
dbearly@unix1.tcd.ie
-----------------------------------------------------------------------------

tcs@router.jhuapl.edu (10/10/90)

In article <6984.2711ef88@vax1.tcd.ie>, dbearly@vax1.tcd.ie writes:
>Recent experiments in C programming showed that it is possible to set
>the various attribute bits of a DOS directory. I was wondering if 
>someone could tell me the (possible) effects and uses of setting these
>attributes are ?
>
>	In particular I would like to know about the read-only and
>	archive attributes.
>-----------------------------------------------------------------------------
>dbearly@vax1.tcd.ie
>dbearly@unix1.tcd.ie
>-----------------------------------------------------------------------------

Archive    - On means the file has been changed since the last backup;
             Off means the file has not been modified. 

             Archive is usually used with backup software. When you make a 
             backup, the software turns the Archive bit off. Then when you 
             wish to make an incremental backup (backing up only the files 
             that have been changed from the last backup) it will backup 
             only the files with the Archive bit on.

Read-Only  - On prevents a file from being written to or deleted.
             Off allows the file to be modified.

             Read-Only is used when you wish to protect a file from being 
             removed. It is also used in Multi-User applications. If it 
             isn't set On, someone else is using it and you try to execute
             it, you will get a "Sharing Violation Error [ARI]". Note: 
             This doesn't prevent the file from being Renamed.

Hidden     - On hides this file from Command.Com commands.

             Hidden prevents the standard Command.Com commands from 
             executing on it. Dir, Copy, Del, Rename etc. You can still 
             execute the file. A Hidden data file will not be found in most
             cases.

System     - On tells DOS to consider this a file related to hardware.

             System is the flag used by software to indicate a file that is 
             related to the hardware. in 99% of the cases, IBMBIOS.Sys and 
             IBMCOM.Sys (and other related system files) are the only files
             that have the System flag set although I've seen my tape 
             backup software driver with a System flag set.

Directory  - On indicates this is a directory and not a file.

             While you generally will not see Directory and Volume as a 
             flag in a directory type of program, they are flags. If you 
             use Norton Utilities (NU) you will see these flags on the 
             entry. If you turn off the Directory flag, you have a 
             (generally) 2048 byte file and all files in that directory are
             lost clusters. The next ChkDsk /f will return these files. 
             A directory is just a file that contains information on the 
             files contained in it. If you turn it off and view the file, 
             you will see all the file names in it. 

Volume     - On makes this file the volume label.

             The Volume label is a 0 byte file with the Volume flag set. If
             you look at the directory structure for the root, you will see
             a file (assuming you have a volume label on your drive). There 
             can only be one Volume label and it has to be in the root 
             directory (I've never tried to set two to see what happens).


Disclaimer: This is the information that I have. I didn't write DOS but I 
have lots of experience in using it. I consider myself an expert, (IMHO) 
but you may not. Your milage may vary. Not valid in all states. Allow for 
shrinkage.

Carl Schelin                       | "He who hesitates is not only lost,
tcs@router.jhuapl.edu              |  but miles from the nearest exit."

mvolo@uncecs.edu (Michael R. Volow) (10/10/90)

I don't know C, but other programs such as the MSDOS version of CHMOD,
and a small shareware program FILEMGR.COM or the hex editor in PCTOOLs,
all can change the directory attributes. Unfortunately, you can hide
a directory from DOS, but you can't make it read-only or execute only
or responsive to various security levels. That is, even when one changes
the attributes of a directory to read-only, DOS does not recognize it
as such. DRDOS 5.0 or security programs such as PC-Vault + or HandsOff
can do this.
-- 
Michael Volow, Psychiatry, Durham VA Med Center, Durham NC 27712
919 286 0411 Ext 6933               mvolo@ecsvax.edu

browns@iccgcc.decnet.ab.com (Stan Brown, Oak Road Systems) (10/11/90)

In article <6984.2711ef88@vax1.tcd.ie>, dbearly@vax1.tcd.ie writes:
> Recent experiments in C programming showed that it is possible to set
> the various attribute bits of a DOS directory. I was wondering if 
> someone could tell me the (possible) effects and uses of setting these
> attributes are ?
> 
> 	In particular I would like to know about the read-only and
> 	archive attributes.

The "archive" bit means that the file was changed in some way since
the last backup.  One of the XCOPY options reads and sets this bit,
as do FASTBACK and a number of other file backup utilities.

The "read-only" bit means that the file is, er, read only.  DEL/ERASE
will not delete a file that is read only.

The 2 paragraphs above are not 100% reliable, as some programs bypass
the DOS calls that would set or interrogate these bits.

The above opinions are not attributable to any other person or company.
                                     email: browns@iccgcc.decnet.ab.com
Stan Brown, Oak Road Systems, Cleveland, Ohio, U.S.A.   +1 216 371 0043