home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / CLIPPER / MISC / EMXLIB8F.ZIP / EMX / LIB / SYS / FILESYS.C < prev    next >
Encoding:
C/C++ Source or Header  |  1993-01-02  |  811 b   |  38 lines

  1. /* sys/filesys.c (emx+gcc) -- Copyright (c) 1992-1993 by Eberhard Mattes */
  2.  
  3. #include <sys/emx.h>
  4. #include <string.h>
  5. #include <errno.h>
  6. #include <os2emx.h>
  7. #include "syscalls.h"
  8.  
  9. #define QFSA_SIZE 256
  10.  
  11. int __filesys (const char *drive, char *name, size_t size)
  12. {
  13.   ULONG rc;
  14.   ULONG len;
  15.   FSQBUFFER2 *buf;
  16.  
  17.   len = sizeof (FSQBUFFER2) + QFSA_SIZE;
  18.   buf = alloca (len);
  19.   rc = DosQueryFSAttach (drive, 1, FSAIL_QUERYNAME, buf, &len);
  20.   if (rc != 0)
  21.     {
  22.       _sys_set_errno (rc);
  23.       return (-1);
  24.     }
  25.   if (buf->iType != FSAT_LOCALDRV && buf->iType != FSAT_REMOTEDRV)
  26.     {
  27.       errno = EINVAL;
  28.       return (-1);
  29.     }
  30.   if (buf->cbFSDName >= size)
  31.     {
  32.       errno = E2BIG;
  33.       return (-1);
  34.     }
  35.   strcpy (name, buf->szFSDName + buf->cbName);
  36.   return (0);
  37. }
  38.