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

Diff of /hurd/nfs/ops.c

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

revision 1.43 by roland, Mon May 13 22:23:48 2002 UTC revision 1.44 by marcus, Sun Sep 29 15:11:59 2002 UTC
# Line 1  Line 1 
1  /* Libnetfs callbacks for node operations in NFS client  /* ops.c - Libnetfs callbacks for node operations in NFS client.
2     Copyright (C) 1994,95,96,97,99,2002 Free Software Foundation, Inc.     Copyright (C) 1994,95,96,97,99,2002 Free Software Foundation, Inc.
3    
4     This program is free software; you can redistribute it and/or     This program is free software; you can redistribute it and/or
# Line 91  process_returned_stat (struct node *np, Line 91  process_returned_stat (struct node *np,
91      {      {
92        int attrs_exist;        int attrs_exist;
93    
94        attrs_exist = ntohl (*p++);        attrs_exist = ntohl (*p);
95          p++;
96        if (attrs_exist)        if (attrs_exist)
97          p = register_fresh_stat (np, p);          p = register_fresh_stat (np, p);
98        else if (mod)        else if (mod)
# Line 106  process_returned_stat (struct node *np, Line 107  process_returned_stat (struct node *np,
107     version 2, this is just register_fresh_stat.  In version 3, it does     version 2, this is just register_fresh_stat.  In version 3, it does
108     the wcc_data interpretation too.  If this follows an operation that     the wcc_data interpretation too.  If this follows an operation that
109     we expect has modified the attributes, MOD should be set.     we expect has modified the attributes, MOD should be set.
110     (This unpacks the wcc_data XDR type.) */     (This unpacks the wcc_data XDR type.)  */
111  int *  int *
112  process_wcc_stat (struct node *np, int *p, int mod)  process_wcc_stat (struct node *np, int *p, int mod)
113  {  {
# Line 117  process_wcc_stat (struct node *np, int * Line 118  process_wcc_stat (struct node *np, int *
118        int attrs_exist;        int attrs_exist;
119    
120        /* First the pre_op_attr */        /* First the pre_op_attr */
121        attrs_exist = ntohl (*p++);        attrs_exist = ntohl (*p);
122          p++;
123        if (attrs_exist)        if (attrs_exist)
124          {          {
125            /* Just skip them for now */            /* Just skip them for now */
# Line 133  process_wcc_stat (struct node *np, int * Line 135  process_wcc_stat (struct node *np, int *
135    
136    
137  /* Implement the netfs_validate_stat callback as described in  /* Implement the netfs_validate_stat callback as described in
138     <hurd/netfs.h>. */     <hurd/netfs.h>.  */
139  error_t  error_t
140  netfs_validate_stat (struct node *np, struct iouser *cred)  netfs_validate_stat (struct node *np, struct iouser *cred)
141  {  {
# Line 153  netfs_validate_stat (struct node *np, st Line 155  netfs_validate_stat (struct node *np, st
155    
156    err = conduct_rpc (&rpcbuf, &p);    err = conduct_rpc (&rpcbuf, &p);
157    if (!err)    if (!err)
158      err = nfs_error_trans (ntohl (*p++));      {
159          err = nfs_error_trans (ntohl (*p));
160          p++;
161        }
162    if (!err)    if (!err)
163      register_fresh_stat (np, p);      register_fresh_stat (np, p);
164    
# Line 162  netfs_validate_stat (struct node *np, st Line 167  netfs_validate_stat (struct node *np, st
167  }  }
168    
169  /* Implement the netfs_attempt_chown callback as described in  /* Implement the netfs_attempt_chown callback as described in
170     <hurd/netfs.h>. */     <hurd/netfs.h>.  */
171  error_t  error_t
172  netfs_attempt_chown (struct iouser *cred, struct node *np,  netfs_attempt_chown (struct iouser *cred, struct node *np,
173                       uid_t uid, gid_t gid)                       uid_t uid, gid_t gid)
# Line 179  netfs_attempt_chown (struct iouser *cred Line 184  netfs_attempt_chown (struct iouser *cred
184    p = xdr_encode_fhandle (p, &np->nn->handle);    p = xdr_encode_fhandle (p, &np->nn->handle);
185    p = xdr_encode_sattr_ids (p, uid, gid);    p = xdr_encode_sattr_ids (p, uid, gid);
186    if (protocol_version == 3)    if (protocol_version == 3)
187      *p++ = 0;                   /* guard_check == 0 */      *(p++) = 0;                 /* guard_check == 0 */
188    
189    err = conduct_rpc (&rpcbuf, &p);    err = conduct_rpc (&rpcbuf, &p);
190    if (!err)    if (!err)
191      {      {
192        err = nfs_error_trans (ntohl (*p++));        err = nfs_error_trans (ntohl (*p));
193          p++;
194        if (!err || protocol_version == 3)        if (!err || protocol_version == 3)
195          p = process_wcc_stat (np, p, !err);          p = process_wcc_stat (np, p, !err);
196      }      }
# Line 204  netfs_attempt_chauthor (struct iouser *c Line 210  netfs_attempt_chauthor (struct iouser *c
210  }  }
211    
212  /* Implement the netfs_attempt_chmod callback as described in  /* Implement the netfs_attempt_chmod callback as described in
213     <hurd/netfs.h>. */     <hurd/netfs.h>.  */
214  error_t  error_t
215  netfs_attempt_chmod (struct iouser *cred, struct node *np,  netfs_attempt_chmod (struct iouser *cred, struct node *np,
216                       mode_t mode)                       mode_t mode)
# Line 219  netfs_attempt_chmod (struct iouser *cred Line 225  netfs_attempt_chmod (struct iouser *cred
225        if (err)        if (err)
226          return err;          return err;
227    
228        /* Has the file type changed? (e.g. from symlink to directory) */        /* Has the file type changed? (e.g. from symlink to
229             directory).  */
230        if ((mode & S_IFMT) != (np->nn_stat.st_mode & S_IFMT))        if ((mode & S_IFMT) != (np->nn_stat.st_mode & S_IFMT))
231          {          {
232            char *f = 0;            char *f = 0;
# Line 258  netfs_attempt_chmod (struct iouser *cred Line 265  netfs_attempt_chmod (struct iouser *cred
265    p = xdr_encode_fhandle (p, &np->nn->handle);    p = xdr_encode_fhandle (p, &np->nn->handle);
266    p = xdr_encode_sattr_mode (p, mode);    p = xdr_encode_sattr_mode (p, mode);
267    if (protocol_version == 3)    if (protocol_version == 3)
268      *p++ = 0;                   /* guard check == 0 */      *(p++) = 0;                 /* guard check == 0 */
269    
270    err = conduct_rpc (&rpcbuf, &p);    err = conduct_rpc (&rpcbuf, &p);
271    if (!err)    if (!err)
272      {      {
273        err = nfs_error_trans (ntohl (*p++));        err = nfs_error_trans (ntohl (*p));
274          p++;
275        if (!err || protocol_version == 3)        if (!err || protocol_version == 3)
276          p = process_wcc_stat (np, p, !err);          p = process_wcc_stat (np, p, !err);
277      }      }
# Line 273  netfs_attempt_chmod (struct iouser *cred Line 281  netfs_attempt_chmod (struct iouser *cred
281  }  }
282    
283  /* Implement the netfs_attempt_chflags callback as described in  /* Implement the netfs_attempt_chflags callback as described in
284     <hurd/netfs.h>. */     <hurd/netfs.h>.  */
285  error_t  error_t
286  netfs_attempt_chflags (struct iouser *cred, struct node *np,  netfs_attempt_chflags (struct iouser *cred, struct node *np,
287                         int flags)                         int flags)
# Line 312  netfs_attempt_utimes (struct iouser *cre Line 320  netfs_attempt_utimes (struct iouser *cre
320                                atime ?: &current,                                atime ?: &current,
321                                mtime ?: &current);                                mtime ?: &current);
322    if (protocol_version == 3)    if (protocol_version == 3)
323      *p++ = 0;                   /* guard check == 0 */      *(p++) = 0;                 /* guard check == 0 */
324    
325    err = conduct_rpc (&rpcbuf, &p);    err = conduct_rpc (&rpcbuf, &p);
326    if (!err)    if (!err)
327      {      {
328        err = nfs_error_trans (ntohl (*p++));        err = nfs_error_trans (ntohl (*p));
329          p++;
330        if (!err || protocol_version == 3)        if (!err || protocol_version == 3)
331          p = process_wcc_stat (np, p, !err);          p = process_wcc_stat (np, p, !err);
332      }      }
# Line 327  netfs_attempt_utimes (struct iouser *cre Line 336  netfs_attempt_utimes (struct iouser *cre
336  }  }
337    
338  /* Implement the netfs_attempt_set_size callback as described in  /* Implement the netfs_attempt_set_size callback as described in
339     <hurd/netfs.h>. */     <hurd/netfs.h>.  */
340  error_t  error_t
341  netfs_attempt_set_size (struct iouser *cred, struct node *np,  netfs_attempt_set_size (struct iouser *cred, struct node *np,
342                          off_t size)                          off_t size)
# Line 344  netfs_attempt_set_size (struct iouser *c Line 353  netfs_attempt_set_size (struct iouser *c
353    p = xdr_encode_fhandle (p, &np->nn->handle);    p = xdr_encode_fhandle (p, &np->nn->handle);
354    p = xdr_encode_sattr_size (p, size);    p = xdr_encode_sattr_size (p, size);
355    if (protocol_version == 3)    if (protocol_version == 3)
356      *p++ = 0;                   /* guard_check == 0 */      *(p++) = 0;                 /* guard_check == 0 */
357    
358    err = conduct_rpc (&rpcbuf, &p);    err = conduct_rpc (&rpcbuf, &p);
359    if (!err)    if (!err)
360      {      {
361        err = nfs_error_trans (ntohl (*p++));        err = nfs_error_trans (ntohl (*p));
362          p++;
363        if (!err || protocol_version == 3)        if (!err || protocol_version == 3)
364          p = process_wcc_stat (np, p, !err);          p = process_wcc_stat (np, p, !err);
365      }      }
# Line 390  netfs_attempt_statfs (struct iouser *cre Line 400  netfs_attempt_statfs (struct iouser *cre
400    
401    err = conduct_rpc (&rpcbuf, &p);    err = conduct_rpc (&rpcbuf, &p);
402    if (!err)    if (!err)
403      err = nfs_error_trans (ntohl (*p++));      {
404          err = nfs_error_trans (ntohl (*p));
405          p++;
406        }
407    
408    if (!err)    if (!err)
409      {      {
410        p++;                      /* skip IOSIZE field */        p++;                      /* skip IOSIZE field */
411        st->f_bsize = ntohl (*p++);        st->f_bsize = ntohl (*p);
412        st->f_blocks = ntohl (*p++);        p++;
413        st->f_bfree = ntohl (*p++);        st->f_blocks = ntohl (*p);
414        st->f_bavail = ntohl (*p++);        p++;
415          st->f_bfree = ntohl (*p);
416          p++;
417          st->f_bavail = ntohl (*p);
418          p++;
419        st->f_type = FSTYPE_NFS;        st->f_type = FSTYPE_NFS;
420        st->f_files = 0;        st->f_files = 0;
421        st->f_ffree = 0;        st->f_ffree = 0;
# Line 411  netfs_attempt_statfs (struct iouser *cre Line 428  netfs_attempt_statfs (struct iouser *cre
428  }  }
429    
430  /* Implement the netfs_attempt_sync callback as described in  /* Implement the netfs_attempt_sync callback as described in
431     <hurd/netfs.h>. */     <hurd/netfs.h>.  */
432  error_t  error_t
433  netfs_attempt_sync (struct iouser *cred, struct node *np, int wait)  netfs_attempt_sync (struct iouser *cred, struct node *np, int wait)
434  {  {
# Line 428  netfs_attempt_syncfs (struct iouser *cre Line 445  netfs_attempt_syncfs (struct iouser *cre
445  }  }
446    
447  /* Implement the netfs_attempt_read callback as described in  /* Implement the netfs_attempt_read callback as described in
448     <hurd/netfs.h>. */     <hurd/netfs.h>.  */
449  error_t  error_t
450  netfs_attempt_read (struct iouser *cred, struct node *np,  netfs_attempt_read (struct iouser *cred, struct node *np,
451                      off_t offset, size_t *len, void *data)                      off_t offset, size_t *len, void *data)
# Line 452  netfs_attempt_read (struct iouser *cred, Line 469  netfs_attempt_read (struct iouser *cred,
469          return errno;          return errno;
470    
471        p = xdr_encode_fhandle (p, &np->nn->handle);        p = xdr_encode_fhandle (p, &np->nn->handle);
472        *p++ = htonl (offset);        *(p++) = htonl (offset);
473        *p++ = htonl (thisamt);        *(p++) = htonl (thisamt);
474        if (protocol_version == 2)        if (protocol_version == 2)
475          *p++ = 0;          *(p++) = 0;
476    
477        err = conduct_rpc (&rpcbuf, &p);        err = conduct_rpc (&rpcbuf, &p);
478        if (!err)        if (!err)
479          {          {
480            err = nfs_error_trans (ntohl (*p++));            err = nfs_error_trans (ntohl (*p));
481              p++;
482    
483            if (!err || protocol_version == 3)            if (!err || protocol_version == 3)
484              p = process_returned_stat (np, p, !err);              p = process_returned_stat (np, p, !err);
# Line 471  netfs_attempt_read (struct iouser *cred, Line 489  netfs_attempt_read (struct iouser *cred,
489                return err;                return err;
490              }              }
491    
492            trans_len = ntohl (*p++);            trans_len = ntohl (*p);
493              p++;
494            if (trans_len > thisamt)            if (trans_len > thisamt)
495              trans_len = thisamt;        /* ??? */              trans_len = thisamt;        /* ??? */
496    
497            if (protocol_version == 3)            if (protocol_version == 3)
498              eof = ntohl (*p++);              {
499                  eof = ntohl (*p);
500                  p++;
501                }
502            else            else
503              eof = (trans_len < thisamt);              eof = (trans_len < thisamt);
504    
# Line 498  netfs_attempt_read (struct iouser *cred, Line 520  netfs_attempt_read (struct iouser *cred,
520  }  }
521    
522  /* Implement the netfs_attempt_write callback as described in  /* Implement the netfs_attempt_write callback as described in
523     <hurd/netfs.h>. */     <hurd/netfs.h>.  */
524  error_t  error_t
525  netfs_attempt_write (struct iouser *cred, struct node *np,  netfs_attempt_write (struct iouser *cred, struct node *np,
526                       off_t offset, size_t *len, void *data)                       off_t offset, size_t *len, void *data)
# Line 522  netfs_attempt_write (struct iouser *cred Line 544  netfs_attempt_write (struct iouser *cred
544    
545        p = xdr_encode_fhandle (p, &np->nn->handle);        p = xdr_encode_fhandle (p, &np->nn->handle);
546        if (protocol_version == 2)        if (protocol_version == 2)
547          *p++ = 0;          *(p++) = 0;
548        *p++ = htonl (offset);        *(p++) = htonl (offset);
549        if (protocol_version == 2)        if (protocol_version == 2)
550          *p++ = 0;          *(p++) = 0;
551        if (protocol_version == 3)        if (protocol_version == 3)
552          *p++ = htonl (FILE_SYNC);          *(p++) = htonl (FILE_SYNC);
553        p = xdr_encode_data (p, data, thisamt);        p = xdr_encode_data (p, data, thisamt);
554    
555        err = conduct_rpc (&rpcbuf, &p);        err = conduct_rpc (&rpcbuf, &p);
556        if (!err)        if (!err)
557          {          {
558            err = nfs_error_trans (ntohl (*p++));            err = nfs_error_trans (ntohl (*p));
559              p++;
560            if (!err || protocol_version == 3)            if (!err || protocol_version == 3)
561              p = process_wcc_stat (np, p, !err);              p = process_wcc_stat (np, p, !err);
562            if (!err)            if (!err)
563              {              {
564                if (protocol_version == 3)                if (protocol_version == 3)
565                  {                  {
566                    count = ntohl (*p++);                    count = ntohl (*p);
567                      p++;
568                    p++;          /* ignore COMMITTED */                    p++;          /* ignore COMMITTED */
569                    /* ignore verf for now */                    /* ignore verf for now */
570                    p += NFS3_WRITEVERFSIZE / sizeof (int);                    p += NFS3_WRITEVERFSIZE / sizeof (int);
# Line 596  verify_nonexistent (struct iouser *cred, Line 620  verify_nonexistent (struct iouser *cred,
620    
621    err = conduct_rpc (&rpcbuf, &p);    err = conduct_rpc (&rpcbuf, &p);
622    if (!err)    if (!err)
623      err = nfs_error_trans (ntohl (*p++));      {
624          err = nfs_error_trans (ntohl (*p));
625          p++;
626        }
627    
628    free (rpcbuf);    free (rpcbuf);
629    
# Line 607  verify_nonexistent (struct iouser *cred, Line 634  verify_nonexistent (struct iouser *cred,
634  }  }
635    
636  /* Implement the netfs_attempt_lookup callback as described in  /* Implement the netfs_attempt_lookup callback as described in
637     <hurd/netfs.h>. */     <hurd/netfs.h>.  */
638  error_t  error_t
639  netfs_attempt_lookup (struct iouser *cred, struct node *np,  netfs_attempt_lookup (struct iouser *cred, struct node *np,
640                        char *name, struct node **newnp)                        char *name, struct node **newnp)
# Line 649  netfs_attempt_lookup (struct iouser *cre Line 676  netfs_attempt_lookup (struct iouser *cre
676    err = conduct_rpc (&rpcbuf, &p);    err = conduct_rpc (&rpcbuf, &p);
677    if (!err)    if (!err)
678      {      {
679        err = nfs_error_trans (ntohl (*p++));        err = nfs_error_trans (ntohl (*p));
680          p++;
681        if (!err)        if (!err)
682          {          {
683            p = xdr_decode_fhandle (p, newnp);            p = xdr_decode_fhandle (p, newnp);
# Line 680  netfs_attempt_lookup (struct iouser *cre Line 708  netfs_attempt_lookup (struct iouser *cre
708  }  }
709    
710  /* Implement the netfs_attempt_mkdir callback as described in  /* Implement the netfs_attempt_mkdir callback as described in
711     <hurd/netfs.h>. */     <hurd/netfs.h>.  */
712  error_t  error_t
713  netfs_attempt_mkdir (struct iouser *cred, struct node *np,  netfs_attempt_mkdir (struct iouser *cred, struct node *np,
714                       char *name, mode_t mode)                       char *name, mode_t mode)
# Line 713  netfs_attempt_mkdir (struct iouser *cred Line 741  netfs_attempt_mkdir (struct iouser *cred
741    
742    err = conduct_rpc (&rpcbuf, &p);    err = conduct_rpc (&rpcbuf, &p);
743    if (!err)    if (!err)
744      err = nfs_error_trans (ntohl (*p++));      {
745          err = nfs_error_trans (ntohl (*p));
746          p++;
747        }
748    
749    if (!err)    if (!err)
750      {      {
# Line 735  netfs_attempt_mkdir (struct iouser *cred Line 766  netfs_attempt_mkdir (struct iouser *cred
766  }  }
767    
768  /* Implement the netfs_attempt_rmdir callback as described in  /* Implement the netfs_attempt_rmdir callback as described in
769     <hurd/netfs.h>. */     <hurd/netfs.h>.  */
770  error_t  error_t
771  netfs_attempt_rmdir (struct iouser *cred, struct node *np,  netfs_attempt_rmdir (struct iouser *cred, struct node *np,
772                       char *name)                       char *name)
# Line 759  netfs_attempt_rmdir (struct iouser *cred Line 790  netfs_attempt_rmdir (struct iouser *cred
790    err = conduct_rpc (&rpcbuf, &p);    err = conduct_rpc (&rpcbuf, &p);
791    if (!err)    if (!err)
792      {      {
793        err = nfs_error_trans (ntohl (*p++));        err = nfs_error_trans (ntohl (*p));
794          p++;
795        if (protocol_version == 3)        if (protocol_version == 3)
796          p = process_wcc_stat (np, p, !err);          p = process_wcc_stat (np, p, !err);
797      }      }
# Line 769  netfs_attempt_rmdir (struct iouser *cred Line 801  netfs_attempt_rmdir (struct iouser *cred
801  }  }
802    
803  /* Implement the netfs_attempt_link callback as described in  /* Implement the netfs_attempt_link callback as described in
804     <hurd/netfs.h>. */     <hurd/netfs.h>.  */
805  error_t  error_t
806  netfs_attempt_link (struct iouser *cred, struct node *dir,  netfs_attempt_link (struct iouser *cred, struct node *dir,
807                      struct node *np, char *name, int excl)                      struct node *np, char *name, int excl)
# Line 819  netfs_attempt_link (struct iouser *cred, Line 851  netfs_attempt_link (struct iouser *cred,
851    
852        err = conduct_rpc (&rpcbuf, &p);        err = conduct_rpc (&rpcbuf, &p);
853        if (!err)        if (!err)
854          err = nfs_error_trans (ntohl (*p++));          {
855              err = nfs_error_trans (ntohl (*p));
856              p++;
857            }
858        mutex_unlock (&dir->lock);        mutex_unlock (&dir->lock);
859    
860        free (rpcbuf);        free (rpcbuf);
# Line 868  netfs_attempt_link (struct iouser *cred, Line 903  netfs_attempt_link (struct iouser *cred,
903        err = conduct_rpc (&rpcbuf, &p);        err = conduct_rpc (&rpcbuf, &p);
904        if (!err)        if (!err)
905          {          {
906            err = nfs_error_trans (ntohl (*p++));            err = nfs_error_trans (ntohl (*p));
907              p++;
908    
909            if (protocol_version == 2 && !err)            if (protocol_version == 2 && !err)
910              {              {
# Line 890  netfs_attempt_link (struct iouser *cred, Line 926  netfs_attempt_link (struct iouser *cred,
926    
927                err = conduct_rpc (&rpcbuf, &p);                err = conduct_rpc (&rpcbuf, &p);
928                if (!err)                if (!err)
929                  err = nfs_error_trans (ntohl (*p++));                  {
930                      err = nfs_error_trans (ntohl (*p));
931                      p++;
932                    }
933                if (!err)                if (!err)
934                  {                  {
935                    mutex_lock (&np->lock);                    mutex_lock (&np->lock);
# Line 966  netfs_attempt_link (struct iouser *cred, Line 1005  netfs_attempt_link (struct iouser *cred,
1005                                          _lengthy_ (blocking) conduct_rpc? */                                          _lengthy_ (blocking) conduct_rpc? */
1006            err = conduct_rpc (&rpcbuf, &p);            err = conduct_rpc (&rpcbuf, &p);
1007            if (!err)            if (!err)
1008              err = nfs_error_trans (ntohl (*p++));              {
1009                  err = nfs_error_trans (ntohl (*p));
1010                  p++;
1011                }
1012    
1013            if (!err)            if (!err)
1014              {              {
# Line 999  netfs_attempt_link (struct iouser *cred, Line 1041  netfs_attempt_link (struct iouser *cred,
1041                free (rpcbuf);                free (rpcbuf);
1042                return err;                return err;
1043              }              }
1044            *p++ = htonl (hurd_mode_to_nfs_type (np->nn_stat.st_mode));            *(p++) = htonl (hurd_mode_to_nfs_type (np->nn_stat.st_mode));
1045            p = xdr_encode_sattr_stat (p, &np->nn_stat);            p = xdr_encode_sattr_stat (p, &np->nn_stat);
1046            if (np->nn->dtrans == BLKDEV || np->nn->dtrans == CHRDEV)            if (np->nn->dtrans == BLKDEV || np->nn->dtrans == CHRDEV)
1047              {              {
1048                *p++ = htonl (major (np->nn_stat.st_rdev));                *(p++) = htonl (major (np->nn_stat.st_rdev));
1049                *p++ = htonl (minor (np->nn_stat.st_rdev));                *(p++) = htonl (minor (np->nn_stat.st_rdev));
1050              }              }
1051            mutex_unlock (&np->lock);            mutex_unlock (&np->lock);
1052    
# Line 1012  netfs_attempt_link (struct iouser *cred, Line 1054  netfs_attempt_link (struct iouser *cred,
1054            err = conduct_rpc (&rpcbuf, &p);            err = conduct_rpc (&rpcbuf, &p);
1055            if (!err)            if (!err)
1056              {              {
1057                err = nfs_error_trans (ntohl (*p++));                err = nfs_error_trans (ntohl (*p));
1058                  p++;
1059    
1060                if (!err)                if (!err)
1061                  {                  {
1062                    mutex_lock (&np->lock);                    mutex_lock (&np->lock);
# Line 1058  netfs_attempt_link (struct iouser *cred, Line 1102  netfs_attempt_link (struct iouser *cred,
1102  }  }
1103    
1104  /* Implement the netfs_attempt_mkfile callback as described in  /* Implement the netfs_attempt_mkfile callback as described in
1105     <hurd/netfs.h>. */     <hurd/netfs.h>.  */
1106  error_t  error_t
1107  netfs_attempt_mkfile (struct iouser *cred, struct node *dir,  netfs_attempt_mkfile (struct iouser *cred, struct node *dir,
1108                        mode_t mode, struct node **newnp)                        mode_t mode, struct node **newnp)
# Line 1101  netfs_attempt_mkfile (struct iouser *cre Line 1145  netfs_attempt_mkfile (struct iouser *cre
1145  }  }
1146    
1147  /* Implement the netfs_attempt_create_file callback as described in  /* Implement the netfs_attempt_create_file callback as described in
1148     <hurd/netfs.h>. */     <hurd/netfs.h>.  */
1149  error_t  error_t
1150  netfs_attempt_create_file (struct iouser *cred, struct node *np,  netfs_attempt_create_file (struct iouser *cred, struct node *np,
1151                             char *name, mode_t mode, struct node **newnp)                             char *name, mode_t mode, struct node **newnp)
# Line 1147  netfs_attempt_create_file (struct iouser Line 1191  netfs_attempt_create_file (struct iouser
1191        /* We happen to know this is where the XID is. */        /* We happen to know this is where the XID is. */
1192        int verf = *(int *)rpcbuf;        int verf = *(int *)rpcbuf;
1193    
1194        *p++ = ntohl (EXCLUSIVE);        *(p++) = ntohl (EXCLUSIVE);
1195        /* 8 byte verf */        /* 8 byte verf */
1196        *p++ = ntohl (verf);        *(p++) = ntohl (verf);
1197        p++;        p++;
1198      }      }
1199    else    else
# Line 1161  netfs_attempt_create_file (struct iouser Line 1205  netfs_attempt_create_file (struct iouser
1205    
1206    if (!err)    if (!err)
1207      {      {
1208        err = nfs_error_trans (ntohl (*p++));        err = nfs_error_trans (ntohl (*p));
1209          p++;
1210        if (!err)        if (!err)
1211          {          {
1212            p = xdr_decode_fhandle (p, newnp);            p = xdr_decode_fhandle (p, newnp);
# Line 1192  netfs_attempt_create_file (struct iouser Line 1237  netfs_attempt_create_file (struct iouser
1237  }  }
1238    
1239  /* Implement the netfs_attempt_unlink callback as described in  /* Implement the netfs_attempt_unlink callback as described in
1240     <hurd/netfs.h>. */     <hurd/netfs.h>.  */
1241  error_t  error_t
1242  netfs_attempt_unlink (struct iouser *cred, struct node *dir,  netfs_attempt_unlink (struct iouser *cred, struct node *dir,
1243                        char *name)                        char *name)
# Line 1283  netfs_attempt_unlink (struct iouser *cre Line 1328  netfs_attempt_unlink (struct iouser *cre
1328    err = conduct_rpc (&rpcbuf, &p);    err = conduct_rpc (&rpcbuf, &p);
1329    if (!err)    if (!err)
1330      {      {
1331        err = nfs_error_trans (ntohl (*p++));        err = nfs_error_trans (ntohl (*p));
1332          p++;
1333        if (protocol_version == 3)        if (protocol_version == 3)
1334          p = process_wcc_stat (dir, p, !err);          p = process_wcc_stat (dir, p, !err);
1335      }      }
# Line 1294  netfs_attempt_unlink (struct iouser *cre Line 1340  netfs_attempt_unlink (struct iouser *cre
1340  }  }
1341    
1342  /* Implement the netfs_attempt_rename callback as described in  /* Implement the netfs_attempt_rename callback as described in
1343     <hurd/netfs.h>. */     <hurd/netfs.h>.  */
1344  error_t  error_t
1345  netfs_attempt_rename (struct iouser *cred, struct node *fromdir,  netfs_attempt_rename (struct iouser *cred, struct node *fromdir,
1346                        char *fromname, struct node *todir, char *toname,                        char *fromname, struct node *todir, char *toname,
# Line 1360  netfs_attempt_rename (struct iouser *cre Line 1406  netfs_attempt_rename (struct iouser *cre
1406    err = conduct_rpc (&rpcbuf, &p);    err = conduct_rpc (&rpcbuf, &p);
1407    if (!err)    if (!err)
1408      {      {
1409        err = nfs_error_trans (ntohl (*p++));        err = nfs_error_trans (ntohl (*p));
1410          p++;
1411        if (protocol_version == 3)  /* XXX Should we add `&& !err' ? */        if (protocol_version == 3)  /* XXX Should we add `&& !err' ? */
1412          {          {
1413            mutex_lock (&fromdir->lock);            mutex_lock (&fromdir->lock);
# Line 1374  netfs_attempt_rename (struct iouser *cre Line 1421  netfs_attempt_rename (struct iouser *cre
1421  }  }
1422    
1423  /* Implement the netfs_attempt_readlink callback as described in  /* Implement the netfs_attempt_readlink callback as described in
1424     <hurd/netfs.h>. */     <hurd/netfs.h>.  */
1425  error_t  error_t
1426  netfs_attempt_readlink (struct iouser *cred, struct node *np,  netfs_attempt_readlink (struct iouser *cred, struct node *np,
1427                          char *buf)                          char *buf)
# Line 1399  netfs_attempt_readlink (struct iouser *c Line 1446  netfs_attempt_readlink (struct iouser *c
1446    err = conduct_rpc (&rpcbuf, &p);    err = conduct_rpc (&rpcbuf, &p);
1447    if (!err)    if (!err)
1448      {      {
1449        err = nfs_error_trans (ntohl (*p++));        err = nfs_error_trans (ntohl (*p));
1450          p++;
1451        if (protocol_version == 3)        if (protocol_version == 3)
1452          p = process_returned_stat (np, p, 0);          p = process_returned_stat (np, p, 0);
1453        if (!err)        if (!err)
# Line 1411  netfs_attempt_readlink (struct iouser *c Line 1459  netfs_attempt_readlink (struct iouser *c
1459  }  }
1460    
1461  /* Implement the netfs_check_open_permissions callback as described in  /* Implement the netfs_check_open_permissions callback as described in
1462     <hurd/netfs.h>. */     <hurd/netfs.h>.  */
1463  error_t  error_t
1464  netfs_check_open_permissions (struct iouser *cred, struct node *np,  netfs_check_open_permissions (struct iouser *cred, struct node *np,
1465                                int flags, int newnode)                                int flags, int newnode)
# Line 1429  netfs_check_open_permissions (struct iou Line 1477  netfs_check_open_permissions (struct iou
1477  }  }
1478    
1479  /* Implement the netfs_report_access callback as described in  /* Implement the netfs_report_access callback as described in
1480     <hurd/netfs.h>. */     <hurd/netfs.h>.  */
1481  error_t  error_t
1482  netfs_report_access (struct iouser *cred,  netfs_report_access (struct iouser *cred,
1483                       struct node *np,                       struct node *np,
# Line 1477  netfs_report_access (struct iouser *cred Line 1525  netfs_report_access (struct iouser *cred
1525          return errno;          return errno;
1526    
1527        p = xdr_encode_fhandle (p, &np->nn->handle);        p = xdr_encode_fhandle (p, &np->nn->handle);
1528        *p++ = htonl (ACCESS3_READ | write_check | execute_check);        *(p++) = htonl (ACCESS3_READ | write_check | execute_check);
1529    
1530        err = conduct_rpc (&rpcbuf, &p);        err = conduct_rpc (&rpcbuf, &p);
1531        if (!err)        if (!err)
1532          {          {
1533            err = nfs_error_trans (ntohl (*p++));            err = nfs_error_trans (ntohl (*p));
1534              p++;
1535            p = process_returned_stat (np, p, 0);   /* XXX Should this be            p = process_returned_stat (np, p, 0);   /* XXX Should this be
1536                                                       protected by the                                                       protected by the
1537                                                       if (!err) ? */                                                       if (!err) ? */
1538            if (!err)            if (!err)
1539              {              {
1540                ret = ntohl (*p++);                ret = ntohl (*p);
1541                  p++;
1542                *types = ((ret & ACCESS3_READ ? O_READ : 0)                *types = ((ret & ACCESS3_READ ? O_READ : 0)
1543                          | (ret & write_check ? O_WRITE : 0)                          | (ret & write_check ? O_WRITE : 0)
1544                          | (ret & execute_check ? O_EXEC : 0));                          | (ret & execute_check ? O_EXEC : 0));
# Line 1499  netfs_report_access (struct iouser *cred Line 1549  netfs_report_access (struct iouser *cred
1549  }  }
1550    
1551  /* These definitions have unfortunate side effects, don't use them,  /* These definitions have unfortunate side effects, don't use them,
1552     clever though they are. */     clever though they are.  */
1553  #if 0  #if 0
1554  /* Implement the netfs_check_open_permissions callback as described in  /* Implement the netfs_check_open_permissions callback as described in
1555     <hurd/netfs.h>. */     <hurd/netfs.h>. */
# Line 1577  netfs_check_open_permissions (struct iou Line 1627  netfs_check_open_permissions (struct iou
1627               return failure.  Otherwise, succeed. */               return failure.  Otherwise, succeed. */
1628            p = nfs_initialize_rpc (NFSPROC_READDIR, cred, 0, &rpcbuf, np, -1);            p = nfs_initialize_rpc (NFSPROC_READDIR, cred, 0, &rpcbuf, np, -1);
1629            p = xdr_encode_fhandle (p, &np->nn->handle);            p = xdr_encode_fhandle (p, &np->nn->handle);
1630            *p++ = 0;            *(p++) = 0;
1631            *p++ = htonl (50);            *(p++) = htonl (50);
1632            err = conduct_rpc (&rpcbuf, &p);            err = conduct_rpc (&rpcbuf, &p);
1633            if (!err)            if (!err)
1634              err = nfs_error_trans (ntohl (*p++));              {
1635                  err = nfs_error_trans (ntohl (*p));
1636                  p++;
1637                }
1638            free (rpcbuf);            free (rpcbuf);
1639    
1640            if (err)            if (err)
# Line 1592  netfs_check_open_permissions (struct iou Line 1645  netfs_check_open_permissions (struct iou
1645  }  }
1646    
1647  /* Implement the netfs_report_access callback as described in  /* Implement the netfs_report_access callback as described in
1648     <hurd/netfs.h>. */     <hurd/netfs.h>.  */
1649  void  void
1650  netfs_report_access (struct iouser *cred,  netfs_report_access (struct iouser *cred,
1651                       struct node *np,                       struct node *np,
# Line 1642  netfs_report_access (struct iouser *cred Line 1695  netfs_report_access (struct iouser *cred
1695     *BUFP to that buffer.  *BUFP must be freed by the caller when no     *BUFP to that buffer.  *BUFP must be freed by the caller when no
1696     longer needed.  If an error occurs, don't touch *BUFP and return     longer needed.  If an error occurs, don't touch *BUFP and return
1697     the error code.  Set BUFSIZEP to the amount of data used inside     the error code.  Set BUFSIZEP to the amount of data used inside
1698     *BUFP and TOTALENTRIES to the total number of entries copied. */     *BUFP and TOTALENTRIES to the total number of entries copied.  */
1699  static error_t  static error_t
1700  fetch_directory (struct iouser *cred, struct node *dir,  fetch_directory (struct iouser *cred, struct node *dir,
1701                   void **bufp, size_t *bufsizep, int *totalentries)                   void **bufp, size_t *bufsizep, int *totalentries)
# Line 1681  fetch_directory (struct iouser *cred, st Line 1734  fetch_directory (struct iouser *cred, st
1734          }          }
1735    
1736        p = xdr_encode_fhandle (p, &dir->nn->handle);        p = xdr_encode_fhandle (p, &dir->nn->handle);
1737        *p++ = cookie;        *(p++) = cookie;
1738        *p++ = ntohl (read_size);        *(p++) = ntohl (read_size);
1739        err = conduct_rpc (&rpcbuf, &p);        err = conduct_rpc (&rpcbuf, &p);
1740        if (!err)        if (!err)
1741          err = nfs_error_trans (ntohl (*p++));          {
1742              err = nfs_error_trans (ntohl (*p));
1743              p++;
1744            }
1745        if (err)        if (err)
1746          {          {
1747            free (buf);            free (buf);
1748            return err;            return err;
1749          }          }
1750    
1751        isnext = ntohl (*p++);        isnext = ntohl (*p);
1752          p++;
1753    
1754        /* Now copy them one at a time. */        /* Now copy them one at a time. */
1755        while (isnext)        while (isnext)
# Line 1701  fetch_directory (struct iouser *cred, st Line 1758  fetch_directory (struct iouser *cred, st
1758            int namlen;            int namlen;
1759            int reclen;            int reclen;
1760    
1761            fileno = ntohl (*p++);            fileno = ntohl (*p);
1762            namlen = ntohl (*p++);            p++;
1763              namlen = ntohl (*p);
1764              p++;
1765    
1766            /* There's a hidden +1 here for the null byte and -1 because d_name            /* There's a hidden +1 here for the null byte and -1 because d_name
1767               has a size of one already in the sizeof.  */               has a size of one already in the sizeof.  */
# Line 1727  fetch_directory (struct iouser *cred, st Line 1786  fetch_directory (struct iouser *cred, st
1786            entry->d_reclen = reclen;            entry->d_reclen = reclen;
1787            entry->d_type = DT_UNKNOWN;            entry->d_type = DT_UNKNOWN;
1788            entry->d_namlen = namlen;            entry->d_namlen = namlen;
1789            bcopy (p, entry->d_name, namlen);            memcpy (entry->d_name, p, namlen);
1790            entry->d_name[namlen] = '\0';            entry->d_name[namlen] = '\0';
1791    
1792            p += INTSIZE (namlen);            p += INTSIZE (namlen);
# Line 1735  fetch_directory (struct iouser *cred, st Line 1794  fetch_directory (struct iouser *cred, st
1794    
1795            ++*totalentries;            ++*totalentries;
1796    
1797            cookie = *p++;            cookie = *(p++);
1798            isnext = ntohl (*p++);            isnext = ntohl (*p);
1799              p++;
1800          }          }
1801    
1802        eof = ntohl (*p++);        eof = ntohl (*p);
1803          p++;
1804        free (rpcbuf);        free (rpcbuf);
1805      }      }
1806    
# Line 1751  fetch_directory (struct iouser *cred, st Line 1812  fetch_directory (struct iouser *cred, st
1812    
1813    
1814  /* Implement the netfs_get_directs callback as described in  /* Implement the netfs_get_directs callback as described in
1815     <hurd/netfs.h>. */     <hurd/netfs.h>.  */
1816  error_t  error_t
1817  netfs_get_dirents (struct iouser *cred, struct node *np,  netfs_get_dirents (struct iouser *cred, struct node *np,
1818                     int entry, int nentries, char **data,                     int entry, int nentries, char **data,
# Line 1821  netfs_get_dirents (struct iouser *cred, Line 1882  netfs_get_dirents (struct iouser *cred,
1882    
1883    
1884  /* Implement the netfs_set_translator callback as described in  /* Implement the netfs_set_translator callback as described in
1885     <hurd/netfs.h>. */     <hurd/netfs.h>.  */
1886  error_t  error_t
1887  netfs_set_translator (struct iouser *cred,  netfs_set_translator (struct iouser *cred,
1888                        struct node *np,                        struct node *np,
# Line 1832  netfs_set_translator (struct iouser *cre Line 1893  netfs_set_translator (struct iouser *cre
1893  }  }
1894    
1895  /* Implement the netfs_attempt_mksymlink callback as described in  /* Implement the netfs_attempt_mksymlink callback as described in
1896     <hurd/netfs.h>. */     <hurd/netfs.h>.  */
1897  error_t  error_t
1898  netfs_attempt_mksymlink (struct iouser *cred,  netfs_attempt_mksymlink (struct iouser *cred,
1899                           struct node *np,                           struct node *np,
# Line 1852  netfs_attempt_mksymlink (struct iouser * Line 1913  netfs_attempt_mksymlink (struct iouser *
1913  }  }
1914    
1915  /* Implement the netfs_attempt_mkdev callback as described in  /* Implement the netfs_attempt_mkdev callback as described in
1916     <hurd/netfs.h>. */     <hurd/netfs.h>.  */
1917  error_t  error_t
1918  netfs_attempt_mkdev (struct iouser *cred,  netfs_attempt_mkdev (struct iouser *cred,
1919                       struct node *np,                       struct node *np,

Legend:
Removed from v.1.43  
changed lines
  Added in v.1.44

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