home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / unix / internal / 1636 < prev    next >
Encoding:
Text File  |  1992-07-30  |  1.9 KB  |  70 lines

  1. Path: sparky!uunet!mcsun!Germany.EU.net!unido!marco!krabat!leo
  2. From: leo@krabat.marco.de (Matthias Pfaller)
  3. Newsgroups: comp.unix.internals
  4. Subject: Problems with fsync(2) in SunOS
  5. Keywords: fsync EACCES
  6. Message-ID: <1089@krabat.marco.de>
  7. Date: 31 Jul 92 08:46:58 GMT
  8. Organization: marco GmbH, D-8047 Karlsfeld
  9. Lines: 59
  10.  
  11. We have a network of three sun-machines (one of them with SunOS 4.1.2,
  12. the other two with SunOS 4.1.1) and four SysVr3 machines (one 386-based,
  13. three M68020-based). The filesystems are crossmounted with NFS.
  14.  
  15. We are using SCCS to maintain our sources.
  16. We noticed that when one does a delta from a sun on a directory mounted
  17. from a SysVr3 machine, the delta command fails with
  18. "directory `.' unwritable"
  19. also the directory IS writable.
  20. using trace(1) we could identify the failing systemcall. It's "fsync(2)".
  21.  
  22. You can use the following small c-program to reproduce the problem.
  23. Requirments:
  24. You need root-access on your own machine.
  25. You need root-access on the remote machine.
  26. You must not be logged in as root or bin.
  27.  
  28. execute the command with:
  29. tst remote-filesys/file
  30.  
  31. It is important that the chown that is done with a call to system(3)
  32. succeeds. If your remote machine is a SysV machine you may insert
  33.     if (fchown(1, 2, -1))
  34.         perror("fchown");
  35. instead of the call to system(3).
  36.  
  37. The fsync-call will fail with EACCES.
  38. If you try the program on a local file, there will be no problem.
  39. Has anyone a solution for our problem?
  40.  
  41.     Matthias Pfaller (leo @ marco.de)
  42.  
  43. #include <fcntl.h>
  44.  
  45. main(argc, argv)
  46. int argc; char **argv;
  47. {
  48.     int fd;
  49.     char b[80];
  50.  
  51.     if ((fd = open(argv[1], O_WRONLY|O_CREAT, 0666)) < 0) {
  52.         perror("open");
  53.         exit(1);
  54.     }
  55.  
  56.     if (fchmod(fd, 0444))
  57.         perror("fchmod");
  58.  
  59.     sprintf(b, "su root -c '/etc/chown bin %s'", argv[1]);
  60.     system(b);
  61.  
  62.     if (write(fd, "hallo\n", 6) != 6)
  63.         perror("write");
  64.     if (fsync(fd))
  65.         perror("fsync");
  66.     if (close(fd))
  67.         perror("close");
  68.     exit(0);
  69. }
  70.