version 1.17, 2006/02/01 19:06:24 |
version 1.18, 2008/05/13 02:13:46 |
|
|
static void query(char *); |
static void query(char *); |
static int chkparent(char *, opt_t); |
static int chkparent(char *, opt_t); |
static char *savetarget(char *, opt_t); |
static char *savetarget(char *, opt_t); |
static void recvfile(char *, opt_t, int, char *, char *, time_t, time_t, off_t); |
static void recvfile(char *, int, opt_t, int, char *, char *, time_t, time_t, off_t); |
static void recvdir(opt_t, int, char *, char *); |
static void recvdir(opt_t, int, char *, char *); |
static void recvlink(char *, opt_t, int, off_t); |
static void recvlink(char *, opt_t, int, off_t); |
static void hardlink(char *); |
static void hardlink(char *); |
|
|
* Receive a file |
* Receive a file |
*/ |
*/ |
static void |
static void |
recvfile(char *new, opt_t opts, int mode, char *owner, char *group, |
recvfile(char *new, int f, opt_t opts, int mode, char *owner, |
time_t mtime, time_t atime, off_t size) |
char *group, time_t mtime, time_t atime, off_t size) |
{ |
{ |
int f, wrerr, olderrno; |
int wrerr, olderrno; |
off_t i; |
off_t i; |
char *cp; |
char *cp; |
char *savefile = NULL; |
char *savefile = NULL; |
static struct stat statbuff; |
static struct stat statbuff; |
|
|
/* |
/* |
* Create temporary file |
|
*/ |
|
if ((f = open(new, O_CREAT|O_EXCL|O_WRONLY, mode)) < 0) { |
|
if (errno != ENOENT || chkparent(new, opts) < 0 || |
|
(f = open(new, O_CREAT|O_EXCL|O_WRONLY, mode)) < 0) { |
|
error("%s: create failed: %s", new, SYSERR); |
|
(void) unlink(new); |
|
return; |
|
} |
|
} |
|
|
|
/* |
|
* Receive the file itself |
* Receive the file itself |
*/ |
*/ |
ack(); |
ack(); |
|
|
static void |
static void |
recvit(char *cmd, int type) |
recvit(char *cmd, int type) |
{ |
{ |
int mode; |
int f, mode; |
opt_t opts; |
opt_t opts; |
off_t size; |
off_t size; |
time_t mtime, atime; |
time_t mtime, atime; |
|
|
tempname); |
tempname); |
*file = '/'; |
*file = '/'; |
} |
} |
(void) mktemp(new); |
if ((f = mkstemp(new)) == -1) { |
|
error("%s: create failed: %s", new, SYSERR); |
|
return; |
|
} |
} |
} |
|
|
/* |
/* |
|
|
break; |
break; |
|
|
case S_IFREG: |
case S_IFREG: |
recvfile(new, opts, mode, owner, group, mtime, atime, size); |
recvfile(new, f, opts, mode, owner, group, mtime, atime, size); |
break; |
break; |
|
|
default: |
default: |