vbackup for mac tweaks (dave swasey)
This commit is contained in:
parent
c99ef336aa
commit
9437f55b49
1 changed files with 20 additions and 8 deletions
|
|
@ -7,6 +7,7 @@
|
||||||
* -D print debugging
|
* -D print debugging
|
||||||
* -f 'fast' writes - skip write if block exists on server
|
* -f 'fast' writes - skip write if block exists on server
|
||||||
* -m set mount name
|
* -m set mount name
|
||||||
|
* -M set mount place
|
||||||
* -n nop -- don't actually write blocks
|
* -n nop -- don't actually write blocks
|
||||||
* -s print status updates
|
* -s print status updates
|
||||||
* -v print debugging trace
|
* -v print debugging trace
|
||||||
|
|
@ -83,19 +84,19 @@ void fsysproc(void*);
|
||||||
void statusproc(void*);
|
void statusproc(void*);
|
||||||
void ventiproc(void*);
|
void ventiproc(void*);
|
||||||
int timefmt(Fmt*);
|
int timefmt(Fmt*);
|
||||||
char* mountplace(char *dev);
|
char* guessmountplace(char *dev);
|
||||||
|
|
||||||
void
|
void
|
||||||
usage(void)
|
usage(void)
|
||||||
{
|
{
|
||||||
fprint(2, "usage: vbackup [-DVnv] [-m mtpt] [-s secs] [-w n] disk [score]\n");
|
fprint(2, "usage: vbackup [-DVnv] [-m mtpt] [-M mtpl] [-s secs] [-w n] disk [score]\n");
|
||||||
threadexitsall("usage");
|
threadexitsall("usage");
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
threadmain(int argc, char **argv)
|
threadmain(int argc, char **argv)
|
||||||
{
|
{
|
||||||
char *pref, *mountname;
|
char *pref, *mountname, *mountplace;
|
||||||
uchar score[VtScoreSize], prev[VtScoreSize];
|
uchar score[VtScoreSize], prev[VtScoreSize];
|
||||||
int i, fd, csize;
|
int i, fd, csize;
|
||||||
vlong bsize;
|
vlong bsize;
|
||||||
|
|
@ -112,6 +113,7 @@ threadmain(int argc, char **argv)
|
||||||
fmtinstall('V', vtscorefmt);
|
fmtinstall('V', vtscorefmt);
|
||||||
|
|
||||||
mountname = sysname();
|
mountname = sysname();
|
||||||
|
mountplace = nil;
|
||||||
ARGBEGIN{
|
ARGBEGIN{
|
||||||
default:
|
default:
|
||||||
usage();
|
usage();
|
||||||
|
|
@ -128,6 +130,12 @@ threadmain(int argc, char **argv)
|
||||||
case 'm':
|
case 'm':
|
||||||
mountname = EARGF(usage());
|
mountname = EARGF(usage());
|
||||||
break;
|
break;
|
||||||
|
case 'M':
|
||||||
|
mountplace = EARGF(usage());
|
||||||
|
i = strlen(mountplace);
|
||||||
|
if(i > 0 && mountplace[i-1] == '/')
|
||||||
|
mountplace[i-1] = 0;
|
||||||
|
break;
|
||||||
case 'n':
|
case 'n':
|
||||||
nop = 1;
|
nop = 1;
|
||||||
break;
|
break;
|
||||||
|
|
@ -289,8 +297,10 @@ threadmain(int argc, char **argv)
|
||||||
qfree(qventi);
|
qfree(qventi);
|
||||||
|
|
||||||
if(statustime)
|
if(statustime)
|
||||||
print("# %T procs exited: %d blocks changed, %d read, %d written, %d skipped, %d copied\n",
|
print("# %T procs exited: %d of %d %d-byte blocks changed, "
|
||||||
nchange, vtcachenread, vtcachenwrite, nskip, vtcachencopy);
|
"%d read, %d written, %d skipped, %d copied\n",
|
||||||
|
nchange, fsys->nblock, fsys->blocksize,
|
||||||
|
vtcachenread, vtcachenwrite, nskip, vtcachencopy);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* prepare root block
|
* prepare root block
|
||||||
|
|
@ -328,9 +338,11 @@ threadmain(int argc, char **argv)
|
||||||
tm = *localtime(time(0));
|
tm = *localtime(time(0));
|
||||||
tm.year += 1900;
|
tm.year += 1900;
|
||||||
tm.mon++;
|
tm.mon++;
|
||||||
|
if(mountplace == nil)
|
||||||
|
mountplace = guessmountplace(argv[0]);
|
||||||
print("mount /%s/%d/%02d%02d%s %s:%V %d/%02d%02d/%02d%02d\n",
|
print("mount /%s/%d/%02d%02d%s %s:%V %d/%02d%02d/%02d%02d\n",
|
||||||
mountname, tm.year, tm.mon, tm.mday,
|
mountname, tm.year, tm.mon, tm.mday,
|
||||||
mountplace(argv[0]),
|
mountplace,
|
||||||
root.type, b->score,
|
root.type, b->score,
|
||||||
tm.year, tm.mon, tm.mday, tm.hour, tm.min);
|
tm.year, tm.mon, tm.mday, tm.hour, tm.min);
|
||||||
print("# %T %s %s:%V\n", argv[0], root.type, b->score);
|
print("# %T %s %s:%V\n", argv[0], root.type, b->score);
|
||||||
|
|
@ -549,7 +561,7 @@ timefmt(Fmt *fmt)
|
||||||
}
|
}
|
||||||
|
|
||||||
char*
|
char*
|
||||||
mountplace(char *dev)
|
guessmountplace(char *dev)
|
||||||
{
|
{
|
||||||
char *cmd, *q;
|
char *cmd, *q;
|
||||||
int p[2], fd[3], n;
|
int p[2], fd[3], n;
|
||||||
|
|
@ -561,7 +573,7 @@ mountplace(char *dev)
|
||||||
fd[0] = -1;
|
fd[0] = -1;
|
||||||
fd[1] = p[1];
|
fd[1] = p[1];
|
||||||
fd[2] = -1;
|
fd[2] = -1;
|
||||||
cmd = smprint("mount | awk '$1==\"%s\" && $2 == \"on\" {print $3}'", dev);
|
cmd = smprint("mount | awk 'BEGIN{v=\"%s\"; u=v; sub(/rdisk/, \"disk\", u);} ($1==v||$1==u) && $2 == \"on\" {print $3}'", dev);
|
||||||
if(threadspawnl(fd, "sh", "sh", "-c", cmd, nil) < 0)
|
if(threadspawnl(fd, "sh", "sh", "-c", cmd, nil) < 0)
|
||||||
sysfatal("exec mount|awk (to find mtpt of %s): %r", dev);
|
sysfatal("exec mount|awk (to find mtpt of %s): %r", dev);
|
||||||
/* threadspawnl closed p[1] */
|
/* threadspawnl closed p[1] */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue