/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
* Portions of this source code were derived from Berkeley 4.3 BSD
* under license from the Regents of the University of California.
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <unistd.h>
#include <ctype.h>
#include <limits.h>
#include <errno.h>
#include <fcntl.h>
#include "cpio.h"
/*
* Allocation wrappers. Used to centralize error handling for
* failed allocations.
*/
static void *
{
return (NULL);
}
/*
* Note: unlike the other e_*lloc functions, e_realloc does not zero out the
* additional memory it returns. Ensure that you do not trust its contents
* when you call it.
*/
void *
{
return (e_alloc_fail(flag));
}
return (ret);
}
char *
{
return (e_alloc_fail(flag));
}
return (ret);
}
void *
{
return (e_alloc_fail(flag));
}
return (ret);
}
void *
{
return (e_alloc_fail(flag));
}
return (ret);
}
/*
* Simple printf() which only support "%s" conversion.
* We need secure version of printf since format string can be supplied
* from gettext().
*/
void
{
const char *s = fmt;
while (*s != '\0') {
if (*s != '%') {
continue;
}
s++;
if (*s != 's') {
continue;
}
s++;
}
}
/*
* Step through a file discovering and recording pairs of data and hole
* If there is no holes found, NULL is returned.
*
* Note: According to lseek(2), only filesystems which support
* fpathconf(_PC_MIN_HOLE_SIZE) support SEEK_HOLE. For filesystems
* that do not supply information about holes, the file will be
* represented as one entire data region.
*/
static holes_list_t *
{
return (NULL);
cnt = 0;
hole = 0;
/* no more data till the end of file */
} else {
/* assume data starts from the * beginning */
data = 0;
}
}
/* assume that data ends at the end of file */
}
/* no holes */
break;
}
/* set data and hole */
cnt++;
}
/*
* reset to the beginning, otherwise subsequent read calls would
* get EOF
*/
return (hlh);
}
/*
* Calculate the real data size in the sparse file.
*/
static off_t
{
size = 0;
}
return (size);
}
/*
* Convert val to digit string and put it in str. The next address
* of the last digit is returned.
*/
static char *
{
}
/*
* sequence.
* <data> <sp> <hole> <sp>
*/
static void
{
char *p;
p = str;
*p++ = ' ';
*p++ = ' ';
}
*--p = '\0';
}
/*
* Convert decimal str into unsigned long long value. The end pointer
* is returned.
*/
static const char *
{
char *np;
str++;
return (NULL);
errno = 0;
return (NULL); /* invalid value */
return (NULL); /* invalid input */
return (np);
}
static void
{
}
}
/*
* When a hole is detected, non NULL holes_info pointer is returned.
* If we are in copy-out mode, holes_list is converted to string (holesdata)
* which will be prepended to file contents. The holesdata is a character
* string and in the format of:
*
* <data size(%10u)><SP><file size(%llu)><SP>
* <SP><data off><SP><hole off><SP><data off><SP><hole off> ...
*
* This string is parsed by parse_holesholes() in copy-in mode to restore
* the sparse info.
*/
{
return (NULL);
if (!pass_mode) {
/*
* Convert into string data, and place it to after
* the first 2 fixed entries.
*/
/*
* Add the first two fixed entries. The size of holesdata
* includes '\0' at the end of data
*/
/* calc real file size without holes */
}
return (hi);
}
/*
* The holesdata information is in the following format:
* <data size(%10u)><SP><file size(%llu)><SP>
* <SP><data off><SP><hole off><SP><data off><SP><hole off> ...
* read_holes_header() allocates holes_info_t, and read the first 2
* entries (data size and file size). The rest of holesdata is
* read by parse_holesdata().
*/
{
/* read prepended holes data size */
bad:
return (NULL);
}
/* read original(expanded) file size */
goto bad;
/* sanity check */
goto bad;
}
return (hi);
}
int
{
/* create hole list */
while (*str != '\0') {
/* link list */
/* read the string token for data */
goto bad;
/* there must be single blank space in between */
if (*str != ' ')
goto bad;
/* read the string token for hole */
goto bad;
}
/* check to see if offset is in ascending order */
loff = -1;
goto bad;
/* data and hole can be equal */
goto bad;
}
/* The last hole offset should match original file size */
bad:
return (1);
}
return (0);
}
void
{
}