]>
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 Free Software
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_path__
;
22 int rmt_open__ (const char *, int, int, const char *);
23 int rmt_close__ (int);
24 ssize_t
rmt_read__ (int, char *, size_t);
25 ssize_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(Path) \
36 (!force_local_option && (rmt_path__ = strchr (Path, ':')) \
37 && rmt_path__ > (Path) && ! memchr (Path, rmt_path__ - (Path), '/'))
42 #define __REM_BIAS (1 << 30)
45 # define O_CREAT 01000
48 #define rmtopen(Path, Oflag, Mode, Command) \
49 (_remdev (Path) ? rmt_open__ (Path, Oflag, __REM_BIAS, Command) \
50 : open (Path, Oflag, Mode))
52 #define rmtaccess(Path, Amode) \
53 (_remdev (Path) ? 0 : access (Path, Amode))
55 #define rmtstat(Path, Buffer) \
56 (_remdev (Path) ? (errno = EOPNOTSUPP), -1 : stat (Path, Buffer))
58 #define rmtcreat(Path, Mode, Command) \
60 ? rmt_open__ (Path, 1 | O_CREAT, __REM_BIAS, Command) \
63 #define rmtlstat(Path, Buffer) \
64 (_remdev (Path) ? (errno = EOPNOTSUPP), -1 : lstat (Path, Buffer))
66 #define rmtread(Fd, Buffer, Length) \
67 (_isrmt (Fd) ? rmt_read__ (Fd - __REM_BIAS, Buffer, Length) \
68 : safe_read (Fd, Buffer, Length))
70 #define rmtwrite(Fd, Buffer, Length) \
71 (_isrmt (Fd) ? rmt_write__ (Fd - __REM_BIAS, Buffer, Length) \
72 : full_write (Fd, Buffer, Length))
74 #define rmtlseek(Fd, Offset, Where) \
75 (_isrmt (Fd) ? rmt_lseek__ (Fd - __REM_BIAS, Offset, Where) \
76 : lseek (Fd, Offset, Where))
78 #define rmtclose(Fd) \
79 (_isrmt (Fd) ? rmt_close__ (Fd - __REM_BIAS) : close (Fd))
81 #define rmtioctl(Fd, Request, Argument) \
82 (_isrmt (Fd) ? rmt_ioctl__ (Fd - __REM_BIAS, Request, Argument) \
83 : ioctl (Fd, Request, Argument))
86 (_isrmt (Fd) ? (errno = EOPNOTSUPP), -1 : dup (Fd))
88 #define rmtfstat(Fd, Buffer) \
89 (_isrmt (Fd) ? (errno = EOPNOTSUPP), -1 : fstat (Fd, Buffer))
91 #define rmtfcntl(Fd, Command, Argument) \
92 (_isrmt (Fd) ? (errno = EOPNOTSUPP), -1 : fcntl (Fd, Command, Argument))
94 #define rmtisatty(Fd) \
95 (_isrmt (Fd) ? 0 : isatty (Fd))
This page took 0.042745 seconds and 4 git commands to generate.