version 1.34, 2003/06/03 02:56:24 |
version 1.35, 2003/06/10 22:20:54 |
|
|
void file_flush(int, int); |
void file_flush(int, int); |
|
|
int |
int |
main(argc, argv) |
main(int argc, char *argv[]) |
int argc; |
|
char *argv[]; |
|
{ |
{ |
struct stat from_sb, to_sb; |
struct stat from_sb, to_sb; |
mode_t *set; |
mode_t *set; |
|
|
* build a path name and install the file |
* build a path name and install the file |
*/ |
*/ |
void |
void |
install(from_name, to_name, fset, flags) |
install(char *from_name, char *to_name, u_long fset, u_int flags) |
char *from_name, *to_name; |
|
u_long fset; |
|
u_int flags; |
|
{ |
{ |
struct stat from_sb, to_sb; |
struct stat from_sb, to_sb; |
struct utimbuf utb; |
struct utimbuf utb; |
|
|
* copy from one file to another |
* copy from one file to another |
*/ |
*/ |
void |
void |
copy(from_fd, from_name, to_fd, to_name, size, sparse) |
copy(int from_fd, char *from_name, int to_fd, char *to_name, off_t size, |
int from_fd, to_fd; |
int sparse) |
char *from_name, *to_name; |
|
off_t size; |
|
int sparse; |
|
{ |
{ |
ssize_t nr, nw; |
ssize_t nr, nw; |
int serrno; |
int serrno; |
|
|
* compare two files; non-zero means files differ |
* compare two files; non-zero means files differ |
*/ |
*/ |
int |
int |
compare(from_fd, from_name, from_len, to_fd, to_name, to_len) |
compare(int from_fd, const char *from_name, size_t from_len, int to_fd, |
int from_fd; |
const char *to_name, size_t to_len) |
const char *from_name; |
|
size_t from_len; |
|
int to_fd; |
|
const char *to_name; |
|
size_t to_len; |
|
{ |
{ |
caddr_t p1, p2; |
caddr_t p1, p2; |
size_t length, remainder; |
size_t length, remainder; |
|
|
* use strip(1) to strip the target file |
* use strip(1) to strip the target file |
*/ |
*/ |
void |
void |
strip(to_name) |
strip(char *to_name) |
char *to_name; |
|
{ |
{ |
int serrno, status; |
int serrno, status; |
char * volatile path_strip; |
char * volatile path_strip; |
|
|
* build directory heirarchy |
* build directory heirarchy |
*/ |
*/ |
void |
void |
install_dir(path) |
install_dir(char *path) |
char *path; |
|
{ |
{ |
char *p; |
char *p; |
struct stat sb; |
struct stat sb; |
|
|
* print a usage message and die |
* print a usage message and die |
*/ |
*/ |
void |
void |
usage() |
usage(void) |
{ |
{ |
(void)fprintf(stderr, "\ |
(void)fprintf(stderr, "\ |
usage: install [-bCcpSs] [-B suffix] [-f flags] [-g group] [-m mode] [-o owner] file1 file2\n\ |
usage: install [-bCcpSs] [-B suffix] [-f flags] [-g group] [-m mode] [-o owner] file1 file2\n\ |
|
|
* create a temporary file based on path and open it |
* create a temporary file based on path and open it |
*/ |
*/ |
int |
int |
create_tempfile(path, temp, tsize) |
create_tempfile(char *path, char *temp, size_t tsize) |
char *path; |
|
char *temp; |
|
size_t tsize; |
|
{ |
{ |
char *p; |
char *p; |
|
|
|
|
* create a new file, overwriting an existing one if necessary |
* create a new file, overwriting an existing one if necessary |
*/ |
*/ |
int |
int |
create_newfile(path, sbp) |
create_newfile(char *path, struct stat *sbp) |
char *path; |
|
struct stat *sbp; |
|
{ |
{ |
char backup[MAXPATHLEN]; |
char backup[MAXPATHLEN]; |
|
|
|
|
*/ |
*/ |
|
|
int |
int |
file_write(fd, str, cnt, rem, isempt, sz) |
file_write(int fd, char *str, size_t cnt, int *rem, int *isempt, int sz) |
int fd; |
|
char *str; |
|
size_t cnt; |
|
int *rem; |
|
int *isempt; |
|
int sz; |
|
{ |
{ |
char *pt; |
char *pt; |
char *end; |
char *end; |
|
|
* let us create a hole at the end. To get the last block with zeros, we |
* let us create a hole at the end. To get the last block with zeros, we |
* write the last BYTE with a zero (back up one byte and write a zero). |
* write the last BYTE with a zero (back up one byte and write a zero). |
*/ |
*/ |
|
|
void |
void |
file_flush(int fd, int isempt) |
file_flush(int fd, int isempt) |
{ |
{ |