2 * Amanda, The Advanced Maryland Automatic Network Disk Archiver
3 * Copyright (c) 1991-1998 University of Maryland at College Park
6 * Permission to use, copy, modify, distribute, and sell this software and its
7 * documentation for any purpose is hereby granted without fee, provided that
8 * the above copyright notice appear in all copies and that both that
9 * copyright notice and this permission notice appear in supporting
10 * documentation, and that the name of U.M. not be used in advertising or
11 * publicity pertaining to distribution of the software without specific,
12 * written prior permission. U.M. makes no representations about the
13 * suitability of this software for any purpose. It is provided "as is"
14 * without express or implied warranty.
16 * U.M. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL U.M.
18 * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
19 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
20 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
21 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
23 * Author: James da Silva, Systems Design and Analysis Group
24 * Computer Science Department
25 * University of Maryland at College Park
28 /* NOTE: this driver is *deprecated* and should not be used. See the Device API
29 * in device-src/ for the new implementation.
33 * $Id: output-null.c,v 1.9 2006/06/02 00:56:06 paddy_s Exp $
35 * tapeio.c virtual tape interface for a null device.
41 #include "output-null.h"
42 #include "fileheader.h"
48 static off_t *amount_written = NULL;
49 static size_t open_count = 0;
58 off_t **amount_written_p = &amount_written;
60 (void)filename; /* Quiet unused parameter warning */
62 if ((flags & 3) != O_RDONLY) {
66 if ((fd = open("/dev/null", flags, mask)) >= 0) {
67 tapefd_setinfo_fake_label(fd, 1);
68 amtable_alloc((void **)amount_written_p,
70 SIZEOF(*amount_written),
74 amount_written[fd] = (off_t)0;
85 return read(fd, buffer, count);
94 ssize_t write_count = (ssize_t)count;
99 if (write_count <= 0) {
100 return 0; /* special case */
103 if ((length = tapefd_getinfo_length(fd)) > (off_t)0) {
104 kbytes_left = length - amount_written[fd];
105 if ((off_t)(write_count / 1024) > kbytes_left) {
106 write_count = (ssize_t)kbytes_left * 1024;
109 amount_written[fd] += (off_t)((write_count + 1023) / 1024);
110 if (write_count <= 0) {
114 r = write(fd, buffer, (size_t)write_count);
127 null_tapefd_resetofs(
130 (void)fd; /* Quiet unused parameter warning */
136 struct am_mt_status *stat)
138 (void)fd; /* Quiet unused parameter warning */
140 memset((void *)stat, 0, SIZEOF(*stat));
141 stat->online_valid = 1;
151 (void)filename; /* Quiet unused parameter warning */
153 return stat("/dev/null", buf);
161 (void)filename; /* Quiet unused parameter warning */
163 return access("/dev/null", mode);
170 amount_written[fd] = (off_t)0;
178 amount_written[fd] = (off_t)0;
187 (void)fd; /* Quiet unused parameter warning */
188 (void)count; /* Quiet unused parameter warning */
198 (void)fd; /* Quiet unused parameter warning */
199 (void)count; /* Quiet unused parameter warning */
205 null_tapefd_can_fork(
208 (void)fd; /* Quiet unused parameter warning */