Changeset 70 for trunk/dll/valid.c


Ignore:
Timestamp:
Nov 5, 2003, 2:18:25 AM (22 years ago)
Author:
root
Message:

Add JFS and FAT32 support

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/valid.c

    r48 r70  
    1010
    1111  Revisions     23 Nov 02 SHL - RootName: rework for sanity
    12                 27 Nov 02 SHL - MakeFullName: correct typo
    13 
     12                27 Nov 02 SHL - MakeFullName: correct typo
     13                11 Jun 03 SHL - Add JFS and FAT32 support
    1414
    1515***********************************************************************/
     
    168168
    169169
    170 INT CheckDrive (CHAR Drive, CHAR *FileSystem, ULONG *type) {
    171 
     170INT CheckDrive (CHAR chDrive, CHAR *pszFileSystem, ULONG *pulType)
     171{
    172172  CHAR        Path[3],*Buffer = NULL,*pfsn = NULL,*pfsd = NULL;
    173173  ULONG       Size,Status,action,LengthIn,LengthOut;
     
    176176  PFSQBUFFER2 pfsq;
    177177
    178   if(FileSystem)
    179     *FileSystem = 0;
    180   if(type)
    181     *type = 0;
     178  if (pszFileSystem)
     179    *pszFileSystem = 0;
     180  if (pulType)
     181    *pulType = 0;
    182182
    183183  if(DosAllocMem((PVOID)&Buffer,4096,
    184184                 PAG_COMMIT | OBJ_TILE | PAG_READ | PAG_WRITE)) {
    185185    DosBeep(50,50);
    186     return -1;
    187   }
    188 
    189   Path[0] = Drive;
     186    return -1;                          // Say failed
     187  }
     188
     189  Path[0] = chDrive;
    190190  Path[1] = ':';
    191191  Path[2] = 0;
     
    194194  Status = DosQueryFSAttach(Path, 0, FSAIL_QUERYNAME,
    195195                            (PFSQBUFFER2)Buffer, &Size);
    196   if(Status) {   /* can't get any info at all */
     196  if (Status)
     197  {
     198    /* can't get any info at all */
    197199    DosFreeMem(Buffer);
    198200    DosError(FERR_DISABLEHARDERR);
    199     return -1;
     201    return -1;                          // Say failed
    200202  }
    201203
     
    204206  pfsd = pfsn + pfsq->cbFSDName + 1;
    205207
    206   if(FileSystem) {
    207     strncpy(FileSystem, pfsn, CCHMAXPATH);
    208     FileSystem[CCHMAXPATH - 1] = 0;
    209   }
    210 
    211   if(type && !strcmp(pfsn,CDFS))
    212     (*type) |= (DRIVE_NOTWRITEABLE | DRIVE_CDROM | DRIVE_REMOVABLE);
    213 
    214   if(((PFSQBUFFER2)Buffer)->iType == FSAT_REMOTEDRV) {
    215     if(type)
    216       (*type) |= DRIVE_REMOTE;
    217     if(type && !strcmp(pfsn,CBSIFS)) {
    218       (*type) |= DRIVE_ZIPSTREAM;
    219       (*type) &= (~DRIVE_REMOTE);
    220       (*type) |= DRIVE_NOLONGNAMES;
    221       if(pfsq->cbFSAData) {
    222 
     208  if (pszFileSystem)
     209  {
     210    strncpy(pszFileSystem, pfsn, CCHMAXPATH);
     211    pszFileSystem[CCHMAXPATH - 1] = 0;
     212  }
     213
     214  if (pulType && !strcmp(pfsn,CDFS))
     215    *pulType |= DRIVE_NOTWRITEABLE | DRIVE_CDROM | DRIVE_REMOVABLE;
     216
     217  if (((PFSQBUFFER2)Buffer)->iType == FSAT_REMOTEDRV)
     218  {
     219    if (pulType)
     220      *pulType |= DRIVE_REMOTE;
     221    if (pulType && !strcmp(pfsn,CBSIFS))
     222    {
     223      *pulType |= DRIVE_ZIPSTREAM;
     224      *pulType &= ~DRIVE_REMOTE;
     225      *pulType |= DRIVE_NOLONGNAMES;
     226      if (pfsq->cbFSAData)
     227      {
    223228        ULONG FType;
    224229
    225         if(CheckDrive(*pfsd,NULL,&FType) != -1) {
    226           if(FType & DRIVE_REMOVABLE)
    227             (*type) |= DRIVE_REMOVABLE;
    228           if(!(FType & DRIVE_NOLONGNAMES))
    229             (*type) &= (~DRIVE_NOLONGNAMES);
     230        if (CheckDrive(*pfsd,NULL,&FType) != -1)
     231        {
     232          if (FType & DRIVE_REMOVABLE)
     233            *pulType |= DRIVE_REMOVABLE;
     234          if (~FType & DRIVE_NOLONGNAMES)
     235            *pulType &= ~DRIVE_NOLONGNAMES;
    230236        }
    231237      }
    232238    }
    233     if(type && (!strcmp(pfsn,HPFS) || !strcmp(pfsn,HPFS386)))
    234       (*type) &= (~DRIVE_NOLONGNAMES);
     239    if (pulType &&
     240        (!strcmp(pfsn,HPFS) ||
     241         !strcmp(pfsn,JFS) ||
     242         !strcmp(pfsn,FAT32) ||
     243         !strcmp(pfsn,HPFS386)))
     244    {
     245      *pulType &= ~DRIVE_NOLONGNAMES;
     246    }
    235247    DosFreeMem(Buffer);
    236     return 0;  /* assume remotes are non-removable */
    237   }
    238 
    239   if(strcmp(pfsn,HPFS) && strcmp(pfsn,CDFS) && strcmp(pfsn,HPFS386)) {
    240     if(type)
    241       (*type) |= DRIVE_NOLONGNAMES;
     248    return 0;                           // Say non-removable
     249  }
     250
     251  // Local drive
     252  if (strcmp(pfsn,HPFS) &&
     253      strcmp(pfsn,JFS) &&
     254      strcmp(pfsn,CDFS) &&
     255      strcmp(pfsn,FAT32) &&
     256      strcmp(pfsn,HPFS386))
     257  {
     258    if(pulType)
     259      (*pulType) |= DRIVE_NOLONGNAMES;
    242260  }
    243261
     
    246264                   OPEN_ACCESS_READONLY | OPEN_SHARE_DENYNONE |
    247265                   OPEN_FLAGS_DASD | OPEN_FLAGS_FAIL_ON_ERROR, 0);
    248   if(Status) {
    249     DosError(FERR_DISABLEHARDERR);
    250     if(type)
    251       (*type) |= DRIVE_REMOVABLE;
     266  if(Status)
     267  {
     268    DosError(FERR_DISABLEHARDERR);
     269    if (pulType)
     270      *pulType |= DRIVE_REMOVABLE;      // Assume removable if can not access
    252271    DosFreeMem(Buffer);
    253     return(1);  /* assume inaccessible local drives are removable */
     272    return 1;                           // Say removable
    254273  }
    255274  LengthIn = sizeof(Command);
     
    260279              &NonRemovable, sizeof(NonRemovable), &LengthOut);
    261280  DosClose(Handle);
    262   if(!NonRemovable && type)
    263     (*type) |= DRIVE_REMOVABLE;
     281  if (!NonRemovable && pulType)
     282    *pulType |= DRIVE_REMOVABLE;
    264283  DosFreeMem(Buffer);
    265   return (NonRemovable) ? 0 : 1;
     284  return NonRemovable ? 0 : 1;
    266285}
    267286
     
    532551
    533552
    534 VOID DriveFlagsOne (INT x) {
    535 
     553VOID DriveFlagsOne (INT x)
     554{
    536555  INT         removable;
    537556  CHAR        szDrive[] = " :\\",FileSystem[CCHMAXPATH];
     
    546565                    DRIVE_NOLOADSUBJS | DRIVE_NOLOADLONGS |
    547566                    DRIVE_INCLUDEFILES | DRIVE_SLOW);
    548   if(removable != -1) {
    549 
    550     struct {
     567  if(removable != -1)
     568  {
     569    struct
     570    {
    551571      ULONG serial;
    552572      CHAR  volumelength;
     
    566586  if(drvtype & DRIVE_REMOTE)
    567587    driveflags[x] |= DRIVE_REMOTE;
    568   if(strcmp(FileSystem,HPFS) &&
    569      strcmp(FileSystem,HPFS386) &&
    570      strcmp(FileSystem,CDFS))
     588  if (strcmp(FileSystem,HPFS) &&
     589      strcmp(FileSystem,JFS) &&
     590      strcmp(FileSystem,CDFS) &&
     591      strcmp(FileSystem,FAT32) &&
     592      strcmp(FileSystem,HPFS386))
     593  {
    571594    driveflags[x] |= DRIVE_NOLONGNAMES;
     595  }
    572596  if(!strcmp(FileSystem,CDFS)) {
    573597    removable = 1;
Note: See TracChangeset for help on using the changeset viewer.