home *** CD-ROM | disk | FTP | other *** search
/ linuxmafia.com 2016 / linuxmafia.com.tar / linuxmafia.com / pub / linux / backup / star-1.3.1.tar.gz / star-1.3.1.tar / star-1.3.1 / star / create.dgux.patch < prev    next >
Text File  |  1997-06-15  |  3KB  |  125 lines

  1. *** create.c.orig    Sat Jun 14 15:53:45 1997
  2. --- create.c    Sun Jun 15 18:38:08 1997
  3. ***************
  4. *** 35,40 ****
  5. --- 35,101 ----
  6.   #include <strdefs.h>
  7.   #include "starsubs.h"
  8.   
  9. + #if defined(DGUX) && !defined(NO_DG_FILEREAD)
  10. + #include <fcntl.h>
  11. + #include <sys/dg_unbuffered_io.h>
  12. + LOCAL    FILE    *dg_fileopen    __PR((FINFO *info));
  13. + LOCAL    int    dg_fileclose    __PR((FILE *fp));
  14. + LOCAL    int    dg_fileread    __PR((FILE *f, char *bp, int cnd));
  15. + FILE *dg_fileopen(info)
  16. +     FINFO    *info;
  17. + {
  18. +     static    FILE    __f;
  19. +     int    f;
  20. +     if ((f = open(info->f_name, O_DG_UNBUFFERED)) < 0)
  21. +         return ((FILE *)0);
  22. +     __f._file = f;
  23. +     __f._cnt = 0;
  24. +     __f._ptr = info->f_rsize;
  25. +     return (&__f);
  26. + }
  27. + int dg_fileclose(fp)
  28. +     FILE    *fp;
  29. + {
  30. +     return (close(fp->_file));
  31. + }
  32. + int dg_fileread(fp, bp, cnt)
  33. +     FILE    *fp;
  34. +     char    *bp;
  35. +     int    cnt;
  36. + {
  37. +     int    n;
  38. + again:
  39. +     n = dg_unbuffered_read(fp->_file, bp, fp->_cnt, cnt/512);
  40. +     if (n < 0) {
  41. +         if (geterrno() == EINTR)
  42. +             goto again;
  43. +         return (-1);
  44. +     }
  45. +     if (n == 0)
  46. +         return (0);
  47. +     fp->_cnt += n;
  48. +     if (fp->_cnt == tarblocks((int)fp->_ptr)) {
  49. +         if ((((int)fp->_ptr) % 512) == 0)
  50. +             return (n * 512);
  51. +         n -= 1;
  52. +         n *= 512;
  53. +         n += ((int)fp->_ptr) % 512;
  54. +         return (n);
  55. +     }
  56. +     return (n * 512);
  57. + }
  58. + #endif
  59.   typedef    struct    links {
  60.       struct    links    *l_next;
  61.           long    l_ino;
  62. ***************
  63. *** 227,232 ****
  64. --- 288,296 ----
  65.       else if (is_symlink(info) && !read_symlink(name, info, ptb))
  66.           ;
  67.       else if (is_file(info) && info->f_size != 0 && !nullout &&
  68. + #if defined(DGUX) && !defined(NO_DG_FILEREAD)
  69. +                 (f = dg_fileopen(info)) == (FILE *)NULL) {
  70. + #else
  71.   #ifdef    OLD_OPEN
  72.                   (f = fileopen(name,"ru")) == (FILE *)NULL) {
  73.   #else
  74. ***************
  75. *** 236,241 ****
  76. --- 300,306 ----
  77.                    */
  78.                   (f = fileopen(name,"r")) == (FILE *)NULL) {
  79.   #endif
  80. + #endif
  81.           errmsg("Cannot open '%s'.\n", name);
  82.       } else {
  83.           if (info->f_nlink > 1 && read_link(name, namlen, info, ptb))
  84. ***************
  85. *** 280,286 ****
  86. --- 345,355 ----
  87.           if (acctime && f != NULL)
  88.               rs_acctime(f, info);
  89.           if (f)
  90. + #if defined(DGUX) && !defined(NO_DG_FILEREAD)
  91. +             dg_fileclose(f);
  92. + #else
  93.               fclose(f);
  94. + #endif
  95.       }
  96.   }
  97.   
  98. ***************
  99. *** 421,428 ****
  100. --- 490,502 ----
  101.           cr_file(info, (int(*)__PR((void *, char *, int)))nullread,
  102.                               f, 0, "reading");
  103.       } else {
  104. + #if defined(DGUX) && !defined(NO_DG_FILEREAD)
  105. +         cr_file(info, (int(*)__PR((void *, char *, int)))dg_fileread,
  106. +                             f, 0, "reading");
  107. + #else
  108.           cr_file(info, (int(*)__PR((void *, char *, int)))ffileread,
  109.                               f, 0, "reading");
  110. + #endif
  111.       }
  112.   }
  113.   
  114.