backup.c File Reference

#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
#include <fcntl.h>
#include <utime.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/wait.h>
#include <stdio.h>
#include <dirent.h>

Include dependency graph for backup.c:

Go to the source code of this file.

Data Structures

struct  sorted

Defines

#define NAME_SIZE   _DIRENT_NAME_LEN
#define COPY_SIZE   4096
#define MAX_ENTRIES   512
#define MAX_PATH   256
#define NONFATAL   0
#define FATAL   1
#define NO_SAVINGS   512
#define OUT_OF_SPACE   2

Functions

 _PROTOTYPE (int main,(int argc, char **argv))
 _PROTOTYPE (void maketarget,(char *dir2))
 _PROTOTYPE (int make_dir,(char *dir))
 _PROTOTYPE (int stat_all,(char *dir1, int n))
 _PROTOTYPE (void sort_dir,(int m))
 _PROTOTYPE (void process,(int m, char *dir1, char *dir2))
 _PROTOTYPE (void swap,(struct sorted *sp1, struct sorted *sp2))
 _PROTOTYPE (int copy,(char *dir1, struct sorted *sp, char *cbuf2))
 _PROTOTYPE (int zcopy,(char *src, char *targ))
 _PROTOTYPE (void copydir,(char *dir1, char *dir2, char *namep))
 _PROTOTYPE (void newdisk,(char *dir))
 _PROTOTYPE (void usage,(void))
 _PROTOTYPE (void error,(int type, char *s1, char *s2, char *s3))
int main (int argc, argv)
void maketarget (char *dir2)
int make_dir (char *dir)
int stat_all (char *dir1, int n)
void sort_dir (int m)
void process (int m, char *dir1, char *dir2)
void swap (struct sorted *sp1, struct sorted *sp2)
int copy (char *dir1, struct sorted *sp, char *cbuf2)
int zcopy (char *src, char *targ)
void copydir (char *dir1, char *dir2, char *namep)
void newdisk (char *dir)
void usage ()
void error (int type, char *s1, char *s2, char *s3)

Variables

dirent dir_ent [MAX_ENTRIES]
int entries = 0
char copybuf [COPY_SIZE]
char * pname
int dflag
int jflag
int mflag
int nflag
int oflag
int rflag
int sflag
int tflag
int vflag
int zflag
int errno
char ** environ


Define Documentation

#define COPY_SIZE   4096
 

Definition at line 49 of file backup.c.

Referenced by copy().

#define FATAL   1
 

Definition at line 53 of file backup.c.

#define MAX_ENTRIES   512
 

Definition at line 50 of file backup.c.

Referenced by main().

#define MAX_PATH   256
 

Definition at line 51 of file backup.c.

#define NAME_SIZE   _DIRENT_NAME_LEN
 

Definition at line 46 of file backup.c.

#define NO_SAVINGS   512
 

Definition at line 54 of file backup.c.

Referenced by zcopy().

#define NONFATAL   0
 

Definition at line 52 of file backup.c.

Referenced by copy(), error(), process(), and stat_all().

#define OUT_OF_SPACE   2
 

Definition at line 55 of file backup.c.

Referenced by copy(), process(), and zcopy().


Function Documentation

_PROTOTYPE void  error,
(int type, char *s1, char *s2, char *s3) 
 

_PROTOTYPE void  usage,
(void) 
 

_PROTOTYPE void  newdisk,
(char *dir
 

_PROTOTYPE void  copydir,
(char *dir1, char *dir2, char *namep) 
 

_PROTOTYPE int  zcopy,
(char *src, char *targ) 
 

_PROTOTYPE int  copy,
(char *dir1, struct sorted *sp, char *cbuf2) 
 

_PROTOTYPE void  swap,
(struct sorted *sp1, struct sorted *sp2) 
 

_PROTOTYPE void  process,
(int m, char *dir1, char *dir2) 
 

_PROTOTYPE void  sort_dir,
(int m
 

_PROTOTYPE int  stat_all,
(char *dir1, int n
 

_PROTOTYPE int  make_dir,
(char *dir
 

_PROTOTYPE void  maketarget,
(char *dir2) 
 

_PROTOTYPE int  main,
(int argc, char **argv) 
 

int copy char *  dir1,
struct sorted sp,
char *  cbuf2
 

Definition at line 344 of file backup.c.

References close, COPY_SIZE, copybuf, creat, dflag, EIO, ENFILE, ENOSPC, errno, error, fd1, fd2, jflag, MAX_PATH, msg, n, NAME_SIZE, NONFATAL, O_RDONLY, oflag, open, OUT_OF_SPACE, p, pname, printf, read, rflag, S_IWUSR, sflag, strcmp, strcpy(), strlen(), strncat(), strncmp(), tflag, unlink, utime, vflag, write, zcopy(), and zflag.

void copydir char *  dir1,
char *  dir2,
char *  namep
 

Definition at line 499 of file backup.c.

References environ, error, execle, FATAL, fork, jflag, MAX_PATH, mflag, nflag, oflag, pid, pname, rflag, sflag, snprintf(), status, strcat(), strcpy(), tflag, vflag, wait, and zflag.

void error int  type,
char *  s1,
char *  s2,
char *  s3
 

Definition at line 579 of file backup.c.

References exit(), fprintf(), NONFATAL, pname, and stderr.

int main int  argc,
argv 
 

Definition at line 88 of file backup.c.

References c, closedir, cp, dflag, dir_ent, e, entries, error, FATAL, jflag, m, maketarget(), MAX_ENTRIES, memcpy(), mflag, n, nflag, NULL, oflag, opendir, perror(), pname, process(), readdir, rflag, s, S_IFDIR, S_IFMT, sflag, sort_dir(), stat, stat_all(), strcmp, strrchr(), sync, tflag, usage, vflag, and zflag.

int make_dir char *  dir  ) 
 

Definition at line 188 of file backup.c.

References close, environ, error, execle, FATAL, fork, pid, status, and wait.

Referenced by maketarget().

void maketarget char *  dir2  ) 
 

Definition at line 163 of file backup.c.

References access, c, make_dir(), MAX_PATH, p, and strcpy().

Referenced by main(), and newdisk().

void newdisk char *  dir  ) 
 

Definition at line 545 of file backup.c.

References environ, error, execle, FATAL, fork, maketarget(), pid, printf, status, and wait.

Referenced by process().

void process int  m,
char *  dir1,
char *  dir2
 

Definition at line 271 of file backup.c.

References cbuf, copy, error, FATAL, fmode(), if(), MAX_PATH, mflag, modtime(), NAME_SIZE, newdisk(), NONFATAL, OUT_OF_SPACE, printf, rflag, s, S_IFMT, S_IFREG, snprintf(), sp, stat, strlen(), strncat(), strncmp(), and zflag.

void sort_dir int  m  ) 
 

Definition at line 255 of file backup.c.

References sorted::namep, and strcmp.

Referenced by main().

int stat_all char *  dir1,
int  n
 

Definition at line 211 of file backup.c.

References cbuf, dirent::d_ino, dirent::d_name, d_name(), dir_ent, error, i, j, MAX_PATH, NAME_SIZE, NONFATAL, s, snprintf(), stat, and strcmp.

Referenced by main().

void swap struct sorted sp1,
struct sorted sp2
 

Definition at line 331 of file backup.c.

References d.

void usage void   ) 
 

Definition at line 572 of file backup.c.

References exit(), fprintf(), pname, and stderr.

int zcopy char *  src,
char *  targ
 

Definition at line 463 of file backup.c.

References close, environ, error, execle, FATAL, fork, NO_SAVINGS, O_RDWR, open, OUT_OF_SPACE, pid, rflag, s, status, strcat(), strcpy(), and wait.

Referenced by copy().


Variable Documentation

char copybuf[COPY_SIZE]
 

Definition at line 67 of file backup.c.

Referenced by copy().

int dflag
 

Definition at line 69 of file backup.c.

struct dirent dir_ent[MAX_ENTRIES]
 

Definition at line 57 of file backup.c.

Referenced by main(), map_range(), and stat_all().

int entries = 0
 

Definition at line 58 of file backup.c.

Referenced by apply_remove(), icmp_router_advertisement(), main(), traverse(), and unzRepair().

char** environ
 

Definition at line 19 of file environ.c.

int errno
 

Definition at line 70 of file rcp.c.

int jflag
 

Definition at line 69 of file backup.c.

int mflag
 

Definition at line 69 of file backup.c.

int nflag
 

Definition at line 69 of file backup.c.

int oflag
 

Definition at line 69 of file backup.c.

Referenced by copy(), copydir(), do_chown(), dumpfile(), fts_build(), imhand(), main(), mtrans(), and recvfile().

char* pname
 

Definition at line 68 of file backup.c.

Referenced by copy(), copydir(), error(), getparamlist(), main(), and usage().

int rflag
 

Definition at line 69 of file backup.c.

int sflag
 

Definition at line 69 of file backup.c.

int tflag
 

Definition at line 69 of file backup.c.

int vflag
 

Definition at line 69 of file backup.c.

int zflag
 

Definition at line 69 of file backup.c.


Generated on Fri Apr 14 23:04:54 2006 for minix by  doxygen 1.4.6