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