summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>1999-10-17 05:43:39 +0000
committerEric Andersen <andersen@codepoet.org>1999-10-17 05:43:39 +0000
commit9b5871888989b16f94cbba5dd304ac444def3afd (patch)
tree17187e3f6988830c0e329378e552995d083080ed
parentcb6e25655f894c90e4befc4bee0e66794dd6858f (diff)
downloadbusybox-w32-9b5871888989b16f94cbba5dd304ac444def3afd.tar.gz
busybox-w32-9b5871888989b16f94cbba5dd304ac444def3afd.tar.bz2
busybox-w32-9b5871888989b16f94cbba5dd304ac444def3afd.zip
Some fixes and such
-rw-r--r--chmod_chown_chgrp.c23
-rw-r--r--coreutils/cp.c14
-rw-r--r--coreutils/mv.c7
-rw-r--r--cp.c14
-rw-r--r--find.c8
-rw-r--r--findutils/find.c8
-rw-r--r--internal.h4
-rw-r--r--mv.c7
-rw-r--r--utility.c15
9 files changed, 50 insertions, 50 deletions
diff --git a/chmod_chown_chgrp.c b/chmod_chown_chgrp.c
index 5c2adab78..f3d8ce207 100644
--- a/chmod_chown_chgrp.c
+++ b/chmod_chown_chgrp.c
@@ -49,20 +49,17 @@ static const char chmod_usage[] = "[-R] MODE[,MODE]... FILE...\n"
49 49
50 50
51 51
52static int fileAction(const char *fileName) 52static int fileAction(const char *fileName, struct stat* statbuf)
53{ 53{
54 struct stat statBuf; 54 switch (whichApp) {
55 if (stat(fileName, &statBuf) < 0) { 55 case CHGRP_APP:
56 switch (whichApp) { 56 case CHOWN_APP:
57 case CHGRP_APP: 57 if (chown(fileName, ((whichApp==CHOWN_APP)? uid: statbuf->st_uid), gid) < 0)
58 case CHOWN_APP: 58 return( TRUE);
59 if (chown(fileName, ((whichApp==CHOWN_APP)? uid: statBuf.st_uid), gid) < 0) 59 case CHMOD_APP:
60 return( TRUE); 60 fprintf(stderr, "%s, %d\n", fileName, mode);
61 case CHMOD_APP: 61 if (chmod(fileName, mode))
62 fprintf(stderr, "%s, %d\n", fileName, mode); 62 return( TRUE);
63 if (chmod(fileName, mode))
64 return( TRUE);
65 }
66 } 63 }
67 perror(fileName); 64 perror(fileName);
68 return( FALSE); 65 return( FALSE);
diff --git a/coreutils/cp.c b/coreutils/cp.c
index 6ca66e642..4016fc760 100644
--- a/coreutils/cp.c
+++ b/coreutils/cp.c
@@ -41,21 +41,24 @@ static int preserveFlag = FALSE;
41static const char *srcName; 41static const char *srcName;
42static const char *destName; 42static const char *destName;
43static const char *skipName; 43static const char *skipName;
44static int dirFlag = FALSE;
44 45
45 46
46static int fileAction(const char *fileName) 47static int fileAction(const char *fileName, struct stat* statbuf)
47{ 48{
48 char newdestName[NAME_MAX]; 49 char newdestName[NAME_MAX];
49 strcpy(newdestName, destName); 50 strcpy(newdestName, destName);
50 strcat(newdestName, strstr(fileName, skipName)); 51 if (dirFlag==TRUE && newdestName[strlen(newdestName)-1]!= '/' ) {
52 strcat(newdestName, "/");
53 if ( skipName != NULL)
54 strcat(newdestName, strstr(fileName, skipName));
55 }
51 return (copyFile(fileName, newdestName, preserveFlag, followLinks)); 56 return (copyFile(fileName, newdestName, preserveFlag, followLinks));
52} 57}
53 58
54extern int cp_main(int argc, char **argv) 59extern int cp_main(int argc, char **argv)
55{ 60{
56 61
57 int dirFlag;
58
59 if (argc < 3) { 62 if (argc < 3) {
60 fprintf(stderr, "Usage: %s", cp_usage); 63 fprintf(stderr, "Usage: %s", cp_usage);
61 exit (FALSE); 64 exit (FALSE);
@@ -91,10 +94,9 @@ extern int cp_main(int argc, char **argv)
91 94
92 95
93 destName = argv[argc - 1]; 96 destName = argv[argc - 1];
94
95 dirFlag = isDirectory(destName); 97 dirFlag = isDirectory(destName);
96 98
97 if ((argc > 3) && !dirFlag) { 99 if ((argc > 3) && dirFlag==FALSE) {
98 fprintf(stderr, "%s: not a directory\n", destName); 100 fprintf(stderr, "%s: not a directory\n", destName);
99 exit (FALSE); 101 exit (FALSE);
100 } 102 }
diff --git a/coreutils/mv.c b/coreutils/mv.c
index df56206a3..10a082210 100644
--- a/coreutils/mv.c
+++ b/coreutils/mv.c
@@ -41,7 +41,7 @@ extern int mv_main (int argc, char **argv)
41 41
42 if (argc < 3) { 42 if (argc < 3) {
43 fprintf (stderr, "Usage: %s %s", *argv, mv_usage); 43 fprintf (stderr, "Usage: %s %s", *argv, mv_usage);
44 return (FALSE); 44 exit (FALSE);
45 } 45 }
46 lastArg = argv[argc - 1]; 46 lastArg = argv[argc - 1];
47 47
@@ -49,8 +49,7 @@ extern int mv_main (int argc, char **argv)
49 49
50 if ((argc > 3) && !dirFlag) { 50 if ((argc > 3) && !dirFlag) {
51 fprintf (stderr, "%s: not a directory\n", lastArg); 51 fprintf (stderr, "%s: not a directory\n", lastArg);
52 52 exit (FALSE);
53 return (FALSE);
54 } 53 }
55 54
56 while (argc-- > 2) { 55 while (argc-- > 2) {
@@ -80,5 +79,5 @@ extern int mv_main (int argc, char **argv)
80 if (unlink (srcName) < 0) 79 if (unlink (srcName) < 0)
81 perror (srcName); 80 perror (srcName);
82 } 81 }
83 return (TRUE); 82 exit (TRUE);
84} 83}
diff --git a/cp.c b/cp.c
index 6ca66e642..4016fc760 100644
--- a/cp.c
+++ b/cp.c
@@ -41,21 +41,24 @@ static int preserveFlag = FALSE;
41static const char *srcName; 41static const char *srcName;
42static const char *destName; 42static const char *destName;
43static const char *skipName; 43static const char *skipName;
44static int dirFlag = FALSE;
44 45
45 46
46static int fileAction(const char *fileName) 47static int fileAction(const char *fileName, struct stat* statbuf)
47{ 48{
48 char newdestName[NAME_MAX]; 49 char newdestName[NAME_MAX];
49 strcpy(newdestName, destName); 50 strcpy(newdestName, destName);
50 strcat(newdestName, strstr(fileName, skipName)); 51 if (dirFlag==TRUE && newdestName[strlen(newdestName)-1]!= '/' ) {
52 strcat(newdestName, "/");
53 if ( skipName != NULL)
54 strcat(newdestName, strstr(fileName, skipName));
55 }
51 return (copyFile(fileName, newdestName, preserveFlag, followLinks)); 56 return (copyFile(fileName, newdestName, preserveFlag, followLinks));
52} 57}
53 58
54extern int cp_main(int argc, char **argv) 59extern int cp_main(int argc, char **argv)
55{ 60{
56 61
57 int dirFlag;
58
59 if (argc < 3) { 62 if (argc < 3) {
60 fprintf(stderr, "Usage: %s", cp_usage); 63 fprintf(stderr, "Usage: %s", cp_usage);
61 exit (FALSE); 64 exit (FALSE);
@@ -91,10 +94,9 @@ extern int cp_main(int argc, char **argv)
91 94
92 95
93 destName = argv[argc - 1]; 96 destName = argv[argc - 1];
94
95 dirFlag = isDirectory(destName); 97 dirFlag = isDirectory(destName);
96 98
97 if ((argc > 3) && !dirFlag) { 99 if ((argc > 3) && dirFlag==FALSE) {
98 fprintf(stderr, "%s: not a directory\n", destName); 100 fprintf(stderr, "%s: not a directory\n", destName);
99 exit (FALSE); 101 exit (FALSE);
100 } 102 }
diff --git a/find.c b/find.c
index d618401bf..c92202b86 100644
--- a/find.c
+++ b/find.c
@@ -35,7 +35,7 @@ static const char find_usage[] = "find [path...] [expression]\n"
35 35
36 36
37 37
38static int fileAction(const char *fileName) 38static int fileAction(const char *fileName, struct stat* statbuf)
39{ 39{
40 if (pattern==NULL) 40 if (pattern==NULL)
41 fprintf(stdout, "%s\n", fileName); 41 fprintf(stdout, "%s\n", fileName);
@@ -44,7 +44,7 @@ static int fileAction(const char *fileName)
44 return( TRUE); 44 return( TRUE);
45} 45}
46 46
47static int dirAction(const char *fileName) 47static int dirAction(const char *fileName, struct stat* statbuf)
48{ 48{
49 DIR *dir; 49 DIR *dir;
50 struct dirent *entry; 50 struct dirent *entry;
@@ -70,7 +70,7 @@ static int dirAction(const char *fileName)
70int find_main(int argc, char **argv) 70int find_main(int argc, char **argv)
71{ 71{
72 if (argc <= 1) { 72 if (argc <= 1) {
73 dirAction( "."); 73 dirAction( ".", NULL);
74 } 74 }
75 75
76 /* peel off the "find" */ 76 /* peel off the "find" */
@@ -120,7 +120,7 @@ int find_main(int argc, char **argv)
120 break; 120 break;
121 } 121 }
122 122
123 dirAction( directory); 123 dirAction( directory, NULL);
124 exit(TRUE); 124 exit(TRUE);
125} 125}
126 126
diff --git a/findutils/find.c b/findutils/find.c
index d618401bf..c92202b86 100644
--- a/findutils/find.c
+++ b/findutils/find.c
@@ -35,7 +35,7 @@ static const char find_usage[] = "find [path...] [expression]\n"
35 35
36 36
37 37
38static int fileAction(const char *fileName) 38static int fileAction(const char *fileName, struct stat* statbuf)
39{ 39{
40 if (pattern==NULL) 40 if (pattern==NULL)
41 fprintf(stdout, "%s\n", fileName); 41 fprintf(stdout, "%s\n", fileName);
@@ -44,7 +44,7 @@ static int fileAction(const char *fileName)
44 return( TRUE); 44 return( TRUE);
45} 45}
46 46
47static int dirAction(const char *fileName) 47static int dirAction(const char *fileName, struct stat* statbuf)
48{ 48{
49 DIR *dir; 49 DIR *dir;
50 struct dirent *entry; 50 struct dirent *entry;
@@ -70,7 +70,7 @@ static int dirAction(const char *fileName)
70int find_main(int argc, char **argv) 70int find_main(int argc, char **argv)
71{ 71{
72 if (argc <= 1) { 72 if (argc <= 1) {
73 dirAction( "."); 73 dirAction( ".", NULL);
74 } 74 }
75 75
76 /* peel off the "find" */ 76 /* peel off the "find" */
@@ -120,7 +120,7 @@ int find_main(int argc, char **argv)
120 break; 120 break;
121 } 121 }
122 122
123 dirAction( directory); 123 dirAction( directory, NULL);
124 exit(TRUE); 124 exit(TRUE);
125} 125}
126 126
diff --git a/internal.h b/internal.h
index 397eca48a..4650e9f41 100644
--- a/internal.h
+++ b/internal.h
@@ -122,8 +122,8 @@ void freeChunks(void);
122int fullWrite(int fd, const char *buf, int len); 122int fullWrite(int fd, const char *buf, int len);
123int fullRead(int fd, char *buf, int len); 123int fullRead(int fd, char *buf, int len);
124int recursiveAction(const char *fileName, int recurse, int followLinks, 124int recursiveAction(const char *fileName, int recurse, int followLinks,
125 int (*fileAction) (const char *fileName), 125 int (*fileAction) (const char *fileName, struct stat* statbuf),
126 int (*dirAction) (const char *fileName)); 126 int (*dirAction) (const char *fileName, struct stat* statbuf));
127int match(const char* text, const char * pattern); 127int match(const char* text, const char * pattern);
128const char* timeString(time_t timeVal); 128const char* timeString(time_t timeVal);
129 129
diff --git a/mv.c b/mv.c
index df56206a3..10a082210 100644
--- a/mv.c
+++ b/mv.c
@@ -41,7 +41,7 @@ extern int mv_main (int argc, char **argv)
41 41
42 if (argc < 3) { 42 if (argc < 3) {
43 fprintf (stderr, "Usage: %s %s", *argv, mv_usage); 43 fprintf (stderr, "Usage: %s %s", *argv, mv_usage);
44 return (FALSE); 44 exit (FALSE);
45 } 45 }
46 lastArg = argv[argc - 1]; 46 lastArg = argv[argc - 1];
47 47
@@ -49,8 +49,7 @@ extern int mv_main (int argc, char **argv)
49 49
50 if ((argc > 3) && !dirFlag) { 50 if ((argc > 3) && !dirFlag) {
51 fprintf (stderr, "%s: not a directory\n", lastArg); 51 fprintf (stderr, "%s: not a directory\n", lastArg);
52 52 exit (FALSE);
53 return (FALSE);
54 } 53 }
55 54
56 while (argc-- > 2) { 55 while (argc-- > 2) {
@@ -80,5 +79,5 @@ extern int mv_main (int argc, char **argv)
80 if (unlink (srcName) < 0) 79 if (unlink (srcName) < 0)
81 perror (srcName); 80 perror (srcName);
82 } 81 }
83 return (TRUE); 82 exit (TRUE);
84} 83}
diff --git a/utility.c b/utility.c
index cf90f37d1..4bb479f0c 100644
--- a/utility.c
+++ b/utility.c
@@ -46,8 +46,9 @@ int isDirectory(const char *name)
46 46
47 if (stat(name, &statBuf) < 0) 47 if (stat(name, &statBuf) < 0)
48 return FALSE; 48 return FALSE;
49 49 if (S_ISDIR(statBuf.st_mode))
50 return S_ISDIR(statBuf.st_mode); 50 return TRUE;
51 return(FALSE);
51} 52}
52 53
53 54
@@ -467,8 +468,8 @@ int fullRead(int fd, char *buf, int len)
467 */ 468 */
468int 469int
469recursiveAction(const char *fileName, int recurse, int followLinks, 470recursiveAction(const char *fileName, int recurse, int followLinks,
470 int (*fileAction) (const char *fileName), 471 int (*fileAction) (const char *fileName, struct stat* statbuf),
471 int (*dirAction) (const char *fileName)) 472 int (*dirAction) (const char *fileName, struct stat* statbuf))
472{ 473{
473 int status; 474 int status;
474 struct stat statbuf; 475 struct stat statbuf;
@@ -487,7 +488,7 @@ recursiveAction(const char *fileName, int recurse, int followLinks,
487 if (recurse == FALSE) { 488 if (recurse == FALSE) {
488 if (S_ISDIR(statbuf.st_mode)) { 489 if (S_ISDIR(statbuf.st_mode)) {
489 if (dirAction != NULL) 490 if (dirAction != NULL)
490 return (dirAction(fileName)); 491 return (dirAction(fileName, &statbuf));
491 else 492 else
492 return (TRUE); 493 return (TRUE);
493 } 494 }
@@ -501,7 +502,7 @@ recursiveAction(const char *fileName, int recurse, int followLinks,
501 return (FALSE); 502 return (FALSE);
502 } 503 }
503 if (dirAction != NULL) { 504 if (dirAction != NULL) {
504 status = dirAction(fileName); 505 status = dirAction(fileName, &statbuf);
505 if (status == FALSE) { 506 if (status == FALSE) {
506 perror(fileName); 507 perror(fileName);
507 return (FALSE); 508 return (FALSE);
@@ -531,7 +532,7 @@ recursiveAction(const char *fileName, int recurse, int followLinks,
531 if (fileAction == NULL) 532 if (fileAction == NULL)
532 return (TRUE); 533 return (TRUE);
533 else 534 else
534 return (fileAction(fileName)); 535 return (fileAction(fileName, &statbuf));
535 } 536 }
536 return (TRUE); 537 return (TRUE);
537} 538}