]>
Dogcows Code - chaz/tar/blob - src/rmt.h
1 /* Definitions for communicating with a remote tape drive.
3 Copyright (C) 1988, 1992, 1996, 1997, 2001, 2003, 2004 Free
4 Software Foundation, Inc.
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)
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.
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. */
20 extern char *rmt_dev_name__
;
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 *);
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. */
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)))
43 #define __REM_BIAS (1 << 30)
46 # define O_CREAT 01000
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))
53 #define rmtaccess(dev_name, amode) \
54 (_remdev (dev_name) ? 0 : access (dev_name, amode))
56 #define rmtstat(dev_name, buffer) \
57 (_remdev (dev_name) ? (errno = EOPNOTSUPP), -1 : stat (dev_name, buffer))
59 #define rmtcreat(dev_name, mode, command) \
61 ? rmt_open__ (dev_name, 1 | O_CREAT, __REM_BIAS, command) \
62 : creat (dev_name, mode))
64 #define rmtlstat(dev_name, muffer) \
65 (_remdev (dev_name) ? (errno = EOPNOTSUPP), -1 : lstat (dev_name, buffer))
67 #define rmtread(fd, buffer, length) \
68 (_isrmt (fd) ? rmt_read__ (fd - __REM_BIAS, buffer, length) \
69 : safe_read (fd, buffer, length))
71 #define rmtwrite(fd, buffer, length) \
72 (_isrmt (fd) ? rmt_write__ (fd - __REM_BIAS, buffer, length) \
73 : full_write (fd, buffer, length))
75 #define rmtlseek(fd, offset, where) \
76 (_isrmt (fd) ? rmt_lseek__ (fd - __REM_BIAS, offset, where) \
77 : lseek (fd, offset, where))
79 #define rmtclose(fd) \
80 (_isrmt (fd) ? rmt_close__ (fd - __REM_BIAS) : close (fd))
82 #define rmtioctl(fd, request, argument) \
83 (_isrmt (fd) ? rmt_ioctl__ (fd - __REM_BIAS, request, argument) \
84 : ioctl (fd, request, argument))
87 (_isrmt (fd) ? (errno = EOPNOTSUPP), -1 : dup (fd))
89 #define rmtfstat(fd, buffer) \
90 (_isrmt (fd) ? (errno = EOPNOTSUPP), -1 : fstat (fd, buffer))
92 #define rmtfcntl(cd, command, argument) \
93 (_isrmt (fd) ? (errno = EOPNOTSUPP), -1 : fcntl (fd, command, argument))
95 #define rmtisatty(fd) \
96 (_isrmt (fd) ? 0 : isatty (fd))
This page took 0.044329 seconds and 5 git commands to generate.