usrNfs.c
上传用户:luoyougen
上传日期:2008-05-12
资源大小:23136k
文件大小:2k
源码类别:

VxWorks

开发平台:

C/C++

  1. /* usrNfs.c - Support for NFS */
  2. /* Copyright 1999-2002 Wind River Systems, Inc. */
  3. /*
  4. modification history
  5. --------------------
  6. 01c,20dec01,vvv  added alloca support
  7. 01b,06nov01,vvv  made max. path length configurable (SPR #63551)
  8. 01a,25feb99,nps  written
  9. */
  10. /*
  11. DESCRIPTION
  12. This file is used to include support for network devices using the BSD
  13. interface. The file contents are included in the project configuration 
  14. file when INCLUDE_NFS is defined. This file performs the necessary
  15. configuration - namely sets the Unix authorisations as specified by
  16. the user via the project facility.
  17. NOMANUAL
  18. */
  19. #ifdef __GNUC__
  20. # ifndef alloca
  21. #  define alloca __builtin_alloca
  22. # endif
  23. #endif
  24. const int nfsMaxPath = NFS_MAXPATH + 1;
  25. /******************************************************************************
  26. *
  27. * usrNfsInit - initialize NFS
  28. *
  29. * This routine initializes NFS and configures it using the following parameters
  30. * defined by the user via the project facility.
  31. *
  32. * - NFS_USER_ID
  33. * - NFS_GROUP_ID
  34. *
  35. * RETURNS: OK or ERROR
  36. *
  37. * NOMANUAL
  38. */
  39. STATUS usrNfsInit (void)
  40.     {
  41.     char *devName;
  42.     if (nfsMaxPath < 1)
  43. {
  44. printf ("Error initializing NFS, invalid NFS_MAXPATHn");
  45. return (ERROR);
  46. }
  47.     if ((devName = (char *) alloca (nfsMaxPath)) == NULL)
  48. {
  49. printf ("Error initializing NFS, out of memoryn");
  50. return (ERROR);
  51. }
  52.     /*
  53.      * The following values are the default values used in NFS.
  54.      * They can be reset here if necessary.
  55.      *
  56.      *     nfsMaxMsgLen   = 8192        message size (decrease only)
  57.      *     nfsTimeoutSec  = 5           timeout seconds
  58.      *     nfsTimeoutUSec = 0           timeout microseconds
  59.      */
  60. #if (CPU==SIMHPPA)
  61.     nfsMaxMsgLen   = 512;
  62. #endif
  63.     nfsAuthUnixSet (sysBootParams.hostName,
  64.         NFS_USER_ID,
  65.         NFS_GROUP_ID,
  66.         0,
  67.         (int *) 0);
  68.     if (nfsDrv () == ERROR)     /* initialize nfs driver */
  69.         printf ("Error initializing NFS, errno = %#xn", errno);
  70.     else
  71.         {
  72.         /* if the boot pathname starts with a device name, e.g. an nfs mount,
  73.          * then set the current directory to that device
  74.          */
  75.         (void) iosDevFind (sysBootParams.bootFile, &pAddrString);
  76.         if (pAddrString != sysBootParams.bootFile)
  77.             {
  78.             devName[0] = EOS;
  79.             strncat (devName, sysBootParams.bootFile, pAddrString - sysBootParams.bootFile);
  80.             ioDefPathSet (devName);
  81.             }
  82.         }
  83.     return OK;
  84.     }