X-Git-Url: https://git.wh0rd.org/?a=blobdiff_plain;f=rmt%2Frmt.c;h=7d5d29ab939bf06f16388775600d03821c7bbfb3;hb=3d4a9c407f7acb58d91f9329ba203e468c60c2ed;hp=74116b0a46e84f82a1a96ce321d5d766caf8a030;hpb=1227625a12a66e0ded78a1997c2d23f23202a382;p=dump.git diff --git a/rmt/rmt.c b/rmt/rmt.c index 74116b0..7d5d29a 100644 --- a/rmt/rmt.c +++ b/rmt/rmt.c @@ -1,8 +1,9 @@ /* * Ported to Linux's Second Extended File System as part of the * dump and restore backup suit - * Remy Card , 1994, 1995, 1996 - * + * Remy Card , 1994-1997 + * Stelian Pop , 1999-2000 + * Stelian Pop - AlcĂ´ve , 2000 */ /* @@ -39,14 +40,9 @@ */ #ifndef lint -static char copyright[] = -"@(#) Copyright (c) 1983, 1993\n\ - The Regents of the University of California. All rights reserved.\n"; -#endif /* not lint */ - -#ifndef lint -static char sccsid[] = "@(#)rmt.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ +static const char rcsid[] = + "$Id: rmt.c,v 1.10 2000/11/10 14:51:42 stelian Exp $"; +#endif /* not linux */ /* * rmt @@ -56,7 +52,9 @@ static char sccsid[] = "@(#)rmt.c 8.1 (Berkeley) 6/6/93"; #include #include #include +#ifndef __linux__ #include +#endif #include #include #include @@ -69,7 +67,7 @@ int maxrecsize = -1; #define SSIZE 64 char device[SSIZE]; -char count[SSIZE], mode[SSIZE], pos[SSIZE], op[SSIZE]; +char count[SSIZE], filemode[SSIZE], pos[SSIZE], op[SSIZE]; char resp[BUFSIZ]; @@ -83,11 +81,9 @@ void error __P((int)); void getstring __P((char *)); int -main(argc, argv) - int argc; - char **argv; +main(int argc, char *argv[]) { - int rval; + int rval = 0; char c; int n, i, cc; @@ -109,9 +105,14 @@ top: if (tape >= 0) (void) close(tape); getstring(device); - getstring(mode); - DEBUG2("rmtd: O %s %s\n", device, mode); - tape = open(device, atoi(mode)); + getstring(filemode); + DEBUG2("rmtd: O %s %s\n", device, filemode); + /* + * XXX the rmt protocol does not provide a means to + * specify the permission bits; allow rw for everyone, + * as modified by the users umask + */ + tape = open(device, atoi(filemode), 0666); if (tape < 0) goto ioerror; goto respond; @@ -188,6 +189,12 @@ top: goto top; } + case 'V': /* version */ + getstring(op); + DEBUG1("rmtd: V %s\n", op); + rval = 2; + goto respond; + default: DEBUG1("rmtd: garbage command %c\n", c); exit(3); @@ -202,9 +209,7 @@ ioerror: goto top; } -void -getstring(bp) - char *bp; +void getstring(char *bp) { int i; char *cp = bp; @@ -219,9 +224,7 @@ getstring(bp) } char * -checkbuf(record, size) - char *record; - int size; +checkbuf(char *record, int size) { if (size <= maxrecsize) @@ -241,11 +244,10 @@ checkbuf(record, size) } void -error(num) - int num; +error(int num) { DEBUG2("rmtd: E %d (%s)\n", num, strerror(num)); - (void)sprintf(resp, "E%d\n%s\n", num, strerror(num)); + (void)snprintf(resp, sizeof(resp), "E%d\n%s\n", num, strerror(num)); (void)write(1, resp, strlen(resp)); }