commit-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

hurd/nfsd ChangeLog cache.c loop.c ops.c xdr.c


From: Marcus Brinkmann
Subject: hurd/nfsd ChangeLog cache.c loop.c ops.c xdr.c
Date: Sun, 29 Sep 2002 11:12:48 -0400

CVSROOT:        /cvsroot/hurd
Module name:    hurd
Changes by:     Marcus Brinkmann <address@hidden>       02/09/29 11:12:48

Modified files:
        nfsd           : ChangeLog cache.c loop.c ops.c xdr.c 

Log message:
        2002-09-29  Marcus Brinkmann  <address@hidden>
        
        * loop.c (server_loop): Use memset instead bzero.
        (server_loop): Add parenthesis for post-decrement (even
        though it is only used as an lvalue here).  Increment P after
        using it in the macro, not within.
        * ops.c (complete_setattr): Likewise.
        (op_setattr, op_read, op_write, op_create, op_symlink, op_mkdir,
        op_readdir, op_getport): Likewise.
        * xdr.c (encode_fattr): Likewise.
        (encode_data): Likewise.  Also use memcpy instead bcopy.
        (encode_statfs): Likewise.
        (decode_name): Likewise.  Also use memcpy instead bcopy.
        (encode_fhandle): Use memcpy instead bcopy.
        * cache.c (process_cred): Add parenthesis for post-decrement (even
        though it is only used as an lvalue here).  Increment P after
        using it in the macro, not within.
        (idspec_lookup): Use memcpy, not bcopy.
        (lookup_cache_handle): Likewise.
        (create_cached_handle): Likewise.
        (check_cached_replies): Likewise.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/hurd/hurd/nfsd/ChangeLog.diff?tr1=1.21&tr2=1.22&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/hurd/hurd/nfsd/cache.c.diff?tr1=1.10&tr2=1.11&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/hurd/hurd/nfsd/loop.c.diff?tr1=1.7&tr2=1.8&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/hurd/hurd/nfsd/ops.c.diff?tr1=1.7&tr2=1.8&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/hurd/hurd/nfsd/xdr.c.diff?tr1=1.4&tr2=1.5&r1=text&r2=text

Patches:
Index: hurd/nfsd/ChangeLog
diff -c hurd/nfsd/ChangeLog:1.21 hurd/nfsd/ChangeLog:1.22
*** hurd/nfsd/ChangeLog:1.21    Wed May 29 04:36:06 2002
--- hurd/nfsd/ChangeLog Sun Sep 29 11:12:48 2002
***************
*** 1,3 ****
--- 1,25 ----
+ 2002-09-29  Marcus Brinkmann  <address@hidden>
+ 
+       * loop.c (server_loop): Use memset instead bzero.
+       (server_loop): Add parenthesis for post-decrement (even
+       though it is only used as an lvalue here).  Increment P after
+       using it in the macro, not within.
+       * ops.c (complete_setattr): Likewise.
+       (op_setattr, op_read, op_write, op_create, op_symlink, op_mkdir,
+       op_readdir, op_getport): Likewise.
+       * xdr.c (encode_fattr): Likewise.
+       (encode_data): Likewise.  Also use memcpy instead bcopy.
+       (encode_statfs): Likewise.
+       (decode_name): Likewise.  Also use memcpy instead bcopy.
+       (encode_fhandle): Use memcpy instead bcopy.
+       * cache.c (process_cred): Add parenthesis for post-decrement (even
+       though it is only used as an lvalue here).  Increment P after
+       using it in the macro, not within.
+       (idspec_lookup): Use memcpy, not bcopy.
+       (lookup_cache_handle): Likewise.
+       (create_cached_handle): Likewise.
+       (check_cached_replies): Likewise.
+ 
  2002-05-29  Roland McGrath  <address@hidden>
  
        * nfsd.h (struct proctable): [0] -> [], for newfangled GCC.
Index: hurd/nfsd/cache.c
diff -c hurd/nfsd/cache.c:1.10 hurd/nfsd/cache.c:1.11
*** hurd/nfsd/cache.c:1.10      Wed May  8 05:29:13 2002
--- hurd/nfsd/cache.c   Sun Sep 29 11:12:48 2002
***************
*** 1,4 ****
! /*
     Copyright (C) 1996,98,99,2000,02 Free Software Foundation, Inc.
     Written by Michael I. Bushnell, p/BSG.
  
--- 1,4 ----
! /* cache.c - Cache operations for the nfs daemon.
     Copyright (C) 1996,98,99,2000,02 Free Software Foundation, Inc.
     Written by Michael I. Bushnell, p/BSG.
  
***************
*** 46,54 ****
  static int nfreeids;
  static int leastidlastuse;
  
! /* Compare I against the specified set of users/groups. */
  /* Use of int in decl of UIDS and GIDS is correct here; that's
!    the NFS type because they come in in known 32 bit slots. */
  static int
  idspec_compare (struct idspec *i, int nuids, int ngids,
                int *uids, int *gids)
--- 46,54 ----
  static int nfreeids;
  static int leastidlastuse;
  
! /* Compare I against the specified set of users/groups.  */
  /* Use of int in decl of UIDS and GIDS is correct here; that's
!    the NFS type because they come in in known 32 bit slots.  */
  static int
  idspec_compare (struct idspec *i, int nuids, int ngids,
                int *uids, int *gids)
***************
*** 66,72 ****
    return 1;
  }
  
! /* Compute a hash value for a given user spec */
  static int
  idspec_hash (int nuids, int ngids, int *uids, int *gids)
  {
--- 66,72 ----
    return 1;
  }
  
! /* Compute a hash value for a given user spec.  */
  static int
  idspec_hash (int nuids, int ngids, int *uids, int *gids)
  {
***************
*** 81,87 ****
    return hash;
  }
  
! /* Lookup a user spec in the hash table and allocate a reference */
  static struct idspec *
  idspec_lookup (int nuids, int ngids, int *uids, int *gids)
  {
--- 81,87 ----
    return hash;
  }
  
! /* Lookup a user spec in the hash table and allocate a reference.  */
  static struct idspec *
  idspec_lookup (int nuids, int ngids, int *uids, int *gids)
  {
***************
*** 107,114 ****
    i->ngids = ngids;
    i->uids = malloc (nuids * sizeof (uid_t));
    i->gids = malloc (ngids * sizeof (gid_t));
!   bcopy (uids, i->uids, nuids * sizeof (uid_t));
!   bcopy (gids, i->gids, ngids * sizeof (gid_t));
    i->references = 1;
  
    i->next = idhashtable[hash];
--- 107,114 ----
    i->ngids = ngids;
    i->uids = malloc (nuids * sizeof (uid_t));
    i->gids = malloc (ngids * sizeof (gid_t));
!   memcpy (i->uids, uids, nuids * sizeof (uid_t));
!   memcpy (i->gids, gids, ngids * sizeof (gid_t));
    i->references = 1;
  
    i->next = idhashtable[hash];
***************
*** 132,164 ****
    int firstgid;
    int i;
  
!   type = ntohl (*p++);
  
    if (type != AUTH_UNIX)
      {
!       int size = ntohl (*p++);
        *credp = idspec_lookup (0, 0, 0, 0);
        p += INTSIZE (size);
      }
    else
      {
!       p++;                    /* skip size */
!       p++;                    /* skip seconds */
!       len = ntohl (*p++);
!       p += INTSIZE (len);     /* skip hostname */
  
!       uid = p++;              /* remember loc of uid */
        *uid = ntohl (*uid);
  
!       firstgid = *p++;                /* remember first gid */
!       gids = p;                       /* here's where the array will start */
!       ngids = ntohl (*p++);
  
!       /* Now swap the first gid to be the first element of the array */
        *gids = firstgid;
!       ngids++;                        /* and count it */
  
!       /* And byteswap the gids */
        for (i = 0; i < ngids; i++)
        gids[i] = ntohl (gids[i]);
  
--- 132,169 ----
    int firstgid;
    int i;
  
!   type = ntohl (*p);
!   p++;
  
    if (type != AUTH_UNIX)
      {
!       int size = ntohl (*p);
!       p++;
        *credp = idspec_lookup (0, 0, 0, 0);
        p += INTSIZE (size);
      }
    else
      {
!       p++;                    /* Skip size.  */
!       p++;                    /* Skip seconds.  */
!       len = ntohl (*p);
!       p++;
!       p += INTSIZE (len);     /* Skip hostname.  */
  
!       uid = p++;              /* Remember location of uid.  */
        *uid = ntohl (*uid);
  
!       firstgid = *(p++);      /* Remember first gid.  */
!       gids = p;                       /* Here is where the array will start.  
*/
!       ngids = ntohl (*p);
!       p++;
  
!       /* Now swap the first gid to be the first element of the
!        array.  */
        *gids = firstgid;
!       ngids++;                        /* And count it.  */
  
!       /* And byteswap the gids.  */
        for (i = 0; i < ngids; i++)
        gids[i] = ntohl (gids[i]);
  
***************
*** 167,175 ****
        *credp = idspec_lookup (1, ngids, uid, gids);
      }
  
!   /* Next is the verf field; skip it entirely */
!   p++;                                /* skip id */
!   len = htonl (*p++);
    p += INTSIZE (len);
  
    return p;
--- 172,181 ----
        *credp = idspec_lookup (1, ngids, uid, gids);
      }
  
!   /* Next is the verf field; skip it entirely.  */
!   p++;                                /* Skip ID.  */
!   len = htonl (*p);
!   p++;
    p += INTSIZE (len);
  
    return p;
***************
*** 235,241 ****
            }
        }
  
!       /* If we didn't bail early, then this is valid */
        if (nfreeids)
        leastidlastuse = newleast;
      }
--- 241,247 ----
            }
        }
  
!       /* If we didn't bail early, then this is valid.  */
        if (nfreeids)
        leastidlastuse = newleast;
      }
***************
*** 281,289 ****
        return p + NFS2_FHSIZE / sizeof (int);
        }
  
!   /* Not found */
  
!   /* First four bytes are our internal table of filesystems */
    fsys = lookup_filesystem (*p);
    if (fsys == MACH_PORT_NULL
        || fsys_getfile (fsys, i->uids, i->nuids, i->gids, i->ngids,
--- 287,295 ----
        return p + NFS2_FHSIZE / sizeof (int);
        }
  
!   /* Not found.  */
  
!   /* First four bytes are our internal table of filesystems.  */
    fsys = lookup_filesystem (*p);
    if (fsys == MACH_PORT_NULL
        || fsys_getfile (fsys, i->uids, i->nuids, i->gids, i->ngids,
***************
*** 295,301 ****
      }
  
    c = malloc (sizeof (struct cache_handle));
!   bcopy (p, c->handle, NFS2_FHSIZE);
    cred_ref (i);
    c->ids = i;
    c->port = port;
--- 301,307 ----
      }
  
    c = malloc (sizeof (struct cache_handle));
!   memcpy (c->handle, p, NFS2_FHSIZE);
    cred_ref (i);
    c->ids = i;
    c->port = port;
***************
*** 363,369 ****
            }
        }
  
!       /* If we didn't bail early, then this is valid. */
        if (nfreefh)
        leastfhlastuse = newleast;
      }
--- 369,375 ----
            }
        }
  
!       /* If we didn't bail early, then this is valid.  */
        if (nfreefh)
        leastfhlastuse = newleast;
      }
***************
*** 381,402 ****
    size_t handlelen = NFS2_FHSIZE - sizeof (int);
    mach_port_t newport, ref;
  
!   /* Authenticate USERPORT so that we can call file_getfh on it. */
    ref = mach_reply_port ();
!   /* MAKE_SEND is safe becaue we destroy REF ourselves. */
    if (io_reauthenticate (userport, ref, MACH_MSG_TYPE_MAKE_SEND)
        || auth_user_authenticate (authserver, ref, MACH_MSG_TYPE_MAKE_SEND,
                                 &newport))
      {
        /* Reauthentication has failed, but maybe the filesystem will let
!        us call file_getfh anyway. */
        newport = userport;
      }
    else
      mach_port_deallocate (mach_task_self (), userport);
    mach_port_destroy (mach_task_self (), ref);
  
!   /* Fetch the file handle */
    *(int *)fhandle = fs;
    err = file_getfh (newport, &bp, &handlelen);
    mach_port_deallocate (mach_task_self (), newport);
--- 387,408 ----
    size_t handlelen = NFS2_FHSIZE - sizeof (int);
    mach_port_t newport, ref;
  
!   /* Authenticate USERPORT so that we can call file_getfh on it.  */
    ref = mach_reply_port ();
!   /* MAKE_SEND is safe becaue we destroy REF ourselves.  */
    if (io_reauthenticate (userport, ref, MACH_MSG_TYPE_MAKE_SEND)
        || auth_user_authenticate (authserver, ref, MACH_MSG_TYPE_MAKE_SEND,
                                 &newport))
      {
        /* Reauthentication has failed, but maybe the filesystem will let
!        us call file_getfh anyway.  */
        newport = userport;
      }
    else
      mach_port_deallocate (mach_task_self (), userport);
    mach_port_destroy (mach_task_self (), ref);
  
!   /* Fetch the file handle.  */
    *(int *)fhandle = fs;
    err = file_getfh (newport, &bp, &handlelen);
    mach_port_deallocate (mach_task_self (), newport);
***************
*** 404,420 ****
      return 0;
    if (bp != fhandle + sizeof (int))
      {
!       bcopy (bp, fhandle + sizeof (int), NFS2_FHSIZE - sizeof (int));
        munmap (bp, handlelen);
      }
  
!   /* Cache it */
    hash = fh_hash (fhandle, credc->ids);
    mutex_lock (&fhhashlock);
    for (c = fhhashtable[hash]; c; c = c->next)
      if (c->ids == credc->ids && ! bcmp (fhandle, c->handle, NFS2_FHSIZE))
        {
!       /* Return this one */
        if (c->references == 0)
          nfreefh--;
        c->references++;
--- 410,426 ----
      return 0;
    if (bp != fhandle + sizeof (int))
      {
!       memcpy (fhandle + sizeof (int), bp, NFS2_FHSIZE - sizeof (int));
        munmap (bp, handlelen);
      }
  
!   /* Cache it.  */
    hash = fh_hash (fhandle, credc->ids);
    mutex_lock (&fhhashlock);
    for (c = fhhashtable[hash]; c; c = c->next)
      if (c->ids == credc->ids && ! bcmp (fhandle, c->handle, NFS2_FHSIZE))
        {
!       /* Return this one.  */
        if (c->references == 0)
          nfreefh--;
        c->references++;
***************
*** 423,429 ****
        }
  
    /* Always call fsys_getfile so that we don't depend on the
!      particular open modes of the port passed in. */
  
    err = fsys_getfile (lookup_filesystem (fs),
                      credc->ids->uids, credc->ids->nuids,
--- 429,435 ----
        }
  
    /* Always call fsys_getfile so that we don't depend on the
!      particular open modes of the port passed in.  */
  
    err = fsys_getfile (lookup_filesystem (fs),
                      credc->ids->uids, credc->ids->nuids,
***************
*** 436,450 ****
        return 0;
      }
  
!   /* Create it anew */
    c = malloc (sizeof (struct cache_handle));
!   bcopy (fhandle, c->handle, NFS2_FHSIZE);
    cred_ref (credc->ids);
    c->ids = credc->ids;
    c->port = newport;
    c->references = 1;
  
!   /* And add it to the hash table */
    c->next = fhhashtable[hash];
    if (c->next)
      c->next->prevp = &c->next;
--- 442,456 ----
        return 0;
      }
  
!   /* Create it anew.  */
    c = malloc (sizeof (struct cache_handle));
!   memcpy (c->handle, fhandle, NFS2_FHSIZE);
    cred_ref (credc->ids);
    c->ids = credc->ids;
    c->port = newport;
    c->references = 1;
  
!   /* And add it to the hash table.  */
    c->next = fhhashtable[hash];
    if (c->next)
      c->next->prevp = &c->next;
***************
*** 464,470 ****
  
  /* Check the list of cached replies to see if this is a replay of a
     previous transaction; if so, return the cache record.  Otherwise,
!    create a new cache record. */
  struct cached_reply *
  check_cached_replies (int xid,
                      struct sockaddr_in *sender)
--- 470,476 ----
  
  /* Check the list of cached replies to see if this is a replay of a
     previous transaction; if so, return the cache record.  Otherwise,
!    create a new cache record.  */
  struct cached_reply *
  check_cached_replies (int xid,
                      struct sockaddr_in *sender)
***************
*** 490,496 ****
    cr = malloc (sizeof (struct cached_reply));
    mutex_init (&cr->lock);
    mutex_lock (&cr->lock);
!   bcopy (sender, &cr->source, sizeof (struct sockaddr_in));
    cr->xid = xid;
    cr->data = 0;
    cr->references = 1;
--- 496,502 ----
    cr = malloc (sizeof (struct cached_reply));
    mutex_init (&cr->lock);
    mutex_lock (&cr->lock);
!   memcpy (&cr->source, sender, sizeof (struct sockaddr_in));
    cr->xid = xid;
    cr->data = 0;
    cr->references = 1;
***************
*** 506,512 ****
  }
  
  /* A cached reply returned by check_cached_replies is now no longer
!    needed by its caller. */
  void
  release_cached_reply (struct cached_reply *cr)
  {
--- 512,518 ----
  }
  
  /* A cached reply returned by check_cached_replies is now no longer
!    needed by its caller.  */
  void
  release_cached_reply (struct cached_reply *cr)
  {
***************
*** 559,565 ****
            }
        }
  
!       /* If we didn't bail early, then this is valid */
        if (nfreereplies)
        leastreplylastuse = newleast;
      }
--- 565,571 ----
            }
        }
  
!       /* If we didn't bail early, then this is valid.  */
        if (nfreereplies)
        leastreplylastuse = newleast;
      }
Index: hurd/nfsd/loop.c
diff -c hurd/nfsd/loop.c:1.7 hurd/nfsd/loop.c:1.8
*** hurd/nfsd/loop.c:1.7        Wed May  8 05:29:13 2002
--- hurd/nfsd/loop.c    Sun Sep 29 11:12:48 2002
***************
*** 1,4 ****
! /* Main server loop for nfs server.
     Copyright (C) 1996,98,2002 Free Software Foundation, Inc.
     Written by Michael I. Bushnell, p/BSG.
  
--- 1,4 ----
! /* loop.c - Main server loop for nfs server.
     Copyright (C) 1996,98,2002 Free Software Foundation, Inc.
     Written by Michael I. Bushnell, p/BSG.
  
***************
*** 55,61 ****
    socklen_t addrlen;
    int cc;
  
!   bzero (&fakec, sizeof (struct cache_handle));
  
    for (;;)
      {
--- 55,61 ----
    socklen_t addrlen;
    int cc;
  
!   memset (&fakec, 0, sizeof (struct cache_handle));
  
    for (;;)
      {
***************
*** 64,96 ****
        addrlen = sizeof (struct sockaddr_in);
        cc = recvfrom (fd, buf, MAXIOSIZE, 0, &sender, &addrlen);
        if (cc == -1)
!       continue;               /* ignore errors */
!       xid = *p++;
  
!       /* Ignore things that aren't proper RPCs. */
!       if (ntohl (*p++) != CALL)
        continue;
  
        cr = check_cached_replies (xid, &sender);
        if (cr->data)
!       /* This transacation has already completed */
        goto repost_reply;
  
        r = (int *) rbuf = malloc (MAXIOSIZE);
  
!       if (ntohl (*p++) != RPC_MSG_VERSION)
        {
!         /* Reject RPC */
!         *r++ = xid;
!         *r++ = htonl (REPLY);
!         *r++ = htonl (MSG_DENIED);
!         *r++ = htonl (RPC_MISMATCH);
!         *r++ = htonl (RPC_MSG_VERSION);
!         *r++ = htonl (RPC_MSG_VERSION);
          goto send_reply;
        }
  
!       program = ntohl (*p++);
        switch (program)
        {
        case MOUNTPROG:
--- 64,99 ----
        addrlen = sizeof (struct sockaddr_in);
        cc = recvfrom (fd, buf, MAXIOSIZE, 0, &sender, &addrlen);
        if (cc == -1)
!       continue;               /* Ignore errors.  */
!       xid = *(p++);
  
!       /* Ignore things that aren't proper RPCs.  */
!       if (ntohl (*p) != CALL)
        continue;
+       p++;
  
        cr = check_cached_replies (xid, &sender);
        if (cr->data)
!       /* This transacation has already completed.  */
        goto repost_reply;
  
        r = (int *) rbuf = malloc (MAXIOSIZE);
  
!       if (ntohl (*p) != RPC_MSG_VERSION)
        {
!         /* Reject RPC.  */
!         *(r++) = xid;
!         *(r++) = htonl (REPLY);
!         *(r++) = htonl (MSG_DENIED);
!         *(r++) = htonl (RPC_MISMATCH);
!         *(r++) = htonl (RPC_MSG_VERSION);
!         *(r++) = htonl (RPC_MSG_VERSION);
          goto send_reply;
        }
+       p++;
  
!       program = ntohl (*p);
!       p++;
        switch (program)
        {
        case MOUNTPROG:
***************
*** 109,152 ****
          break;
  
        default:
!         /* Program unavailable */
!         *r++ = xid;
!         *r++ = htonl (REPLY);
!         *r++ = htonl (MSG_ACCEPTED);
!         *r++ = htonl (AUTH_NULL);
!         *r++ = htonl (0);
!         *r++ = htonl (PROG_UNAVAIL);
          goto send_reply;
        }
  
!       if (ntohl (*p++) != version)
        {
!         /* Program mismatch */
!         *r++ = xid;
!         *r++ = htonl (REPLY);
!         *r++ = htonl (MSG_ACCEPTED);
!         *r++ = htonl (AUTH_NULL);
!         *r++ = htonl (0);
!         *r++ = htonl (PROG_MISMATCH);
!         *r++ = htonl (version);
!         *r++ = htonl (version);
          goto send_reply;
        }
  
!       procedure = htonl (*p++);
        if (procedure < table->min
          || procedure > table->max
          || table->procs[procedure - table->min].func == 0)
        {
!         /* Procedure unavailable */
!         *r++ = xid;
!         *r++ = htonl (REPLY);
!         *r++ = htonl (MSG_ACCEPTED);
!         *r++ = htonl (AUTH_NULL);
!         *r++ = htonl (0);
!         *r++ = htonl (PROC_UNAVAIL);
!         *r++ = htonl (table->min);
!         *r++ = htonl (table->max);
          goto send_reply;
        }
        proc = &table->procs[procedure - table->min];
--- 112,157 ----
          break;
  
        default:
!         /* Program unavailable.  */
!         *(r++) = xid;
!         *(r++) = htonl (REPLY);
!         *(r++) = htonl (MSG_ACCEPTED);
!         *(r++) = htonl (AUTH_NULL);
!         *(r++) = htonl (0);
!         *(r++) = htonl (PROG_UNAVAIL);
          goto send_reply;
        }
  
!       if (ntohl (*p) != version)
        {
!         /* Program mismatch.  */
!         *(r++) = xid;
!         *(r++) = htonl (REPLY);
!         *(r++) = htonl (MSG_ACCEPTED);
!         *(r++) = htonl (AUTH_NULL);
!         *(r++) = htonl (0);
!         *(r++) = htonl (PROG_MISMATCH);
!         *(r++) = htonl (version);
!         *(r++) = htonl (version);
          goto send_reply;
        }
+       p++;
  
!       procedure = htonl (*p);
!       p++;
        if (procedure < table->min
          || procedure > table->max
          || table->procs[procedure - table->min].func == 0)
        {
!         /* Procedure unavailable.  */
!         *(r++) = xid;
!         *(r++) = htonl (REPLY);
!         *(r++) = htonl (MSG_ACCEPTED);
!         *(r++) = htonl (AUTH_NULL);
!         *(r++) = htonl (0);
!         *(r++) = htonl (PROC_UNAVAIL);
!         *(r++) = htonl (table->min);
!         *(r++) = htonl (table->max);
          goto send_reply;
        }
        proc = &table->procs[procedure - table->min];
***************
*** 172,205 ****
            }
        }
  
!       /* Fill in beginning of reply */
!       *r++ = xid;
!       *r++ = htonl (REPLY);
!       *r++ = htonl (MSG_ACCEPTED);
!       *r++ = htonl (AUTH_NULL);
!       *r++ = htonl (0);
!       *r++ = htonl (SUCCESS);
        if (!proc->process_error)
!       /* The function does its own error processing,
!          and we ignore its return value.  */
        (void) (*proc->func) (c, p, &r, version);
        else
        {
          if (c)
            {
!             /* Assume success for now and patch it later if necessary */
              int *errloc = r;
!             *r++ = htonl (0);
              /* Call processing function, its output after error code.  */
              err = (*proc->func) (c, p, &r, version);
              if (err)
                {
                  r = errloc;   /* Back up, patch error code, discard rest.  */
!                 *r++ = htonl (nfs_error_trans (err, version));
                }
            }
          else
!           *r++ = htonl (nfs_error_trans (ESTALE, version));
        }
  
        cred_rele (cred);
--- 177,210 ----
            }
        }
  
!       /* Fill in beginning of reply.  */
!       *(r++) = xid;
!       *(r++) = htonl (REPLY);
!       *(r++) = htonl (MSG_ACCEPTED);
!       *(r++) = htonl (AUTH_NULL);
!       *(r++) = htonl (0);
!       *(r++) = htonl (SUCCESS);
        if (!proc->process_error)
!       /* The function does its own error processing, and we ignore
!          its return value.  */
        (void) (*proc->func) (c, p, &r, version);
        else
        {
          if (c)
            {
!             /* Assume success for now and patch it later if necessary.  */
              int *errloc = r;
!             *(r++) = htonl (0);
              /* Call processing function, its output after error code.  */
              err = (*proc->func) (c, p, &r, version);
              if (err)
                {
                  r = errloc;   /* Back up, patch error code, discard rest.  */
!                 *(r++) = htonl (nfs_error_trans (err, version));
                }
            }
          else
!           *(r++) = htonl (nfs_error_trans (ESTALE, version));
        }
  
        cred_rele (cred);
***************
*** 212,218 ****
  
      repost_reply:
        sendto (fd, cr->data, cr->len, 0,
!             (struct sockaddr *)&sender, addrlen);
        release_cached_reply (cr);
      }
  }
--- 217,223 ----
  
      repost_reply:
        sendto (fd, cr->data, cr->len, 0,
!             (struct sockaddr *) &sender, addrlen);
        release_cached_reply (cr);
      }
  }
Index: hurd/nfsd/ops.c
diff -c hurd/nfsd/ops.c:1.7 hurd/nfsd/ops.c:1.8
*** hurd/nfsd/ops.c:1.7 Sun Feb 25 23:15:43 2001
--- hurd/nfsd/ops.c     Sun Sep 29 11:12:48 2002
***************
*** 1,5 ****
! /* NFS daemon protocol operations
!    Copyright (C) 1996, 2001 Free Software Foundation, Inc.
     Written by Michael I. Bushnell, p/BSG.
  
     This file is part of the GNU Hurd.
--- 1,5 ----
! /* ops.c NFS daemon protocol operations.
!    Copyright (C) 1996, 2001, 2002 Free Software Foundation, Inc.
     Written by Michael I. Bushnell, p/BSG.
  
     This file is part of the GNU Hurd.
***************
*** 69,76 ****
    if (err)
      return err;
  
!   uid = ntohl (*p++);
!   gid = ntohl (*p++);
    if (uid == -1)
      uid = st.st_uid;
    if (gid == -1)
--- 69,78 ----
    if (err)
      return err;
  
!   uid = ntohl (*p);
!   p++;
!   gid = ntohl (*p);
!   p++;
    if (uid == -1)
      uid = st.st_uid;
    if (gid == -1)
***************
*** 80,95 ****
    if (err)
      return err;
  
!   size = ntohl (*p++);
    if (size != -1 && size != st.st_size)
      err = file_set_size (port, size);
    if (err)
      return err;
  
!   atime.seconds = ntohl (*p++);
!   atime.microseconds = ntohl (*p++);
!   mtime.seconds = ntohl (*p++);
!   mtime.microseconds = ntohl (*p++);
  
    if (atime.seconds != -1 && atime.microseconds == -1)
      atime.microseconds = 0;
--- 82,102 ----
    if (err)
      return err;
  
!   size = ntohl (*p);
!   p++;
    if (size != -1 && size != st.st_size)
      err = file_set_size (port, size);
    if (err)
      return err;
  
!   atime.seconds = ntohl (*p);
!   p++;
!   atime.microseconds = ntohl (*p);
!   p++;
!   mtime.seconds = ntohl (*p);
!   p++;
!   mtime.microseconds = ntohl (*p);
!   p++;
  
    if (atime.seconds != -1 && atime.microseconds == -1)
      atime.microseconds = 0;
***************
*** 124,130 ****
    mode_t mode;
    struct stat st;
  
!   mode = ntohl (*p++);
    if (mode != -1)
      err = file_chmod (c->port, mode);
  
--- 131,138 ----
    mode_t mode;
    struct stat st;
  
!   mode = ntohl (*p);
!   p++;
    if (mode != -1)
      err = file_chmod (c->port, mode);
  
***************
*** 159,165 ****
                    &newport);
    free (name);
  
!   /* Block attempts to bounce out of this filesystem by any technique */
    if (!err
        && (do_retry != FS_RETRY_NORMAL
          || retry_name[0] != '\0'))
--- 167,173 ----
                    &newport);
    free (name);
  
!   /* Block attempts to bounce out of this filesystem by any technique.  */
    if (!err
        && (do_retry != FS_RETRY_NORMAL
          || retry_name[0] != '\0'))
***************
*** 189,195 ****
    mach_msg_type_number_t len = sizeof (buf);
    error_t err;
  
!   /* Shamelessly copied from the libc readlink */
    err = file_get_translator (c->port, &transp, &len);
    if (err)
      {
--- 197,203 ----
    mach_msg_type_number_t len = sizeof (buf);
    error_t err;
  
!   /* Shamelessly copied from the libc readlink.  */
    err = file_get_translator (c->port, &transp, &len);
    if (err)
      {
***************
*** 215,221 ****
  static size_t
  count_read_buffersize (int *p, int version)
  {
!   return ntohl (*++p);                /* skip OFFSET, return COUNT */
  }
  
  static error_t
--- 223,230 ----
  static size_t
  count_read_buffersize (int *p, int version)
  {
!   p++;                        /* Skip OFFSET.  */
!   return ntohl (*p);  /* Return COUNT.  */
  }
  
  static error_t
***************
*** 231,238 ****
    struct stat st;
    error_t err;
  
!   offset = ntohl (*p++);
!   count = ntohl (*p++);
  
    err = io_read (c->port, &bp, &buflen, offset, count);
    if (err)
--- 240,249 ----
    struct stat st;
    error_t err;
  
!   offset = ntohl (*p);
!   p++;
!   count = ntohl (*p);
!   p++;
  
    err = io_read (c->port, &bp, &buflen, offset, count);
    if (err)
***************
*** 269,277 ****
    struct stat st;
  
    p++;
!   offset = ntohl (*p++);
    p++;
-   count = ntohl (*p++);
    bp = (char *) *reply;
  
    while (count)
--- 280,290 ----
    struct stat st;
  
    p++;
!   offset = ntohl (*p);
!   p++;
!   p++;
!   count = ntohl (*p);
    p++;
    bp = (char *) *reply;
  
    while (count)
***************
*** 313,319 ****
    off_t size;
  
    p = decode_name (p, &name);
!   mode = ntohl (*p++);
  
    err = dir_lookup (c->port, name, O_NOTRANS | O_CREAT | O_TRUNC, mode,
                    &do_retry, retry_name, &newport);
--- 326,333 ----
    off_t size;
  
    p = decode_name (p, &name);
!   mode = ntohl (*p);
!   p++;
  
    err = dir_lookup (c->port, name, O_NOTRANS | O_CREAT | O_TRUNC, mode,
                    &do_retry, retry_name, &newport);
***************
*** 331,341 ****
      goto errout;
  
    /* NetBSD ignores most of the setattr fields given; that's good enough
!      for me too. */
  
!   p++, p++;                   /* skip uid and gid */
  
!   size = ntohl (*p++);
    if (size != -1 && size != st.st_size)
      {
        err = file_set_size (newport, size);
--- 345,356 ----
      goto errout;
  
    /* NetBSD ignores most of the setattr fields given; that's good enough
!      for me too.  */
  
!   p++, p++;                   /* Skip uid and gid.  */
  
!   size = ntohl (*p);
!   p++;
    if (size != -1 && size != st.st_size)
      {
        err = file_set_size (newport, size);
***************
*** 344,350 ****
    if (err)
      goto errout;
  
!   /* ignore times */
  
    if (statchanged)
      err = io_stat (newport, &st);
--- 359,365 ----
    if (err)
      goto errout;
  
!   /* Ignore times.  */
  
    if (statchanged)
      err = io_stat (newport, &st);
***************
*** 444,450 ****
  
    p = decode_name (p, &name);
    p = decode_name (p, &target);
!   mode = ntohl (*p++);
    if (mode == -1)
      mode = 0777;
  
--- 459,466 ----
  
    p = decode_name (p, &name);
    p = decode_name (p, &target);
!   mode = ntohl (*p);
!   p++;
    if (mode == -1)
      mode = 0777;
  
***************
*** 487,493 ****
    error_t err;
  
    p = decode_name (p, &name);
!   mode = ntohl (*p++);
  
    err = dir_mkdir (c->port, name, mode);
  
--- 503,510 ----
    error_t err;
  
    p = decode_name (p, &name);
!   mode = ntohl (*p);
!   p++;
  
    err = dir_mkdir (c->port, name, mode);
  
***************
*** 507,513 ****
    if (err)
      return err;
  
!   /* Ignore the rest of the sattr structure */
  
    if (!err)
      err = io_stat (newport, &st);
--- 524,530 ----
    if (err)
      return err;
  
!   /* Ignore the rest of the sattr structure.  */
  
    if (!err)
      err = io_stat (newport, &st);
***************
*** 555,562 ****
    int *replystart;
    int *r;
  
!   cookie = ntohl (*p++);
!   count = ntohl (*p++);
  
    buf = (char *) 0;
    bufsize = 0;
--- 572,581 ----
    int *replystart;
    int *r;
  
!   cookie = ntohl (*p);
!   p++;
!   count = ntohl (*p);
!   p++;
  
    buf = (char *) 0;
    bufsize = 0;
***************
*** 572,579 ****
  
    if (nentries == 0)
      {
!       *r++ = htonl (0);       /* no entry */
!       *r++ = htonl (1);       /* EOF */
      }
    else
      {
--- 591,598 ----
  
    if (nentries == 0)
      {
!       *(r++) = htonl (0);     /* No entry.  */
!       *(r++) = htonl (1);     /* EOF.  */
      }
    else
      {
***************
*** 583,595 ****
            && (char *)reply < (char *)replystart + count);
           i++, dp = (struct dirent *) ((char *)dp + dp->d_reclen))
        {
!         *r++ = htonl (1); /* entry present */
!         *r++ = htonl (dp->d_ino);
          r = encode_string (r, dp->d_name);
!         *r++ = htonl (i + cookie + 1); /* next entry */
        }
!       *r++ = htonl (0);               /* no more entries */
!       *r++ = htonl (0);               /* not EOF */
      }
  
    *reply = r;
--- 602,614 ----
            && (char *)reply < (char *)replystart + count);
           i++, dp = (struct dirent *) ((char *)dp + dp->d_reclen))
        {
!         *(r++) = htonl (1);                   /* Entry present.  */
!         *(r++) = htonl (dp->d_ino);
          r = encode_string (r, dp->d_name);
!         *(r++) = htonl (i + cookie + 1);      /* Next entry.  */
        }
!       *(r++) = htonl (0);                     /* No more entries.  */
!       *(r++) = htonl (0);                     /* Not EOF.  */
      }
  
    *reply = r;
***************
*** 603,609 ****
  static size_t
  count_readdir_buffersize (int *p, int version)
  {
!   return ntohl (*++p);                /* skip COOKIE; return COUNT  */
  }
  
  static error_t
--- 622,629 ----
  static size_t
  count_readdir_buffersize (int *p, int version)
  {
!   p++;                        /* Skip COOKIE.  */
!   return ntohl (*p);  /* Return COUNT.  */
  }
  
  static error_t
***************
*** 656,664 ****
  {
    int prog, vers, prot;
  
!   prog = ntohl (*p++);
!   vers = ntohl (*p++);
!   prot = ntohl (*p++);
  
    if (prot != IPPROTO_UDP)
      *(*reply)++ = htonl (0);
--- 676,687 ----
  {
    int prog, vers, prot;
  
!   prog = ntohl (*p);
!   p++;
!   vers = ntohl (*p);
!   p++;
!   prot = ntohl (*p);
!   p++;
  
    if (prot != IPPROTO_UDP)
      *(*reply)++ = htonl (0);
***************
*** 676,692 ****
  
  struct proctable nfs2table =
  {
!   NFS2PROC_NULL,              /* first proc */
!   NFS2PROC_STATFS,            /* last proc */
    {
      { op_null, 0, 0, 0},
      { op_getattr, 0, 1, 1},
      { op_setattr, 0, 1, 1},
!     { 0, 0, 0, 0 },           /* deprecated NFSPROC_ROOT */
      { op_lookup, 0, 1, 1},
      { op_readlink, 0, 1, 1},
      { op_read, count_read_buffersize, 1, 1},
!     { 0, 0, 0, 0 },           /* nonexistent NFSPROC_WRITECACHE */
      { op_write, 0, 1, 1},
      { op_create, 0, 1, 1},
      { op_remove, 0, 1, 1},
--- 699,715 ----
  
  struct proctable nfs2table =
  {
!   NFS2PROC_NULL,              /* First proc.  */
!   NFS2PROC_STATFS,            /* Last proc.  */
    {
      { op_null, 0, 0, 0},
      { op_getattr, 0, 1, 1},
      { op_setattr, 0, 1, 1},
!     { 0, 0, 0, 0 },           /* Deprecated NFSPROC_ROOT.  */
      { op_lookup, 0, 1, 1},
      { op_readlink, 0, 1, 1},
      { op_read, count_read_buffersize, 1, 1},
!     { 0, 0, 0, 0 },           /* Nonexistent NFSPROC_WRITECACHE.  */
      { op_write, 0, 1, 1},
      { op_create, 0, 1, 1},
      { op_remove, 0, 1, 1},
***************
*** 703,710 ****
  
  struct proctable mounttable =
  {
!   MOUNTPROC_NULL,             /* first proc */
!   MOUNTPROC_EXPORT,           /* last proc */
    {
      { op_null, 0, 0, 0},
      { op_mnt, 0, 0, 1},
--- 726,733 ----
  
  struct proctable mounttable =
  {
!   MOUNTPROC_NULL,             /* First proc.  */
!   MOUNTPROC_EXPORT,           /* Last proc.  */
    {
      { op_null, 0, 0, 0},
      { op_mnt, 0, 0, 1},
***************
*** 717,724 ****
  
  struct proctable pmaptable =
  {
!   PMAPPROC_NULL,              /* first proc */
!   PMAPPROC_CALLIT,            /* last proc */
    {
      { op_null, 0, 0, 0},
      { 0, 0, 0, 0},            /* PMAPPROC_SET */
--- 740,747 ----
  
  struct proctable pmaptable =
  {
!   PMAPPROC_NULL,              /* First proc.  */
!   PMAPPROC_CALLIT,            /* Last proc.  */
    {
      { op_null, 0, 0, 0},
      { 0, 0, 0, 0},            /* PMAPPROC_SET */
Index: hurd/nfsd/xdr.c
diff -c hurd/nfsd/xdr.c:1.4 hurd/nfsd/xdr.c:1.5
*** hurd/nfsd/xdr.c:1.4 Wed Aug 14 14:10:19 1996
--- hurd/nfsd/xdr.c     Sun Sep 29 11:12:48 2002
***************
*** 1,5 ****
! /* XDR packing and unpacking in nfsd
!    Copyright (C) 1996 Free Software Foundation, Inc.
     Written by Michael I. Bushnell, p/BSG.
  
     This file is part of the GNU Hurd.
--- 1,5 ----
! /* xdr.c - XDR packing and unpacking in nfsd.
!    Copyright (C) 1996, 2002 Free Software Foundation, Inc.
     Written by Michael I. Bushnell, p/BSG.
  
     This file is part of the GNU Hurd.
***************
*** 23,29 ****
  #include <string.h>
  #include "nfsd.h"
  
! /* Any better ideas? */
  static int
  hurd_mode_to_nfs_mode (mode_t m)
  {
--- 23,29 ----
  #include <string.h>
  #include "nfsd.h"
  
! /* Any better ideas?  */
  static int
  hurd_mode_to_nfs_mode (mode_t m)
  {
***************
*** 61,143 ****
      }
  }
  
! /* Encode ST into P and return the next thing to come after it. */
  int *
  encode_fattr (int *p, struct stat *st, int version)
  {
!   *p++ = htonl (hurd_mode_to_nfs_type (st->st_mode, version));
!   *p++ = htonl (hurd_mode_to_nfs_mode (st->st_mode));
!   *p++ = htonl (st->st_nlink);
!   *p++ = htonl (st->st_uid);
!   *p++ = htonl (st->st_gid);
!   *p++ = htonl (st->st_size);
!   *p++ = htonl (st->st_blksize);
!   *p++ = htonl (st->st_rdev);
!   *p++ = htonl (st->st_blocks);
!   *p++ = htonl (st->st_fsid);
!   *p++ = htonl (st->st_ino);
!   *p++ = htonl (st->st_atime);
!   *p++ = htonl (st->st_atime_usec);
!   *p++ = htonl (st->st_mtime);
!   *p++ = htonl (st->st_mtime_usec);
!   *p++ = htonl (st->st_ctime);
!   *p++ = htonl (st->st_ctime_usec);
    return p;
  }
  
! /* Decode P into NAME and return the next thing to come after it. */
  int *
  decode_name (int *p, char **name)
  {
    int len;
    
!   len = ntohl (*p++);
    *name = malloc (len + 1);
!   bcopy (p, *name, len);
    (*name)[len] = '\0';
    return p + INTSIZE (len);
  }
  
! /* Encode HANDLE into P and return the next thing to come after it. */
  int *
  encode_fhandle (int *p, char *handle)
  {
!   bcopy (handle, p, NFS2_FHSIZE);
    return p + INTSIZE (NFS2_FHSIZE);
  }
  
! /* Encode STRING into P and return the next thing to come after it. */
  int *
  encode_string (int *p, char *string)
  {
    return encode_data (p, string, strlen (string));
  }
  
! /* Encode DATA into P and return the next thing to come after it. */
  int *
  encode_data (int *p, char *data, size_t len)
  {
    int nints = INTSIZE (len);
    
    p[nints] = 0;
!   *p++ = htonl (len);
!   bcopy (data, p, len);
    return p + nints;
  }
  
! /* Encode ST into P and return the next thing to come after it. */
  int *
  encode_statfs (int *p, struct statfs *st)
  {
!   *p++ = st->f_bsize;
!   *p++ = st->f_bsize;
!   *p++ = st->f_blocks;
!   *p++ = st->f_bfree;
!   *p++ = st->f_bavail;
    return p;
  }
  
! /* Return an NFS error corresponding to Hurd error ERR. */
  int
  nfs_error_trans (error_t err, int version)
  {
--- 61,144 ----
      }
  }
  
! /* Encode ST into P and return the next thing to come after it.  */
  int *
  encode_fattr (int *p, struct stat *st, int version)
  {
!   *(p++) = htonl (hurd_mode_to_nfs_type (st->st_mode, version));
!   *(p++) = htonl (hurd_mode_to_nfs_mode (st->st_mode));
!   *(p++) = htonl (st->st_nlink);
!   *(p++) = htonl (st->st_uid);
!   *(p++) = htonl (st->st_gid);
!   *(p++) = htonl (st->st_size);
!   *(p++) = htonl (st->st_blksize);
!   *(p++) = htonl (st->st_rdev);
!   *(p++) = htonl (st->st_blocks);
!   *(p++) = htonl (st->st_fsid);
!   *(p++) = htonl (st->st_ino);
!   *(p++) = htonl (st->st_atime);
!   *(p++) = htonl (st->st_atime_usec);
!   *(p++) = htonl (st->st_mtime);
!   *(p++) = htonl (st->st_mtime_usec);
!   *(p++) = htonl (st->st_ctime);
!   *(p++) = htonl (st->st_ctime_usec);
    return p;
  }
  
! /* Decode P into NAME and return the next thing to come after it.  */
  int *
  decode_name (int *p, char **name)
  {
    int len;
    
!   len = ntohl (*p);
!   p++;
    *name = malloc (len + 1);
!   memcpy (*name, p, len);
    (*name)[len] = '\0';
    return p + INTSIZE (len);
  }
  
! /* Encode HANDLE into P and return the next thing to come after it.  */
  int *
  encode_fhandle (int *p, char *handle)
  {
!   memcpy (p, handle, NFS2_FHSIZE);
    return p + INTSIZE (NFS2_FHSIZE);
  }
  
! /* Encode STRING into P and return the next thing to come after it.  */
  int *
  encode_string (int *p, char *string)
  {
    return encode_data (p, string, strlen (string));
  }
  
! /* Encode DATA into P and return the next thing to come after it.  */
  int *
  encode_data (int *p, char *data, size_t len)
  {
    int nints = INTSIZE (len);
    
    p[nints] = 0;
!   *(p++) = htonl (len);
!   memcpy (p, data, len);
    return p + nints;
  }
  
! /* Encode ST into P and return the next thing to come after it.  */
  int *
  encode_statfs (int *p, struct statfs *st)
  {
!   *(p++) = st->f_bsize;
!   *(p++) = st->f_bsize;
!   *(p++) = st->f_blocks;
!   *(p++) = st->f_bfree;
!   *(p++) = st->f_bavail;
    return p;
  }
  
! /* Return an NFS error corresponding to Hurd error ERR.  */
  int
  nfs_error_trans (error_t err, int version)
  {
***************
*** 206,218 ****
          return NFSERR_INVAL;
          
        case EOPNOTSUPP:
!         return NFSERR_NOTSUPP; /* are we sure here? */
          
        default:
          return NFSERR_IO;
        }
      }
  }      
-       
-       
-      
--- 207,216 ----
          return NFSERR_INVAL;
          
        case EOPNOTSUPP:
!         return NFSERR_NOTSUPP;        /* Are we sure here?  */
          
        default:
          return NFSERR_IO;
        }
      }
  }      




reply via email to

[Prev in Thread] Current Thread [Next in Thread]