install.bin.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (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 2003 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <libgen.h>
#define FILE_BUFF 40960
int supress = 0;
void
usage(void)
{
"usage: install [-sd][-m mode][-g group][-u owner] "
"-f dir file ...\n");
}
void
{
int src_fd;
int dest_fd;
int count;
exit(1);
}
exit(1);
}
}
if (count == -1) {
perror("file_copy(read)");
exit(1);
}
if (!supress)
}
void
{
if (group) {
grp = 2;
grp = 3;
grp = 4;
grp = 5;
grp = 6;
grp = 7;
grp = 8;
grp = 1;
grp = 9;
grp = 10;
grp = 12;
grp = 0;
grp = 14;
grp = 25;
grp = 60001;
grp = 60002;
grp = 101;
else
} else {
grp = -1;
}
if (owner) {
own = 2;
own = 1;
own = 3;
own = 4;
own = 71;
own = 0;
own = 5;
own = 9;
own = 25;
own = 37;
own = 60001;
own = 60002;
/*
* This is a temporary HACK that should be removed!!!
*/
own = 0;
else {
exit(1);
}
} else {
own = -1;
}
perror("chown");
exit(1);
}
}
char *
find_basename(const char *str)
{
int i;
int len;
for (i = len-1; i >= 0; i--)
if (str[i] == '/')
return ((char *)(str + i + 1));
return ((char *)str);
}
int
{
int c;
int errflg = 0;
int dirflg = 0;
int mode = -1;
char dest_file[MAXPATHLEN];
switch (c) {
case 'f':
break;
case 'g':
break;
case 'u':
break;
case 'd':
dirflg = 1;
break;
case 'm':
break;
case 's':
supress = 1;
break;
case '?':
errflg++;
break;
}
}
if (errflg) {
usage();
return (1);
}
usage();
return (1);
}
"install: no destination directory specified.\n");
return (1);
}
if (dirflg) {
continue;
} else {
perror("install: stat");
return (1);
}
}
if (!supress) {
(void) printf(
"install: mkdirp of %s failed\n",
}
} else if (!supress) {
(void) printf("directory %s created\n",
}
} else {
}
if (mode != -1) {
umask(0);
perror("chmod");
return (1);
}
}
}
return (0);
}