/[hurd]/hurd/nfsd/ops.c
ViewVC logotype

Diff of /hurd/nfsd/ops.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.7 by roland, Mon Feb 26 04:15:43 2001 UTC revision 1.8 by marcus, Sun Sep 29 15:12:48 2002 UTC
# Line 1  Line 1 
1  /* NFS daemon protocol operations  /* ops.c NFS daemon protocol operations.
2     Copyright (C) 1996, 2001 Free Software Foundation, Inc.     Copyright (C) 1996, 2001, 2002 Free Software Foundation, Inc.
3     Written by Michael I. Bushnell, p/BSG.     Written by Michael I. Bushnell, p/BSG.
4    
5     This file is part of the GNU Hurd.     This file is part of the GNU Hurd.
# Line 69  complete_setattr (mach_port_t port, Line 69  complete_setattr (mach_port_t port,
69    if (err)    if (err)
70      return err;      return err;
71    
72    uid = ntohl (*p++);    uid = ntohl (*p);
73    gid = ntohl (*p++);    p++;
74      gid = ntohl (*p);
75      p++;
76    if (uid == -1)    if (uid == -1)
77      uid = st.st_uid;      uid = st.st_uid;
78    if (gid == -1)    if (gid == -1)
# Line 80  complete_setattr (mach_port_t port, Line 82  complete_setattr (mach_port_t port,
82    if (err)    if (err)
83      return err;      return err;
84    
85    size = ntohl (*p++);    size = ntohl (*p);
86      p++;
87    if (size != -1 && size != st.st_size)    if (size != -1 && size != st.st_size)
88      err = file_set_size (port, size);      err = file_set_size (port, size);
89    if (err)    if (err)
90      return err;      return err;
91    
92    atime.seconds = ntohl (*p++);    atime.seconds = ntohl (*p);
93    atime.microseconds = ntohl (*p++);    p++;
94    mtime.seconds = ntohl (*p++);    atime.microseconds = ntohl (*p);
95    mtime.microseconds = ntohl (*p++);    p++;
96      mtime.seconds = ntohl (*p);
97      p++;
98      mtime.microseconds = ntohl (*p);
99      p++;
100    
101    if (atime.seconds != -1 && atime.microseconds == -1)    if (atime.seconds != -1 && atime.microseconds == -1)
102      atime.microseconds = 0;      atime.microseconds = 0;
# Line 124  op_setattr (struct cache_handle *c, Line 131  op_setattr (struct cache_handle *c,
131    mode_t mode;    mode_t mode;
132    struct stat st;    struct stat st;
133    
134    mode = ntohl (*p++);    mode = ntohl (*p);
135      p++;
136    if (mode != -1)    if (mode != -1)
137      err = file_chmod (c->port, mode);      err = file_chmod (c->port, mode);
138    
# Line 159  op_lookup (struct cache_handle *c, Line 167  op_lookup (struct cache_handle *c,
167                      &newport);                      &newport);
168    free (name);    free (name);
169    
170    /* Block attempts to bounce out of this filesystem by any technique */    /* Block attempts to bounce out of this filesystem by any technique.  */
171    if (!err    if (!err
172        && (do_retry != FS_RETRY_NORMAL        && (do_retry != FS_RETRY_NORMAL
173            || retry_name[0] != '\0'))            || retry_name[0] != '\0'))
# Line 189  op_readlink (struct cache_handle *c, Line 197  op_readlink (struct cache_handle *c,
197    mach_msg_type_number_t len = sizeof (buf);    mach_msg_type_number_t len = sizeof (buf);
198    error_t err;    error_t err;
199    
200    /* Shamelessly copied from the libc readlink */    /* Shamelessly copied from the libc readlink.  */
201    err = file_get_translator (c->port, &transp, &len);    err = file_get_translator (c->port, &transp, &len);
202    if (err)    if (err)
203      {      {
# Line 215  op_readlink (struct cache_handle *c, Line 223  op_readlink (struct cache_handle *c,
223  static size_t  static size_t
224  count_read_buffersize (int *p, int version)  count_read_buffersize (int *p, int version)
225  {  {
226    return ntohl (*++p);          /* skip OFFSET, return COUNT */    p++;                  /* Skip OFFSET.  */
227      return ntohl (*p);    /* Return COUNT.  */
228  }  }
229    
230  static error_t  static error_t
# Line 231  op_read (struct cache_handle *c, Line 240  op_read (struct cache_handle *c,
240    struct stat st;    struct stat st;
241    error_t err;    error_t err;
242    
243    offset = ntohl (*p++);    offset = ntohl (*p);
244    count = ntohl (*p++);    p++;
245      count = ntohl (*p);
246      p++;
247    
248    err = io_read (c->port, &bp, &buflen, offset, count);    err = io_read (c->port, &bp, &buflen, offset, count);
249    if (err)    if (err)
# Line 269  op_write (struct cache_handle *c, Line 280  op_write (struct cache_handle *c,
280    struct stat st;    struct stat st;
281    
282    p++;    p++;
283    offset = ntohl (*p++);    offset = ntohl (*p);
284      p++;
285      p++;
286      count = ntohl (*p);
287    p++;    p++;
   count = ntohl (*p++);  
288    bp = (char *) *reply;    bp = (char *) *reply;
289    
290    while (count)    while (count)
# Line 313  op_create (struct cache_handle *c, Line 326  op_create (struct cache_handle *c,
326    off_t size;    off_t size;
327    
328    p = decode_name (p, &name);    p = decode_name (p, &name);
329    mode = ntohl (*p++);    mode = ntohl (*p);
330      p++;
331    
332    err = dir_lookup (c->port, name, O_NOTRANS | O_CREAT | O_TRUNC, mode,    err = dir_lookup (c->port, name, O_NOTRANS | O_CREAT | O_TRUNC, mode,
333                      &do_retry, retry_name, &newport);                      &do_retry, retry_name, &newport);
# Line 331  op_create (struct cache_handle *c, Line 345  op_create (struct cache_handle *c,
345      goto errout;      goto errout;
346    
347    /* NetBSD ignores most of the setattr fields given; that's good enough    /* NetBSD ignores most of the setattr fields given; that's good enough
348       for me too. */       for me too.  */
349    
350    p++, p++;                     /* skip uid and gid */    p++, p++;                     /* Skip uid and gid.  */
351    
352    size = ntohl (*p++);    size = ntohl (*p);
353      p++;
354    if (size != -1 && size != st.st_size)    if (size != -1 && size != st.st_size)
355      {      {
356        err = file_set_size (newport, size);        err = file_set_size (newport, size);
# Line 344  op_create (struct cache_handle *c, Line 359  op_create (struct cache_handle *c,
359    if (err)    if (err)
360      goto errout;      goto errout;
361    
362    /* ignore times */    /* Ignore times.  */
363    
364    if (statchanged)    if (statchanged)
365      err = io_stat (newport, &st);      err = io_stat (newport, &st);
# Line 444  op_symlink (struct cache_handle *c, Line 459  op_symlink (struct cache_handle *c,
459    
460    p = decode_name (p, &name);    p = decode_name (p, &name);
461    p = decode_name (p, &target);    p = decode_name (p, &target);
462    mode = ntohl (*p++);    mode = ntohl (*p);
463      p++;
464    if (mode == -1)    if (mode == -1)
465      mode = 0777;      mode = 0777;
466    
# Line 487  op_mkdir (struct cache_handle *c, Line 503  op_mkdir (struct cache_handle *c,
503    error_t err;    error_t err;
504    
505    p = decode_name (p, &name);    p = decode_name (p, &name);
506    mode = ntohl (*p++);    mode = ntohl (*p);
507      p++;
508    
509    err = dir_mkdir (c->port, name, mode);    err = dir_mkdir (c->port, name, mode);
510    
# Line 507  op_mkdir (struct cache_handle *c, Line 524  op_mkdir (struct cache_handle *c,
524    if (err)    if (err)
525      return err;      return err;
526    
527    /* Ignore the rest of the sattr structure */    /* Ignore the rest of the sattr structure.  */
528    
529    if (!err)    if (!err)
530      err = io_stat (newport, &st);      err = io_stat (newport, &st);
# Line 555  op_readdir (struct cache_handle *c, Line 572  op_readdir (struct cache_handle *c,
572    int *replystart;    int *replystart;
573    int *r;    int *r;
574    
575    cookie = ntohl (*p++);    cookie = ntohl (*p);
576    count = ntohl (*p++);    p++;
577      count = ntohl (*p);
578      p++;
579    
580    buf = (char *) 0;    buf = (char *) 0;
581    bufsize = 0;    bufsize = 0;
# Line 572  op_readdir (struct cache_handle *c, Line 591  op_readdir (struct cache_handle *c,
591    
592    if (nentries == 0)    if (nentries == 0)
593      {      {
594        *r++ = htonl (0); /* no entry */        *(r++) = htonl (0);       /* No entry.  */
595        *r++ = htonl (1); /* EOF */        *(r++) = htonl (1);       /* EOF.  */
596      }      }
597    else    else
598      {      {
# Line 583  op_readdir (struct cache_handle *c, Line 602  op_readdir (struct cache_handle *c,
602              && (char *)reply < (char *)replystart + count);              && (char *)reply < (char *)replystart + count);
603             i++, dp = (struct dirent *) ((char *)dp + dp->d_reclen))             i++, dp = (struct dirent *) ((char *)dp + dp->d_reclen))
604          {          {
605            *r++ = htonl (1); /* entry present */            *(r++) = htonl (1);                   /* Entry present.  */
606            *r++ = htonl (dp->d_ino);            *(r++) = htonl (dp->d_ino);
607            r = encode_string (r, dp->d_name);            r = encode_string (r, dp->d_name);
608            *r++ = htonl (i + cookie + 1); /* next entry */            *(r++) = htonl (i + cookie + 1);      /* Next entry.  */
609          }          }
610        *r++ = htonl (0);         /* no more entries */        *(r++) = htonl (0);                       /* No more entries.  */
611        *r++ = htonl (0);         /* not EOF */        *(r++) = htonl (0);                       /* Not EOF.  */
612      }      }
613    
614    *reply = r;    *reply = r;
# Line 603  op_readdir (struct cache_handle *c, Line 622  op_readdir (struct cache_handle *c,
622  static size_t  static size_t
623  count_readdir_buffersize (int *p, int version)  count_readdir_buffersize (int *p, int version)
624  {  {
625    return ntohl (*++p);          /* skip COOKIE; return COUNT  */    p++;                  /* Skip COOKIE.  */
626      return ntohl (*p);    /* Return COUNT.  */
627  }  }
628    
629  static error_t  static error_t
# Line 656  op_getport (struct cache_handle *c, Line 676  op_getport (struct cache_handle *c,
676  {  {
677    int prog, vers, prot;    int prog, vers, prot;
678    
679    prog = ntohl (*p++);    prog = ntohl (*p);
680    vers = ntohl (*p++);    p++;
681    prot = ntohl (*p++);    vers = ntohl (*p);
682      p++;
683      prot = ntohl (*p);
684      p++;
685    
686    if (prot != IPPROTO_UDP)    if (prot != IPPROTO_UDP)
687      *(*reply)++ = htonl (0);      *(*reply)++ = htonl (0);
# Line 676  op_getport (struct cache_handle *c, Line 699  op_getport (struct cache_handle *c,
699    
700  struct proctable nfs2table =  struct proctable nfs2table =
701  {  {
702    NFS2PROC_NULL,                /* first proc */    NFS2PROC_NULL,                /* First proc.  */
703    NFS2PROC_STATFS,              /* last proc */    NFS2PROC_STATFS,              /* Last proc.  */
704    {    {
705      { op_null, 0, 0, 0},      { op_null, 0, 0, 0},
706      { op_getattr, 0, 1, 1},      { op_getattr, 0, 1, 1},
707      { op_setattr, 0, 1, 1},      { op_setattr, 0, 1, 1},
708      { 0, 0, 0, 0 },             /* deprecated NFSPROC_ROOT */      { 0, 0, 0, 0 },             /* Deprecated NFSPROC_ROOT.  */
709      { op_lookup, 0, 1, 1},      { op_lookup, 0, 1, 1},
710      { op_readlink, 0, 1, 1},      { op_readlink, 0, 1, 1},
711      { op_read, count_read_buffersize, 1, 1},      { op_read, count_read_buffersize, 1, 1},
712      { 0, 0, 0, 0 },             /* nonexistent NFSPROC_WRITECACHE */      { 0, 0, 0, 0 },             /* Nonexistent NFSPROC_WRITECACHE.  */
713      { op_write, 0, 1, 1},      { op_write, 0, 1, 1},
714      { op_create, 0, 1, 1},      { op_create, 0, 1, 1},
715      { op_remove, 0, 1, 1},      { op_remove, 0, 1, 1},
# Line 703  struct proctable nfs2table = Line 726  struct proctable nfs2table =
726    
727  struct proctable mounttable =  struct proctable mounttable =
728  {  {
729    MOUNTPROC_NULL,               /* first proc */    MOUNTPROC_NULL,               /* First proc.  */
730    MOUNTPROC_EXPORT,             /* last proc */    MOUNTPROC_EXPORT,             /* Last proc.  */
731    {    {
732      { op_null, 0, 0, 0},      { op_null, 0, 0, 0},
733      { op_mnt, 0, 0, 1},      { op_mnt, 0, 0, 1},
# Line 717  struct proctable mounttable = Line 740  struct proctable mounttable =
740    
741  struct proctable pmaptable =  struct proctable pmaptable =
742  {  {
743    PMAPPROC_NULL,                /* first proc */    PMAPPROC_NULL,                /* First proc.  */
744    PMAPPROC_CALLIT,              /* last proc */    PMAPPROC_CALLIT,              /* Last proc.  */
745    {    {
746      { op_null, 0, 0, 0},      { op_null, 0, 0, 0},
747      { 0, 0, 0, 0},              /* PMAPPROC_SET */      { 0, 0, 0, 0},              /* PMAPPROC_SET */

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26