home *** CD-ROM | disk | FTP | other *** search
/ Magazyn Amiga 13 / MA_Cover_13.bin / source / c / nfsd / src / mount.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-11-29  |  1.7 KB  |  72 lines

  1. /*  RPC code for the mount protocol
  2.  
  3.     ©1999 Joseph Walton
  4.  
  5.     This software is distributed under the terms of the GNU General Public
  6.     License; either version 2 of the License, or (at your option) any
  7.     later version.
  8. */
  9.  
  10. #include "mount.h"
  11. #include "nfs.h"
  12.  
  13. #include "mount_functions.h"
  14.  
  15. /* This is actually a fairly large buffer */
  16. static char pathBuffer[MNTPATHLEN + 1];
  17.  
  18. int mount_procedure(struct Call *call, int32 *ptr, int32 *limit,
  19.     int32 *rptr, int32 *rlimit)
  20. {
  21.     if (call->c_version != MOUNT_VERSION) {
  22.         *rptr++ = P_ENUM(PROG_MISMATCH);
  23.         *rptr++ = P_UINT(MOUNT_VERSION);
  24.         *rptr++ = P_UINT(MOUNT_VERSION);
  25.         return 8;
  26.     }
  27.  
  28.     switch (call->c_procedure) {
  29.         case MOUNT_PROC_NULL:
  30.             *rptr++ = P_ENUM(SUCCESS);
  31.             return 6;
  32.  
  33.         case MOUNT_PROC_MNT:
  34.             ptr = getString(ptr, limit, pathBuffer, sizeof(pathBuffer));
  35.  
  36.             if (!ptr) {
  37.                 *rptr++ = P_ENUM(GARBAGE_ARGS);
  38.                 return 6;
  39.             }
  40.  
  41.             *rptr++ = P_ENUM(SUCCESS);
  42.  
  43.             if ((*rptr = mountproc_mnt(call, pathBuffer, rptr + 1))
  44.                 == NFS_OK)
  45.             {
  46.                 return 7 + INT32S(NFS_FHSIZE);
  47.             }
  48.  
  49.             /* Failed, so we return without the handle */
  50.             return 7;
  51.  
  52.         case MOUNT_PROC_UMNT:
  53.             ptr = getString(ptr, limit, pathBuffer, sizeof(pathBuffer));
  54.  
  55.             if (!ptr) {
  56.                 *rptr++ = P_ENUM(GARBAGE_ARGS);
  57.                 return 6;
  58.             }
  59.  
  60.             /* Succeed at doing nothing */
  61.             *rptr = P_ENUM(SUCCESS);
  62.  
  63.             mountproc_umnt(call, pathBuffer);
  64.             return 6;
  65.  
  66.         default:
  67.             *rptr++ = P_ENUM(PROC_UNAVAIL);
  68.             return 6;
  69.     }
  70. }
  71.  
  72.