[ros-kernel] rcopy fix
Sebastian Schmidt
yath at yath.eu.org
Sun Dec 7 16:22:32 CET 2003
Hi again,
I noticed there's a bug in rcopy. It does never copy files on Linux.
rcopy(3) manpage:
| BUGS
| Field d_type is not implemented as of libc6 2.1 and will
| always return DT_UNKNOWN (0).
is_reg() is now called, is_reg() calls stat(). Patch attached.
HTH,
Sebastian
--
http://krake.yath.eu.org/
[0] yath at eniac:~$ nc mx.chi.playboy.com smtp
220 mx.chi.playboy.com -- ALL YOUR EMAIL ARE BELONG TO US
-------------- next part --------------
--- rcopy.c.old 2003-12-07 16:18:00.000000000 +0100
+++ rcopy.c 2003-12-07 16:16:57.000000000 +0100
@@ -170,8 +170,32 @@
}
#else
-
/* Linux version */
+
+static int
+is_reg (char *path, char *fn)
+{
+ char buf[MAX_PATH];
+ char buf2[MAX_PATH];
+ struct stat sbuf;
+
+ strcpy(buf, path);
+ if (buf[strlen(buf)-1] != '/')
+ strcat(buf, "/");
+ strcat(buf, fn);
+
+ make_absolute(buf2, buf);
+
+ if (stat(buf2, &sbuf) == -1)
+ return 0;
+ else {
+ if (S_ISREG(sbuf.st_mode))
+ return 1;
+ else
+ return 0;
+ }
+}
+
static void
copy_directory (char *path1, char *path2)
{
@@ -191,7 +215,7 @@
if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0)
continue; // skip self and parent
- if (entry->d_type == DT_REG) // normal file
+ if (is_reg(path1, entry->d_name)) // normal file
{
// Convert to absolute path
make_absolute(buf, path1);
More information about the Ros-kernel
mailing list