4
0

rmt.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /* Definitions for communicating with a remote tape drive.
  2. Copyright (C) 1988, 1992, 1996, 1997, 2001, 2003, 2004 Free
  3. Software Foundation, Inc.
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2, or (at your option)
  7. any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software Foundation,
  14. Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
  15. extern char *rmt_dev_name__;
  16. int rmt_open__ (const char *, int, int, const char *);
  17. int rmt_close__ (int);
  18. size_t rmt_read__ (int, char *, size_t);
  19. size_t rmt_write__ (int, char *, size_t);
  20. off_t rmt_lseek__ (int, off_t, int);
  21. int rmt_ioctl__ (int, int, char *);
  22. /* A filename is remote if it contains a colon not preceded by a slash,
  23. to take care of `/:/' which is a shorthand for `/.../<CELL-NAME>/fs'
  24. on machines running OSF's Distributing Computing Environment (DCE) and
  25. Distributed File System (DFS). However, when --force-local, a
  26. filename is never remote. */
  27. #define _remdev(dev_name) \
  28. (!force_local_option && (rmt_dev_name__ = strchr (dev_name, ':')) \
  29. && rmt_dev_name__ > (dev_name) \
  30. && ! memchr (dev_name, '/', rmt_dev_name__ - (dev_name)))
  31. #define _isrmt(fd) \
  32. ((fd) >= __REM_BIAS)
  33. #define __REM_BIAS (1 << 30)
  34. #ifndef O_CREAT
  35. # define O_CREAT 01000
  36. #endif
  37. #define rmtopen(dev_name, oflag, mode, command) \
  38. (_remdev (dev_name) ? rmt_open__ (dev_name, oflag, __REM_BIAS, command) \
  39. : open (dev_name, oflag, mode))
  40. #define rmtaccess(dev_name, amode) \
  41. (_remdev (dev_name) ? 0 : access (dev_name, amode))
  42. #define rmtstat(dev_name, buffer) \
  43. (_remdev (dev_name) ? (errno = EOPNOTSUPP), -1 : stat (dev_name, buffer))
  44. #define rmtcreat(dev_name, mode, command) \
  45. (_remdev (dev_name) \
  46. ? rmt_open__ (dev_name, 1 | O_CREAT, __REM_BIAS, command) \
  47. : creat (dev_name, mode))
  48. #define rmtlstat(dev_name, muffer) \
  49. (_remdev (dev_name) ? (errno = EOPNOTSUPP), -1 : lstat (dev_name, buffer))
  50. #define rmtread(fd, buffer, length) \
  51. (_isrmt (fd) ? rmt_read__ (fd - __REM_BIAS, buffer, length) \
  52. : safe_read (fd, buffer, length))
  53. #define rmtwrite(fd, buffer, length) \
  54. (_isrmt (fd) ? rmt_write__ (fd - __REM_BIAS, buffer, length) \
  55. : full_write (fd, buffer, length))
  56. #define rmtlseek(fd, offset, where) \
  57. (_isrmt (fd) ? rmt_lseek__ (fd - __REM_BIAS, offset, where) \
  58. : lseek (fd, offset, where))
  59. #define rmtclose(fd) \
  60. (_isrmt (fd) ? rmt_close__ (fd - __REM_BIAS) : close (fd))
  61. #define rmtioctl(fd, request, argument) \
  62. (_isrmt (fd) ? rmt_ioctl__ (fd - __REM_BIAS, request, argument) \
  63. : ioctl (fd, request, argument))
  64. #define rmtdup(fd) \
  65. (_isrmt (fd) ? (errno = EOPNOTSUPP), -1 : dup (fd))
  66. #define rmtfstat(fd, buffer) \
  67. (_isrmt (fd) ? (errno = EOPNOTSUPP), -1 : fstat (fd, buffer))
  68. #define rmtfcntl(cd, command, argument) \
  69. (_isrmt (fd) ? (errno = EOPNOTSUPP), -1 : fcntl (fd, command, argument))
  70. #define rmtisatty(fd) \
  71. (_isrmt (fd) ? 0 : isatty (fd))