source: trunk/essentials/app-arch/cpio/lib/rmt.h

Last change on this file was 3332, checked in by bird, 18 years ago

cpio 2.7

File size: 3.4 KB
Line 
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
19
20extern char *rmt_command;
21extern char *rmt_dev_name__;
22
23int rmt_open__ (const char *, int, int, const char *);
24int rmt_close__ (int);
25size_t rmt_read__ (int, char *, size_t);
26size_t rmt_write__ (int, char *, size_t);
27off_t rmt_lseek__ (int, off_t, int);
28int rmt_ioctl__ (int, int, char *);
29
30extern bool force_local_option;
31
32/* A filename is remote if it contains a colon not preceded by a slash,
33 to take care of `/:/' which is a shorthand for `/.../<CELL-NAME>/fs'
34 on machines running OSF's Distributing Computing Environment (DCE) and
35 Distributed File System (DFS). However, when --force-local, a
36 filename is never remote. */
37
38#define _remdev(dev_name) \
39 (!force_local_option && (rmt_dev_name__ = strchr (dev_name, ':')) \
40 && rmt_dev_name__ > (dev_name) \
41 && ! memchr (dev_name, '/', rmt_dev_name__ - (dev_name)))
42
43#define _isrmt(fd) \
44 ((fd) >= __REM_BIAS)
45
46#define __REM_BIAS (1 << 30)
47
48#ifndef O_CREAT
49# define O_CREAT 01000
50#endif
51
52#define rmtopen(dev_name, oflag, mode, command) \
53 (_remdev (dev_name) ? rmt_open__ (dev_name, oflag, __REM_BIAS, command) \
54 : open (dev_name, oflag, mode))
55
56#define rmtaccess(dev_name, amode) \
57 (_remdev (dev_name) ? 0 : access (dev_name, amode))
58
59#define rmtstat(dev_name, buffer) \
60 (_remdev (dev_name) ? (errno = EOPNOTSUPP), -1 : stat (dev_name, buffer))
61
62#define rmtcreat(dev_name, mode, command) \
63 (_remdev (dev_name) \
64 ? rmt_open__ (dev_name, 1 | O_CREAT, __REM_BIAS, command) \
65 : creat (dev_name, mode))
66
67#define rmtlstat(dev_name, muffer) \
68 (_remdev (dev_name) ? (errno = EOPNOTSUPP), -1 : lstat (dev_name, buffer))
69
70#define rmtread(fd, buffer, length) \
71 (_isrmt (fd) ? rmt_read__ (fd - __REM_BIAS, buffer, length) \
72 : safe_read (fd, buffer, length))
73
74#define rmtwrite(fd, buffer, length) \
75 (_isrmt (fd) ? rmt_write__ (fd - __REM_BIAS, buffer, length) \
76 : full_write (fd, buffer, length))
77
78#define rmtlseek(fd, offset, where) \
79 (_isrmt (fd) ? rmt_lseek__ (fd - __REM_BIAS, offset, where) \
80 : lseek (fd, offset, where))
81
82#define rmtclose(fd) \
83 (_isrmt (fd) ? rmt_close__ (fd - __REM_BIAS) : close (fd))
84
85#define rmtioctl(fd, request, argument) \
86 (_isrmt (fd) ? rmt_ioctl__ (fd - __REM_BIAS, request, argument) \
87 : ioctl (fd, request, argument))
88
89#define rmtdup(fd) \
90 (_isrmt (fd) ? (errno = EOPNOTSUPP), -1 : dup (fd))
91
92#define rmtfstat(fd, buffer) \
93 (_isrmt (fd) ? (errno = EOPNOTSUPP), -1 : fstat (fd, buffer))
94
95#define rmtfcntl(cd, command, argument) \
96 (_isrmt (fd) ? (errno = EOPNOTSUPP), -1 : fcntl (fd, command, argument))
97
98#define rmtisatty(fd) \
99 (_isrmt (fd) ? 0 : isatty (fd))
Note: See TracBrowser for help on using the repository browser.