#include <sys/types.h>#include <stddef.h>#include <stdio.h>#include <sys/stat.h>#include <utime.h>#include <string.h>#include <signal.h>#include <dirent.h>#include <errno.h>#include <fcntl.h>#include <stdlib.h>#include <unistd.h>#include <time.h>#include <sys/wait.h>Include dependency graph for synctree.c:

Go to the source code of this file.
Data Structures | |
| struct | mode |
| struct | entry |
Defines | |
| #define | nil 0 |
| #define | LITTLE_ENDIAN 0 |
| #define | USE_SHADOWING 0 |
| #define | PATH_MAX 1024 |
| #define | S_ISLNK(mode) (0) |
| #define | lstat stat |
| #define | symlink(path1, path2) (errno= ENOSYS, -1) |
| #define | readlink(path, buf, len) (errno= ENOSYS, -1) |
| #define | NUMBYTES 4 |
| #define | CHUNK 4096 |
| #define | BUCKSIZE (1+NUMBYTES+CHUNK) |
| #define | DPRINTF(format, arg) |
| #define | transparent 0 |
| #define | isvisible(name) ((void) 0) |
| #define | arraysize(a) (sizeof(a) / sizeof((a)[0])) |
| #define | arraylimit(a) ((a) + arraysize(a)) |
| #define | cancellink() ((void) islink()) |
| #define | wwrite(buf, n) (memcpy(buckp, (buf), (n)), buckp+= (n), buckn+= (n)) |
| #define | P_EXIT 1 |
| #define | P_SHADOW 2 |
Enumerations | |
| enum | orders { ENTER = 128, ADVANCE, CAT, MORE, CANCEL, DIE, DIE_BAD, POSITIVE, NEGATIVE, PASS_YES, PASS_NO } |
| enum | answers { PATH = 128, LINK, DATA, NODATA, DONE, SYMLINK, YES, NO } |
| enum | action { ADD, COMPARE, DELETE } |
Functions | |
| static void | because () |
| static void | perr (char *label) |
| static void | perrx (char *label) |
| static void | isbackup (int slave) |
| static char * | addpath (char *p, char *n) |
| static void | setpath (struct entry *e) |
| static void | sort (struct entry **ae) |
| static void | enter () |
| static char * | link_islink (struct stat *stp, const char *file) |
| static char * | islink () |
| static void | setstat (ino_t ino, struct stat *stp) |
| static int | getstat (char *name, struct stat *stp) |
| static int | advance () |
| static enum orders | request () |
| static void | report () |
| static void | inform (enum answers a) |
| static void | sendnum (long n) |
| static void | send (char *buf, int n) |
| static void | sendstat (struct stat *stp) |
| static int | ask () |
| static void | slave () |
| static int | execute (char **argv) |
| static int | removedir (char *dir) |
| static void | order (enum orders o) |
| static void | rread (char *buf, int n) |
| static enum answers | answer () |
| static long | recnum () |
| static int | receive (char *buf, int max) |
| static void | recstat (struct stat *stp) |
| static int | key () |
| static int | ask (int def) |
| static void | setmodes (int silent) |
| static void | makeold () |
| static void | bail_out (int sig) |
| static int | makenode (char *name, int mode, dev_t addr, off_t size) |
| static void | add (int update) |
| static int | delete (int update) |
| static int | different () |
| static void | compare () |
| if (if S done) | |
| return (c=strcmp(Sp, p)) | |
| static void | master () |
| static void | mediator () |
| static void | startprocess (void(*proc)(), char *machine, char *path, int p_flags) |
| void | splitcolon (char *path, char **amach, char **adir) |
| static void | Usage () |
| main (int argc, char **argv) | |
Variables | |
| static int | install = 0 |
| static int | interact = 0 |
| static int | force = 0 |
| static int | backup = 0 |
| static char | SYNCNAME [] = "synctree" |
| static char | SLAVENAME [] = "==SLAVE==" |
| static char | MASTERNAME [] = "==MASTER==" |
| static char | BACKUP [] = ".backup" |
| static int | filemodes |
| static int | chan [2] = { 0, 1 } |
| static char | bucket [BUCKSIZE] |
| static char * | buckp = bucket |
| static int | buckn = 0 |
| static char * | arg0 |
| static int | ex = 0 |
| static char | path [PATH_MAX+1] |
| static char | lnkpth [PATH_MAX+1] |
| static char * | linkpath |
| static struct stat | st |
| static char | Spath [PATH_MAX+1] |
| static char | Slnkpth [PATH_MAX+1] |
| static char * | Slinkpath = nil |
| static struct stat | Sst |
| static struct entry * | E = nil |
| static int | busy = 0 |
| static int | done = 0 |
| static int | Sdone = 0 |
| static enum action | c |
| char * | Sp |
| char * | p |
| if Sp return | ADD |
| if p return | DELETE |
|
|
Definition at line 299 of file synctree.c. |
|
|
Definition at line 298 of file synctree.c. |
|
|
Definition at line 81 of file synctree.c. Referenced by rread(). |
|
|
Definition at line 409 of file synctree.c. |
|
|
Definition at line 64 of file synctree.c. |
|
|
Definition at line 124 of file synctree.c. |
|
|
Definition at line 170 of file synctree.c. Referenced by startprocess(). |
|
|
Definition at line 47 of file synctree.c. |
|
|
Definition at line 58 of file synctree.c. |
|
|
Definition at line 23 of file synctree.c. |
|
|
Definition at line 63 of file synctree.c. |
|
|
Definition at line 1284 of file synctree.c. Referenced by main(), and startprocess(). |
|
|
Definition at line 1285 of file synctree.c. Referenced by main(), and startprocess(). |
|
|
Definition at line 52 of file synctree.c. |
|
|
Definition at line 60 of file synctree.c. |
|
|
Definition at line 57 of file synctree.c. |
|
|
Definition at line 59 of file synctree.c. |
|
|
Definition at line 169 of file synctree.c. Referenced by advance(). |
|
|
Definition at line 48 of file synctree.c. Referenced by startprocess(). |
|
|
Definition at line 589 of file synctree.c. |
|
|
Definition at line 1171 of file synctree.c. |
|
|
Definition at line 107 of file synctree.c. |
|
|
Definition at line 86 of file synctree.c. |
|
|
Definition at line 968 of file synctree.c. References answer, arg0, ask(), backup, because(), CANCEL, CAT, CHUNK, close, creat, DATA, ENTER, force, fprintf(), interact, link, makenode(), makeold(), mkdir, n, nil, order, perr(), printf, receive, S_IFBLK, S_IFCHR, S_IFDIR, S_IFIFO, S_IFLNK, S_IFMT, S_IFREG, S_ISLNK, setmodes(), Slinkpath, Slnkpth, Spath, Sst, st, stat::st_mode, stat::st_mtime, stat::st_rdev, stat::st_size, stderr, symlink, and write. |
|
||||||||||||
|
Definition at line 191 of file synctree.c. References arg0, exit(), fprintf(), PATH_MAX, stderr, and strlen(). |
|
|
Definition at line 476 of file synctree.c. References E, malloc(), nil, strcpy(), and transparent. |
|
|
Definition at line 775 of file synctree.c. |
|
|
Definition at line 851 of file synctree.c. References answer, c, chan, fflush(), key, NEGATIVE, order, POSITIVE, printf, stdout, y, and YES. |
|
|
|
|
|
Definition at line 940 of file synctree.c. References arg0, DIE_BAD, exit(), fprintf(), makeold(), order, SIG_IGN, signal(), Spath, and stderr. Referenced by master(), and select_image(). |
|
|
Definition at line 138 of file synctree.c. References errno, ex, fprintf(), stderr, and strerror(). Referenced by add(), delete(), makeold(), setmodes(), and slave(). |
|
|
Definition at line 1149 of file synctree.c. References add(), different(), enter(), ENTER, force, install, order, path, printf, S_ISDIR, setmodes(), Sst, st, stat::st_mode, and stat::st_mtime. |
|
|
Definition at line 1085 of file synctree.c. References ask(), because(), cancellink, ex, force, fprintf(), install, interact, path, printf, removedir(), S_ISDIR, st, stat::st_mode, stderr, unlink, and update(). |
|
|
Definition at line 1118 of file synctree.c. References install, linkpath, lnkpth, nil, S_IFBLK, S_IFCHR, S_IFDIR, S_IFIFO, S_IFLNK, S_IFMT, S_IFREG, Slinkpath, Slnkpth, Sst, st, stat::st_mode, stat::st_mtime, stat::st_rdev, stat::st_size, and strcmp. Referenced by compare(). |
|
|
Definition at line 267 of file synctree.c. References arg0, closedir, entry::con, d, e, E, fprintf(), malloc(), entry::next, nil, opendir, path, readdir, sort(), stderr, strcpy(), and strlen(). Referenced by compare(), incr_link(), and slave(). |
|
|
Definition at line 705 of file synctree.c. References execvp, fork, perr(), perrx(), pid, r, status, and wait. |
|
||||||||||||
|
Definition at line 441 of file synctree.c. References backup, BACKUP, errno, filemodes, lseek, lstat, md, read, S_IFREG, S_ISBLK, setstat(), stat::st_gid, stat::st_ino, stat::st_mode, stat::st_mtime, stat::st_rdev, stat::st_size, stat::st_uid, and strcmp. Referenced by modtime(), and setmodes(). |
|
|
Definition at line 1179 of file synctree.c. |
|
|
Definition at line 580 of file synctree.c. References buckn, buckp, DPRINTF, and PATH. Referenced by slave(). |
|
|
Definition at line 173 of file synctree.c. References backup, BACKUP, ENOENT, errno, filemodes, O_RDONLY, O_RDWR, open, and perrx(). Referenced by startprocess(). |
|
|
Definition at line 411 of file synctree.c. References ENOENT, errno, link_islink(), nil, path, perrx(), and st. |
|
|
Definition at line 834 of file synctree.c. References c, EOF, feof, getchar, isatty, putchar, and stdin. |
|
||||||||||||
|
Definition at line 301 of file synctree.c. References arraylimit, close, dev, free, link::ino, lp, link::next, nil, off, and PATH_MAX. |
|
||||||||||||
|
Definition at line 1367 of file synctree.c. References alarm, arg0, chan, close, dup2, ex, exit(), force, fork, install, interact, master(), MASTERNAME, mediator(), nil, P_EXIT, P_SHADOW, perrx(), pipe, r, slave(), SLAVENAME, splitcolon(), startprocess(), strcmp, strrchr(), Usage(), and wait. |
|
||||||||||||||||||||
|
Definition at line 955 of file synctree.c. References backup, close, creat, mknod, and r. Referenced by add(). |
|
|
Definition at line 923 of file synctree.c. References arg0, because(), ENOENT, errno, fprintf(), Spath, stderr, and utime. Referenced by add(), and bail_out(). |
|
|
Definition at line 1191 of file synctree.c. References a, add(), ADD, advance(), ADVANCE, answer, arg0, backup, bail_out(), compare, COMPARE, DELETE, DIE, DIE_BAD, DONE, ex, exit(), fflush(), fprintf(), LINK, nil, order, PATH, receive, recstat(), Sdone, SIG_IGN, SIGHUP, SIGINT, signal(), SIGPIPE, SIGTERM, Slinkpath, Slnkpth, Spath, Sst, stderr, stdout, SYMLINK, and umask. Referenced by exec_bootstrap(), initialize(), main(), and startprocess(). |
|
|
Definition at line 1257 of file synctree.c. References ask(), DIE, DIE_BAD, ex, NEGATIVE, order, PASS_NO, PASS_YES, POSITIVE, and request. Referenced by main(). |
|
|
Definition at line 738 of file synctree.c. |
|
|
Definition at line 144 of file synctree.c. References arg0, errno, ex, fprintf(), stderr, and strerror(). |
|
|
Definition at line 150 of file synctree.c. References exit(), and perr(). Referenced by execute(), isbackup(), islink(), main(), order(), report(), request(), rread(), setstat(), and startprocess(). |
|
||||||||||||
|
Definition at line 810 of file synctree.c. References arg0, exit(), fprintf(), n, recnum(), rread(), and stderr. |
|
|
Definition at line 789 of file synctree.c. |
|
|
Definition at line 824 of file synctree.c. References recnum(). Referenced by master(). |
|
|
Definition at line 727 of file synctree.c. References argv, execute(), nil, and printf. Referenced by delete(). |
|
|
Definition at line 559 of file synctree.c. References buckn, buckp, chan, DPRINTF, perrx(), r, and write. |
|
|
Definition at line 529 of file synctree.c. References arg0, bp, chan, exit(), fprintf(), perrx(), read, and stderr. |
|
|
Referenced by _get_entry(), dcheck(), getmp(), lexi(), lookup(), meta(), sole_reduction(), and unzReadCurrentFile(). |
|
||||||||||||
|
Definition at line 748 of file synctree.c. References arg0, buckn, buckp, BUCKSIZE, chan, exit(), fprintf(), memcpy(), perrx(), r, read, and stderr. |
|
||||||||||||
|
Definition at line 607 of file synctree.c. |
|
|
Definition at line 591 of file synctree.c. References NUMBYTES, and wwrite. Referenced by send(), and sendstat(). |
|
|
Definition at line 614 of file synctree.c. References sendnum(). Referenced by slave(). |
|
|
Definition at line 877 of file synctree.c. References utimbuf::actime, arg0, backup, because(), change(), chmod, chown, errno, fprintf(), geteuid, getstat(), utimbuf::modtime, printf, S_ISLNK, S_ISREG, setstat(), Spath, Sst, st, stat::st_gid, stat::st_ino, stat::st_mode, stat::st_mtime, stat::st_uid, stderr, time, and utime. |
|
|
Definition at line 218 of file synctree.c. |
|
||||||||||||
|
Definition at line 425 of file synctree.c. References BACKUP, filemodes, lseek, md, perrx(), stat::st_gid, stat::st_mode, stat::st_rdev, stat::st_size, stat::st_uid, and write. |
|
|
Definition at line 626 of file synctree.c. References advance(), ADVANCE, arg0, ask(), because(), CANCEL, cancellink, CAT, CHUNK, close, DATA, DIE, die, DIE_BAD, DONE, done, enter(), ENTER, ex, exit(), fprintf(), inform(), LINK, linkpath, lnkpth, n, NEGATIVE, nil, NO, NODATA, O_RDONLY, open, PASS_NO, PASS_YES, path, PATH, perr(), POSITIVE, read, report(), request, run(), S_ISLNK, send, sendstat(), st, stat::st_mode, stderr, strlen(), SYMLINK, and YES. Referenced by main(), and startprocess(). |
|
|
Definition at line 231 of file synctree.c. References e1, e2, if(), entry::next, nil, sort(), and strcmp. |
|
||||||||||||||||
|
Definition at line 1339 of file synctree.c. Referenced by main(). |
|
||||||||||||||||||||
|
Definition at line 1287 of file synctree.c. References argv, chdir, ENOENT, errno, ex, execvp, exit(), flags, force, fprintf(), install, interact, isbackup(), isvisible, m, master(), MASTERNAME, mkdir, nil, P_EXIT, P_SHADOW, perrx(), printf, slave(), SLAVENAME, stderr, strchr, SYNCNAME, and USE_SHADOWING. Referenced by main(). |
|
|
Definition at line 1359 of file synctree.c. |
|
|
Definition at line 1186 of file synctree.c. |
|
|
Definition at line 135 of file synctree.c. |
|
|
Definition at line 76 of file synctree.c. Referenced by getstat(), isbackup(), and setstat(). |
|
|
Definition at line 69 of file synctree.c. Referenced by add(), getstat(), isbackup(), makenode(), master(), and setmodes(). |
|
|
Definition at line 82 of file synctree.c. |
|
|
Definition at line 84 of file synctree.c. |
|
|
Definition at line 83 of file synctree.c. |
|
|
Definition at line 938 of file synctree.c. |
|
|
|
|
|
Definition at line 79 of file synctree.c. Referenced by ask(), main(), order(), report(), request(), and rread(). |
|
|
Definition at line 1187 of file synctree.c. |
|
|
Definition at line 1169 of file synctree.c. |
|
|
Definition at line 216 of file synctree.c. |
|
|
Definition at line 136 of file synctree.c. |
|
|
Definition at line 77 of file synctree.c. Referenced by getstat(), isbackup(), and setstat(). |
|
|
Definition at line 68 of file synctree.c. |
|
|
Definition at line 66 of file synctree.c. Referenced by compare(), delete(), different(), init(), initarg(), main(), setvar(), and startprocess(). |
|
|
Definition at line 67 of file synctree.c. Referenced by add(), delete(), main(), parsecmd(), and startprocess(). |
|
|
Definition at line 184 of file synctree.c. Referenced by different(), and slave(). |
|
|
Definition at line 183 of file synctree.c. Referenced by different(), and slave(). |
|
|
Definition at line 73 of file synctree.c. Referenced by main(), and startprocess(). |
|
|
Definition at line 1177 of file synctree.c. |
|
|
Definition at line 182 of file synctree.c. |
|
|
Definition at line 1169 of file synctree.c. Referenced by master(). |
|
|
Definition at line 72 of file synctree.c. Referenced by main(), and startprocess(). |
|
|
Definition at line 188 of file synctree.c. Referenced by add(), different(), and master(). |
|
|
Definition at line 187 of file synctree.c. Referenced by add(), different(), and master(). |
|
|
Definition at line 1177 of file synctree.c. |
|
|
Definition at line 186 of file synctree.c. Referenced by add(), bail_out(), makeold(), master(), and setmodes(). |
|
|
Definition at line 189 of file synctree.c. Referenced by add(), compare(), different(), master(), and setmodes(). |
|
|
Definition at line 185 of file synctree.c. |
|
|
Definition at line 71 of file synctree.c. Referenced by startprocess(). |
1.4.6