home *** CD-ROM | disk | FTP | other *** search
/ Network Support Encyclopedia 96-1 / novell-nsepro-1996-1-cd2.iso / download / netware / xdfs2.exe / XDFS2.C next >
C/C++ Source or Header  |  1995-08-25  |  4KB  |  153 lines

  1. /**************************************************************************
  2. ** File: xdfs2.c
  3. **
  4. ** Desc: Example program for making Direct File System calls.
  5. **
  6. **       This program displays the file map information on the file
  7. **       specified on the command line.
  8. **
  9. **
  10. **   DISCLAIMER  
  11. **  
  12. **   Novell, Inc. makes no representations or warranties with respect to
  13. **   any NetWare software, and specifically disclaims any express or
  14. **   implied warranties of merchantability, title, or fitness for a
  15. **   particular purpose.  
  16. **
  17. **   Distribution of any NetWare software is forbidden without the
  18. **   express written consent of Novell, Inc.  Further, Novell reserves
  19. **   the right to discontinue distribution of any NetWare software.
  20. **   
  21. **   Novell is not responsible for lost profits or revenue, loss of use
  22. **   of the software, loss of data, costs of re-creating lost data, the
  23. **   cost of any substitute equipment or program, or claims by any party
  24. **   other than you.  Novell strongly recommends a backup be made before
  25. **   any software is installed.   Technical support for this software
  26. **   may be provided at the discretion of Novell.
  27. **
  28. **
  29. **    QMK386 options used:
  30. **
  31. **        None
  32. **
  33. ** Programmers:
  34. **
  35. **    Ini   Who                  Firm
  36. **    ---------------------------------------------------------------------
  37. **    DWH   Dirk W. Howard       Novell Developer Support
  38. **
  39. **
  40. ** History:
  41. **
  42. **    When        Who      What
  43. **    ---------------------------------------------------------------------
  44. **    8-23-1995    DWH      First code.
  45. **
  46. */
  47.  
  48.  
  49. /**************************************************************************
  50. ** Prototypes and macro definitions
  51. */
  52.  
  53. #ifndef PPC
  54.    /*------------------------------------------------
  55.    ** NetWare Intel include files
  56.    */
  57.    #include <stdio.h>
  58.    #include <dfs.h>
  59.    #include <fcntl.h>
  60.    #include <share.h>
  61.    #include <sys\stat.h>
  62.    #include <string.h>
  63. #else
  64.    /*------------------------------------------------
  65.    ** NetWare Power PC include files
  66.    */
  67.    #include <nwtypes.h>
  68.    #include <stdio.h>
  69.    #include <nwdfs.h>
  70.    #include <fcntl.h>
  71.    #include <share.h>
  72.    #include <sys\stat.h>
  73.    #include <string.h>
  74. #endif
  75.  
  76.    /*------------------------------------------------
  77.    ** Macro substitutions
  78.    */
  79.    #define  MAX_TABLE         1
  80.  
  81.  
  82. /**************************************************************************
  83. ** main procedure
  84. */
  85. void main( int argc, char *argv[] )
  86. {
  87.    LONG           lCount;
  88.    LONG           lFH;
  89.    LONG           lCompCode;
  90.    LONG           lFileBlock;
  91.    char           caFilename[ 80 ];
  92.    char           sparseFlag = ' ';
  93.    struct FileMapStructure    mapTable;
  94.  
  95.    if ( argc < 2 )
  96.    {
  97.       printf( "Usage: LOAD %s <filename>\r\n", argv[0] );
  98.       return;
  99.    }
  100.  
  101.    strcpy( caFilename, argv[1] );
  102.  
  103.    /* Open file */
  104.    lFH = DFSsopen( caFilename, O_RDONLY | O_EXCL, SH_COMPAT, 
  105.                    S_IWRITE | S_IREAD, 0x00000040, 0 );
  106.    if ( lFH == -1 )
  107.    {
  108.       printf( "XDFS2: Error in DFSsopen for %s\n\r", caFilename );
  109.       perror( "DFSsopen" );
  110.       return;
  111.    }
  112.  
  113.    /* DFSReturnFileMappingInformation */
  114.    lFileBlock = 0;
  115.    printf( "File Mapping Info                        * = Sparse file hole \r\n"
  116.            "File : %s\r\n\r\n"
  117.            "  Volume Block   File Block   Blocks Contiguous\r\n",
  118.            caFilename );
  119.    do
  120.    {
  121.       lCompCode = DFSReturnFileMappingInformation( lFH, lFileBlock, &lCount,
  122.                   MAX_TABLE, &mapTable );
  123.       if ( lCompCode != 0 )
  124.       {
  125.          printf( "XDFS2: Error in DFSReturnFileMappingInformation %ld\r\n", 
  126.                  lCompCode );
  127.          DFSclose( lFH );
  128.          return;
  129.       }
  130.  
  131.       if ( lFileBlock == mapTable.fileBlock )
  132.       {
  133.          printf( "%c %08ld       %08ld     %08ld\r\n", 
  134.                  sparseFlag, mapTable.volumeBlock, mapTable.fileBlock, 
  135.                  mapTable.numberOfBlocks );
  136.          sparseFlag = ' ';
  137.  
  138.          lFileBlock = lFileBlock + mapTable.numberOfBlocks;
  139.       }
  140.       else
  141.       {
  142.          lFileBlock = mapTable.fileBlock;
  143.          sparseFlag = '*';
  144.       }
  145.  
  146.    } while ( lCount != 0 );
  147.  
  148.  
  149.    /* Close file */
  150.    DFSclose( lFH );
  151. }
  152.  
  153.