/*
* 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 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
* Copyright 2015 Nexenta Systems, Inc. All rights reserved.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
#include <stdio.h>
#include <archives.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include "pkglocale.h"
#include "pkglibmsgs.h"
/*
* Defines for cpio/compression checks.
*/
#define MASK_CK(x, y) (((x) & (y)) == (y))
/* location of distributed file system types database */
/* character array used to hold dfs types database contents */
/* forward declarations */
static void _InitRemoteFstypes(void);
int isFdRemote(int a_fd);
int isPathRemote(char *a_path);
int isFstypeRemote(char *a_fstype);
/*
* Name: isdir
* Description: determine if specified path exists and is a directory
* Arguments: path - pointer to string representing the path to verify
* returns: 0 - directory exists
* 1 - directory does not exist or is not a directory
* NOTE: errno is set appropriately
*/
int
{
/* return error if path does not exist */
return (1);
}
/* return error if path is not a directory */
return (1);
}
return (0);
}
/*
* Name: isfile
* Description: determine if specified path exists and is a directory
* Arguments: dir - pointer to string representing the directory where
* the file is located
* == NULL - use "file" argument only
* file - pointer to string representing the file to verify
* Returns: 0 - success - file exists
* 1 - failure - file does not exist OR is not a file
* NOTE: errno is set appropriately
*/
int
{
/* construct full path if directory specified */
if (dir) {
}
/* return error if path does not exist */
return (1);
}
/* return error if path is a directory */
return (1);
}
/* return error if path is not a file */
return (1);
}
return (0);
}
int
{
/*
* Compressed File Header.
*/
static union {
short int b_mag;
} cm;
int fd;
*iscomp = 0;
perror("");
}
return (0);
} else {
perror("");
return (0);
} else {
perror("");
return (0);
}
/*
* Try to determine if the file is a compressed
* file, if that fails, try to determine if it
* is a cpio archive, if that fails, then we
* fail!
*/
if (ISCOMPCPIO) {
*iscomp = 1;
return (1);
} else if (ISCPIO) {
path);
return (0);
}
return (1);
} else {
return (0);
}
}
}
}
/*
* Name: isPathRemote
* Description: determine if a path object is local or remote
* Arguments: a_path - [RO, *RO] - (char *)
* Pointer to string representing the path to check
* Returns: int
* 1 - the path is remote
* 0 - the path is local to this system
* -1 - cannot determine if path is remote or local
*/
int
{
int r;
if (r < 0) {
return (-1);
}
}
/*
* Name: isFdRemote
* Description: determine if an open file is local or remote
* Arguments: a_fd - [RO, *RO] - (int)
* Integer representing open file to check
* Returns: int
* 1 - the path is remote
* 0 - the path is local to this system
* -1 - cannot determine if path is remote or local
*/
int
{
int r;
if (r < 0) {
return (-1);
}
}
/*
* Name: isFstypeRemote
* Description: determine if a file system type is remote (distributed)
* Arguments: a_fstype - [RO, *RO] - (char *)
* Pointer to string representing the file system type
* to check
* Returns: int
* 1 - the file system type is remote
* 0 - the file system type is local to this system
*/
int
{
int i;
/* initialize the list if it is not yet initialized */
/* scan the list looking for the specified type */
for (i = 0; i < numRemoteFstypes; i++) {
return (1);
}
}
/* type not found in remote file system type list - is not remote */
return (0);
}
/*
* Name: _InitRemoteFstypes
* Description: initialize table of remote file system type names
* Arguments: none
* Returns: none
* Side Effects:
* - The global array "(char **)remoteFstypes" is set to the
* address of an array of string pointers, each of which represents
* a single remote file system type
* - The global variable "(long) numRemoteFstypes" is set to the total
* number of remote file system type strings (names) that are
* contained in the "remoteFstypes" global array.
* - numRemoteFstypes is initialized to "-1" before any attempt has been
* made to read the remote file system type name database.
*/
static void
_InitRemoteFstypes(void)
{
/* return if already initialized */
if (numRemoteFstypes > 0) {
return;
}
/* if list is uninitialized, start with zero */
if (numRemoteFstypes == -1) {
numRemoteFstypes = 0;
}
/* open the remote file system type database file */
/* no remote type database: use predefined remote types */
sizeof (char *) * (numRemoteFstypes+2));
return;
}
/*
* Read the remote file system type database; from fstypes(4):
*
* system utilities packages installed on the system. For each installed
* distributed file system type, there is a line that begins with the
* file system type name (for example, ``nfs''), followed by white space
* and descriptive text.
*
* Lines will look at lot like this:
*
* nfs NFS Utilities
* autofs AUTOFS Utilities
*/
if (format[0] == '\0') {
/* create bounded format: %ns */
}
sizeof (char *) * (numRemoteFstypes+1));
}
/* close database file and return */
}