fixed xargs and dd
This commit is contained in:
parent
25599584fb
commit
1a7b13daf2
17
LICENSE
17
LICENSE
|
@ -1,13 +1,14 @@
|
|||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||
Version 2, December 2004
|
||||
|
||||
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
|
||||
Version 2, December 2004
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim or modified
|
||||
copies of this license document, and changing it is allowed as long
|
||||
as the name is changed.
|
||||
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
|
||||
|
||||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
Everyone is permitted to copy and distribute verbatim or modified
|
||||
copies of this license document, and changing it is allowed as long
|
||||
as the name is changed.
|
||||
|
||||
0. You just DO WHAT THE FUCK YOU WANT TO.
|
||||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. You just DO WHAT THE FUCK YOU WANT TO.
|
||||
|
|
|
@ -10,7 +10,7 @@ int pw_check(const char *prog_name, const struct passwd *pw, const char *pass) {
|
|||
return 0;
|
||||
|
||||
if (pw->pw_passwd[0] == '!' || pw->pw_passwd[0] == '*') {
|
||||
fprintf(stderr, "%s: Denied\n", prog_name);
|
||||
fprintf(stderr, "%s: Access denied\n", prog_name);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ int openfile(int flag, char *path, int mode) {
|
|||
|
||||
off_t strtonum(char *str) {
|
||||
char *p = NULL;
|
||||
off_t res = strtoll(str, &p, 10);
|
||||
off_t res = strtoll(str, &p, 0);
|
||||
if (str != p) {
|
||||
if (!strcmp(p, "b"))
|
||||
res *= 512;
|
||||
|
@ -60,7 +60,7 @@ off_t strtonum(char *str) {
|
|||
res *= 1073741824;
|
||||
}
|
||||
|
||||
if (res <= 1)
|
||||
if (res < 0)
|
||||
res = 0;
|
||||
|
||||
return res;
|
||||
|
@ -181,6 +181,8 @@ int main(int argc, char **argv) {
|
|||
}
|
||||
|
||||
/* dd */
|
||||
off_t opos = 0;
|
||||
|
||||
while (1) {
|
||||
if (count == infull + inpart)
|
||||
break;
|
||||
|
@ -200,7 +202,31 @@ int main(int argc, char **argv) {
|
|||
goto CLOSE;
|
||||
}
|
||||
|
||||
else {}
|
||||
else {
|
||||
char *tmp = ibuf;
|
||||
while (n) {
|
||||
off_t i = obs - opos;
|
||||
if (i > n)
|
||||
i = n;
|
||||
|
||||
memcpy(obuf + opos, tmp, i);
|
||||
|
||||
n -= i;
|
||||
tmp += i;
|
||||
opos += i;
|
||||
if (opos == obs) {
|
||||
if (copy(ofd, obuf, obs, obs))
|
||||
goto CLOSE;
|
||||
|
||||
opos = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (opos != 0) {
|
||||
if (copy(ofd, obuf, obs, obs))
|
||||
goto CLOSE;
|
||||
}
|
||||
|
||||
/* End */
|
||||
|
|
|
@ -60,8 +60,10 @@ int stdin_read(void) {
|
|||
*p = '\0';
|
||||
p = arg;
|
||||
|
||||
if (add_arg(arg, chars))
|
||||
break;
|
||||
if (add_arg(arg, chars)) {
|
||||
fprintf(stderr, "xargs: argument line too long\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
args_passed++;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue