--- embedtools/src/dircmp.c 2010/07/13 11:04:09 1.1.2.2 +++ embedtools/src/dircmp.c 2010/07/13 11:22:36 1.1.2.3 @@ -85,7 +85,12 @@ cmpDir(const char *csDir1, const char *csDir2, struct memset(l, 0, sizeof(struct tagDirName)); } - dir = opendir(csDir1); + if (chdir(csDir1) == -1) { + printf("Error:: %s(%d) #%d - %s\n", __func__, __LINE__, errno, strerror(errno)); + free(l); + return -1; + } + dir = opendir("."); if (!dir) { printf("Error:: %s(%d) #%d - %s\n", __func__, __LINE__, errno, strerror(errno)); free(l); @@ -110,7 +115,7 @@ cmpDir(const char *csDir1, const char *csDir2, struct if (lm) { if (lstat(d.d_name, &sb) != -1) { memset(szStr, 0, MAX_STR); - strftime(szStr, MAX_STR, "%y-%m-%d %H:%M:%S", localtime((time_t*) &sb.st_mtim)); + strftime(szStr, MAX_STR, "%Y-%m-%d %H:%M:%S", localtime((time_t*) &sb.st_mtim)); switch (d.d_type) { case DT_FIFO: strlcpy(szType, "fifo", MAX_STR); @@ -141,9 +146,9 @@ cmpDir(const char *csDir1, const char *csDir2, struct strlcpy(szType, "unknown", MAX_STR); break; } - snprintf(l[n].extra, MAX_STR, "%s links=%d %d:%d perm=0%o size=%llu %s\n", szType, - sb.st_nlink, sb.st_uid, sb.st_gid, sb.st_mode & 0x1fff, - sb.st_size, szStr); + snprintf(l[n].extra, MAX_STR, "%s links=%d inode=%u %d:%d perm=0%o size=%llu %s", + szType, sb.st_nlink, sb.st_ino, sb.st_uid, sb.st_gid, + sb.st_mode & 0x1fff, sb.st_size, szStr); } } @@ -155,7 +160,12 @@ cmpDir(const char *csDir1, const char *csDir2, struct tags[l[i].tag] = i; // open dir 2 for diff ... - dir = opendir(csDir2); + if (chdir(csDir2) == -1) { + printf("Error:: %s(%d) #%d - %s\n", __func__, __LINE__, errno, strerror(errno)); + free(l); + return -1; + } + dir = opendir("."); if (!dir) { printf("Error:: %s(%d) #%d - %s\n", __func__, __LINE__, errno, strerror(errno)); free(l); @@ -198,7 +208,7 @@ cmpDir(const char *csDir1, const char *csDir2, struct if (lm) { if (lstat(d.d_name, &sb) != -1) { memset(szStr, 0, MAX_STR); - strftime(szStr, MAX_STR, "%y-%m-%d %H:%M:%S", localtime((time_t*) &sb.st_mtim)); + strftime(szStr, MAX_STR, "%Y-%m-%d %H:%M:%S", localtime((time_t*) &sb.st_mtim)); switch (d.d_type) { case DT_FIFO: strlcpy(szType, "fifo", MAX_STR); @@ -229,9 +239,9 @@ cmpDir(const char *csDir1, const char *csDir2, struct strlcpy(szType, "unknown", MAX_STR); break; } - snprintf(l[n].extra, MAX_STR, "%s links=%d %d:%d perm=0%o size=%llu %s\n", szType, - sb.st_nlink, sb.st_uid, sb.st_gid, sb.st_mode & 0x1fff, - sb.st_size, szStr); + snprintf(l[n].extra, MAX_STR, "%s links=%d inode=%u %d:%d perm=0%o size=%llu %s", + szType, sb.st_nlink, sb.st_ino, sb.st_uid, sb.st_gid, + sb.st_mode & 0x1fff, sb.st_size, szStr); } }