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
29 * $Id: output-null.c,v 1.9 2006/06/02 00:56:06 paddy_s Exp $
31 * tapeio.c virtual tape interface for a null device.
37 #include "output-null.h"
38 #include "fileheader.h"
44 static off_t *amount_written = NULL;
45 static size_t open_count = 0;
54 off_t **amount_written_p = &amount_written;
56 (void)filename; /* Quiet unused parameter warning */
58 if ((flags & 3) != O_RDONLY) {
62 if ((fd = open("/dev/null", flags, mask)) >= 0) {
63 tapefd_setinfo_fake_label(fd, 1);
64 amtable_alloc((void **)amount_written_p,
66 SIZEOF(*amount_written),
70 amount_written[fd] = (off_t)0;
81 return read(fd, buffer, count);
90 ssize_t write_count = (ssize_t)count;
95 if (write_count <= 0) {
96 return 0; /* special case */
99 if ((length = tapefd_getinfo_length(fd)) > (off_t)0) {
100 kbytes_left = length - amount_written[fd];
101 if ((off_t)(write_count / 1024) > kbytes_left) {
102 write_count = (ssize_t)kbytes_left * 1024;
105 amount_written[fd] += (off_t)((write_count + 1023) / 1024);
106 if (write_count <= 0) {
110 r = write(fd, buffer, (size_t)write_count);
123 null_tapefd_resetofs(
126 (void)fd; /* Quiet unused parameter warning */
132 struct am_mt_status *stat)
134 (void)fd; /* Quiet unused parameter warning */
136 memset((void *)stat, 0, SIZEOF(*stat));
137 stat->online_valid = 1;
147 (void)filename; /* Quiet unused parameter warning */
149 return stat("/dev/null", buf);
157 (void)filename; /* Quiet unused parameter warning */
159 return access("/dev/null", mode);
166 amount_written[fd] = (off_t)0;
174 amount_written[fd] = (off_t)0;
183 (void)fd; /* Quiet unused parameter warning */
184 (void)count; /* Quiet unused parameter warning */
194 (void)fd; /* Quiet unused parameter warning */
195 (void)count; /* Quiet unused parameter warning */
201 null_tapefd_can_fork(
204 (void)fd; /* Quiet unused parameter warning */