Re: How to get File System info



On Thu, 28 Jul 2005 21:48:43 UTC, Peter Flass <Peter_Flass@xxxxxxxxx>
top posted:

> Bob Eager wrote:
> > On Wed, 27 Jul 2005 21:00:36 UTC, "Keith" <ktmos2NOSPAM@xxxxxxxxxxxx>
> > wrote:
> >>does anybody have a simple method of obtaining the file system type , i.e
> >>FAT, HPFS, CDFS, JFS ...
> >>in C.
> >>
> >>A code snippet would be very helpful.

> > I'll email it to you.

> Post would be nice. If it's too long, I'd appreciate an email also, if
> it isn't too much trouble. Thanks.

It's not as long as I thought...so here it is. The bit about strcmp and
constants at the end is just how I wanted it for a particular program,
and can be excised.

----------------------------------------------------------
/*
* Function to determine the type of file system on the drive specified
* in 'path'.
*
* Returns FS_CDFS, FS_CDWFS, FS_NFS, FS_FAT or FS_HPFS;
* any error causes the result to default to FS_FAT.
*
*/

static enum FS_T fstype(PUCHAR path)
{ UCHAR fsqbuf[FSQBUFSIZE];
PUCHAR p;
ULONG fsqbuflen = FSQBUFSIZE;
UCHAR drv[3];

if(path[1] != ':') { /* No drive in path - use default */
curdrv(drv);
} else {
drv[0] = path[0];
drv[1] = path[1];
drv[2] = '\0';
}

if(DosQueryFSAttach(
drv,
0,
FSAIL_QUERYNAME,
(PFSQBUFFER2) fsqbuf,
&fsqbuflen) != 0)
return(FS_FAT);

/* Set 'p' to point to the file system name */

p = fsqbuf + sizeof(USHORT); /* Point past device type */
p += (USHORT) *p + 3*sizeof(USHORT) + 1;
/* Point past drive name and FS name */
/* and FSDA length */

if(strcmp(p, "CDFS") == 0) return(FS_CDFS);
if(strcmp(p, "CDWFS") == 0) return(FS_CDWFS);
if(strcmp(p, "HPFS") == 0) return(FS_HPFS);
if(strcmp(p, "NFS") == 0) return(FS_NFS);

return(FS_FAT);
}

----------------------------------------------------------

.



Relevant Pages

  • Re: The danger of dishonest disk drives (WAS:Re: Need to remove a ghost file, but cant because it do
    ... E.g. if the file system is atomic transaction oriented, ... admin was able to effect a shutdown where disks synced (not just push ... jfs drive wasn't able to be mounted. ... I have formatted a partition with JFS on my hard-disk. ...
    (Debian-User)
  • Re: JFS vs EXT3 vs XFS vs ReiserFS
    ... So, after 3 installs with EXT3, I decided to try something else. ... notice the installer offers JFS, XFS, and ReiserFS, so I picked JFS for ... the most stable and easy to recover file system (and I have stress ... and XFS don't have this problem, and were much faster for hosting large ...
    (Ubuntu)
  • Re: JFS / Unsupported file systems
    ... |> Alex Samad wrote: ... | most of the followup googling I did on jfs seems to give the impression ... every file system has its good points and its flaws. ...
    (Debian-User)
  • Re: [SLE] JFS and Suse 10.0
    ... Does anyone have any opinions on JFS (Suse 10) for the file system that will ... I am experimenting with various file systems for performance testing. ...
    (SuSE)
  • Re: AIX - 452 Error - need help
    ... Then I tried copying the Oracle installer and it was successful. ... Now I tried gunzipping the Oracle installer on AIX box and it therowed ... The problem here is the file system on AIX is JFS (Journalled File ...
    (comp.unix.aix)

Loading