home *** CD-ROM | disk | FTP | other *** search
/ Network Support Encyclopedia 96-1 / novell-nsepro-1996-1-cd2.iso / download / netware / 310pt1.exe / NCPLIM / NCPLIMIT.DOC next >
Text File  |  1990-12-17  |  19KB  |  446 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.                 Guide to Doing File Search Software Development 
  11.  
  12.                                on NetWare 386
  13.  
  14.  
  15.  
  16.  
  17.          Table of Contents
  18.          ------------------
  19.  
  20.  
  21.          1.0     Introduction
  22.  
  23.          2.0     File Searching on NetWare
  24.          2.1     File Searches on 286
  25.          2.2     File Searches on 386
  26.  
  27.          3.0     Software Development Guidelines
  28.          3.1        General Information
  29.          3.2        Using Novel's API
  30.          3.2.1         Coding Examples
  31.          3.3        Using Turbo C
  32.          3.3.1         Coding Examples
  33.          3.4        Using DOS Function Calls
  34.          3.4.1         Coding Examples
  35.  
  36.          4.0     NCPLIMIT patch for NetWare 386 version 3.10
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.          1.0     Introduction
  45.  
  46.  
  47.          The purpose of this guide is to provide additional information 
  48.          for software developers writing software that will operate on a 
  49.          NetWare environment.  Specifically, this guide addresses problems 
  50.          and guidelines for  doing file and directory searches on NetWare 
  51.          drives.  
  52.  
  53.  
  54.          CHAPTER 2:  File searching on NetWare.  This chapter describes
  55.          NetWare file searching under 286 and 386.
  56.  
  57.          CHAPTER 3:  Software Development Guidelines.  This chapter gives
  58.          specific examples of doing file searches using Novell's API,
  59.          Borland C and DOS function calls.
  60.  
  61.          CHAPTER 4:  NCPLIMIT patch for NetWare 386 version 3.10.  This
  62.          chapter describes the use of the patch written to fix a problem
  63.          in NetWare.
  64.  
  65.  
  66.          Additional References:
  67.  
  68.             Novell API:  NetWare C Interface.
  69.  
  70.             BORLAND TURBO C:  Library Reference Guide.
  71.  
  72.             DOS Technical Reference.
  73.  
  74.  
  75.  
  76.  
  77.  
  78.          2.0     File Searching on NetWare
  79.  
  80.  
  81.          File searching on NetWare, from a software developers view, is 
  82.          fundamentally the same as doing file searches on DOS.  The real 
  83.          difference being that under DOS, the file searches are performed 
  84.          locally and under NetWare, a file search request command is sent 
  85.          to the File Server and a response is returned when the search is 
  86.          complete.  The NetWare File Server maintains all the directory 
  87.          structures, file structures and tables that are needed to provide 
  88.          directory and file services to all attached workstations.
  89.  
  90.          A program that performs file searches is any program that does 
  91.          find first's, find next's, or scans directories for file information.
  92.          File searches come in two forms:  1.  when the complete filename or 
  93.          directory name is supplied by the program,  such as "REPORTS.DOC" 
  94.          and  2.  when a wildcard character ( "*" or "?" ) is supplied as a
  95.          part of the filename, such as "MAY??.RPT" or "CLASS*.*".   When a 
  96.          search is done and the complete filename is supplied to NetWare, the
  97.          file server is able to perform the search to completion.  When  a 
  98.          search is done and a wildcard character is supplied, NetWare must 
  99.          retain information about the ongoing search until the searching has
  100.          completed by reaching the end of the specified directory or volume.
  101.          NetWare must  store this information  because the DOS DTA  (Disk 
  102.          Transfer Area) does not have enough space to store a file server 
  103.          number, volume number, and a long (4 byte) search sequence number 
  104.          for over 2 million directory table entries per volume.
  105.  
  106.          2.1     File Searches on 286
  107.  
  108.  
  109.          In order to appreciate how NetWare 386 works it helps to take a 
  110.          look back at NetWare 286 and see how things were.
  111.  
  112.          Two things to remember about NetWare 286 are first, each work-
  113.          station is running under some version of DOS with the corresponding 
  114.          NetWare shell and second, there is a maximum of 32K  directory 
  115.          table entries per volume.
  116.  
  117.          Under DOS,  file commands (open, close, search, read, write, etc.)
  118.          typically use a 16 bit file handle to address files and directorys.  
  119.          This 16 bit value worked nicely for addressing the NetWare 286 
  120.          directory table.  NetWare was able to use the information supplied 
  121.          by DOS to perform the file searches.
  122.  
  123.  
  124.          2.2     File Searches on 386
  125.  
  126.          File operations on NetWare 386 are different for a number of 
  127.          reasons.  One of particular interest to file searches exists 
  128.          because of a 386 enhancement allowing for a maximum number of 
  129.          directory table entries per volume of 2,097,152.  With a work-
  130.          station, running DOS, file  handles are still  16 bit values. 
  131.          This 16 bit value is no longer adequate to address all possible
  132.          entries in a NetWare 386 volume directory table.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.          NetWare must now maintain a table of file and directory entries 
  141.          to map the DOS 16 bit handle to a NetWare 32 bit directory index.
  142.          The number of entries in this table is limited by the SET 
  143.          parameter  "Maximum Outstanding  NCP Searches"  (refer to the 
  144.          NetWare 386 System Administration guide for information on the 
  145.          "set" command).  When the number of entries in the table exceeds 
  146.          the maximum, the oldest entry is removed.  If the entry that is 
  147.          removed is still flagged as an "active" entry, the warning message 
  148.          "You exceeded your outstanding  NCP directory search  limit" is 
  149.          displayed on the workstation console.  When this has happened,
  150.          NetWare no longer  has enough information to  complete the file
  151.          search command requested.  A "file not found" status is returned
  152.          to the calling program along with the console message.  This will
  153.          cause any  number of  undesirable side effects  to the software
  154.          involved.  
  155.  
  156.          The goal of this document is to provide information so developers 
  157.          can write code that does not leave old search information in the
  158.          NetWare search map table.
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.          3.0     Software Development Guidelines
  166.  
  167.  
  168.          3.1        General Information
  169.  
  170.          This section will attempt to describe correct programming practices 
  171.          when doing file searches under NetWare.
  172.  
  173.          The problem we are going to try to avoid is starting a file search 
  174.          and leaving it uncompleted.  This will fill  up NetWare's  mapping 
  175.          table with active entries and will eventually produce the warning 
  176.          message described in section 2.2.
  177.  
  178.          There are  two specific  cases where searches  are started and not 
  179.          completed that will be discussed here.
  180.  
  181.          Case 1:  A program does a "find first" search using a wildcard
  182.                   character in the file name followed by an "open" on the
  183.                   filename returned by the "find first".  The "find first"
  184.                   search function call will leave an active entry in the 
  185.                   NetWare mapping table.  The correct way to program this 
  186.                   example would be to eliminate the "find first" search 
  187.                   function call.  The "open" function automatically initiates 
  188.                   a file search but does not leave an active entry in the 
  189.                   NetWare search mapping table.
  190.  
  191.                   NOTE: If the "find first" call did not use wild card
  192.                   characters, it does not cause this problem.
  193.  
  194.          Case 2:  A program does  a file search in  a given directory using 
  195.                   one of  the wildcard characters  "?" or "*" and  does not 
  196.                   complete the  search.   This happens when a  program is 
  197.                   searching for a file,  finds it, and does not  continue 
  198.                   searching until the end of the directory or volume.  This 
  199.                   will leave an active entry in the  NetWare mapping table 
  200.                   and can eventually produce the warning message described 
  201.                   in section 2.2.
  202.  
  203.         
  204.  
  205.  
  206.  
  207.          3.2        Using Novel's API
  208.  
  209.          Novell's API programming library provides two functions that 
  210.          perform directory and file scans and return information about
  211.          the respective directory or file.  "ScanDirectoryInformation" 
  212.          allows a program to obtain information about the first (or next 
  213.          consecutive)  subdirectory of  a specified  directory  and 
  214.          "ScanFileInformation" will perform the same basic function 
  215.          for files.  
  216.  
  217.          When using these two functions with a wildcard character as a 
  218.          part of the file or directory name search string, the program 
  219.          needs to finish  the search by looping  until the end  of the 
  220.          directory.  Failure to complete the search will leave an active 
  221.          entry in the NetWare mapping table and can eventually produce 
  222.          the warning message described in section 2.2.
  223.  
  224.  
  225.          3.2.1         Coding Examples
  226.  
  227.          /*     Example 1    ScanDirectoryInformation   */
  228.  
  229.          #include      <nit.h>
  230.  
  231.          main()
  232.          {
  233.               BYTE         dir_handle;
  234.               int          sequence_number;
  235.               char         sub_dir_name[16];
  236.               BYTE         date_time[4];
  237.               long         owner;
  238.               BYTE         rights_mask;
  239.               int          done;
  240.  
  241.               /*          .         */
  242.               /*          .         */
  243.               /*          .         */
  244.  
  245.               sequence_number = 0;         /* find the first subdirectory */
  246.               done = ScanDirectoryInformation( dir_handle,
  247.                                                "*.*", sequence_number,
  248.                                                sub_dir_name, date_time,
  249.                                                &owner, &rights_mask);
  250.  
  251.               while( !done )               /* loop through all subdirectories */
  252.               {
  253.               /*  process the subdirectory code */
  254.               /*          .                     */
  255.               /*          .                     */
  256.               /*          .                     */
  257.                                            /* get the next subdirectory */
  258.                   done = ScanDirectoryInformation( dir_handle,
  259.                                                    "*.*", sequence_number,
  260.                                                    sub_dir_name, date_time,
  261.                                                    &owner, &rights_mask);
  262.               }
  263.          }
  264.  
  265.  
  266.  
  267.  
  268.          /*     Example 2    ScanFileInformation   */
  269.  
  270.          #include      <nit.h>
  271.  
  272.          main()
  273.          {
  274.               BYTE         dir_handle;
  275.               char         path_name[255];
  276.               char         file_name[15];
  277.               char         creation_date[2];
  278.               char         last_access_date[2];
  279.               char         last_update_date_time[4];
  280.               char         last_archive_date_time[4];
  281.               BYTE         search_attributes;
  282.               BYTE         file_attributes;
  283.               BYTE         ext_file_attributes;
  284.               long         owner;
  285.               long         file_size;
  286.               int          done;
  287.  
  288.  
  289.               /*          .         */
  290.               /*          .         */
  291.               /*          .         */
  292.  
  293.               sequence_number = 0;              /* find the first file */
  294.               done = ScanfileInformation( dir_handle,
  295.                                           path_name, search_attributes,
  296.                                           &sequence_number, file_name,
  297.                                           &file_attributes, 
  298.                                           &ext_file_attributes,
  299.                                           &file_size, creation_date,
  300.                                           last_access_date, 
  301.                                           last_update_date_time,
  302.                                           last_archive_date_time, &owner );
  303.  
  304.               while( !done )                    /* loop through all files */
  305.               {
  306.               /*  process the next file code    */
  307.               /*          .                     */
  308.               /*          .                     */
  309.               /*          .                     */
  310.                                                 /* now get the next file */
  311.                    done = ScanfileInformation( dir_handle,
  312.                                                path_name, search_attributes,
  313.                                                &sequence_number, file_name,
  314.                                                &file_attributes, 
  315.                                                &ext_file_attributes,
  316.                                                &file_size, creation_date,
  317.                                                last_access_date, 
  318.                                                last_update_date_time,
  319.                                                last_archive_date_time, &owner );
  320.               }
  321.          }
  322.  
  323.  
  324.  
  325.  
  326.  
  327.  
  328.          3.3        Using Turbo C
  329.  
  330.          The Turbo C library contains two function calls that should 
  331.          be used with care when programming for NetWare, "findfirst" 
  332.          and "findnext".  The call "findfirst" should not be used along 
  333.          with any of the Turbo C file open calls.  Any time "findfirst" 
  334.          is used, "findnext" should always be used until searching is 
  335.          complete.
  336.  
  337.  
  338.          3.3.1         Coding Examples
  339.  
  340.          #include      <dir.h>
  341.  
  342.          main()
  343.          {
  344.               struct ffblk file_find_blk;
  345.               int          done;
  346.  
  347.               done = findfirst( "*.*",              /* get the first file */
  348.                                 &file_find_blk, 0);
  349.               while( !done )                        /* loop through all files */
  350.               {
  351.                  /*  process the file code */
  352.                  /*          ..            */
  353.                  /*          ..            */
  354.                  done = findnext(&file_find_blk);   /* get next file */
  355.               }
  356.          }
  357.  
  358.  
  359.  
  360.          3.4        Using DOS Function Calls
  361.  
  362.          When using DOS function calls, there are two sets of calls that
  363.          will perform file searches:  Function 17 (11 Hex), Function 18
  364.          (12 Hex) and function 78 (4E Hex), function 79 (4F Hex).  As with
  365.          the previous examples, any time you make a call to function 17 or
  366.          function 78 you  must complete  the searches by using functions 
  367.          18 or 79.  
  368.  
  369.          It should  also be noted  that functions 17  and 18 are old DOS 
  370.          functions (version  1.0) and  use FCB's  (File Control Blocks) 
  371.          instead of file handles.  Functions 78 and 79 are the recommended 
  372.          functions to use.
  373.  
  374.  
  375.          3.4.1         Coding Examples
  376.  
  377.  
  378.          file_name     db      "REPORT*.*"
  379.  
  380.          DTA_buffer    db      43 dup (?)          ;allocate space for the DTA
  381.  
  382.                        .
  383.                        .
  384.                        .
  385.                                                    ;First we must set up the DTA.
  386.                        mov     ah, 1AH             ;DOS function 1AH
  387.                        mov     dx, seg DTA_buffer  ;ds:dx points to DTA buffer
  388.                        mov     ds, dx
  389.                        mov     dx, offset DTA_buffer
  390.                        int     21H                 ;hand it to DOS
  391.                        .
  392.                        .
  393.                                                    ;Now get ready to search for the
  394.                                                    ;first file...
  395.                        mov     ah, 4EH             ;DOS find first function 
  396.                        mov     cx, 0               ;normal search attribute
  397.                        mov     dx, seg file_name   ;ds:dx points to file name
  398.                        mov     ds, dx
  399.                        mov     dx, offset file_name
  400.                        int     21H                 ;Hand it to DOS
  401.                        jc      no_more_files       ;if carry is set, then no 
  402.                                                    ;file was found.
  403.          file_loop:
  404.                        .                           ;code for processing the
  405.                        .                           ;files as they are found.
  406.                        .
  407.                                                    ;Now setup to find the next
  408.                                                    ;file match
  409.                        mov     ah, 4FH             ;DOS find next file
  410.                        int     21H                 ;Hand it to DOS
  411.                        jc      no_more_files       ;if carry is set, then no 
  412.                                                    ;more files to process
  413.  
  414.                        jmp     file_loop           ;Always loop until there are 
  415.                                                    ;no more files to process.
  416.  
  417.          no_more_files:
  418.  
  419.  
  420.  
  421.  
  422.          4.0     NCPLIMIT patch for NetWare 386 version 3.10
  423.  
  424.  
  425.          This patch is written for NetWare 386 version 3.10.  It is to 
  426.          be used with the Novell patch manager NLM "PATCHMAN.NLM".  The 
  427.          "NCPLIMIT.NLM" patch adds code that will provide better manage-
  428.          ment of file searches done on the server.  If you have applications 
  429.          that generate the warning message "You exceeded your outstanding 
  430.          NCP directory search limit." you should load this NLM on the server.
  431.  
  432.          To load NCPLIMIT.NLM from floppy disk enter the following commands 
  433.          at the server console:
  434.  
  435.  
  436.          LOAD A:PATCHMAN            ( This loads the patch manager NLM )
  437.          LOAD A:NCPLIMIT            ( This loads the ncp limit NLM patch )
  438.  
  439.  
  440.               
  441.          Using this patch will fix a problem with NetWare management of 
  442.          the  search mapping table but is  NOT a replacement for correct
  443.          programming.  If, after loading this patch, you still get the
  444.          warning message on the workstation, you will need to follow the
  445.          recommendations given in this guide to fix your software.
  446.