|
|
| version 1.3.2.2, 2012/11/13 13:38:14 | version 1.3.2.3, 2012/11/13 13:53:14 |
|---|---|
| Line 145 create_diridx(const char *csDir, int lm, int *tags, st | Line 145 create_diridx(const char *csDir, int lm, int *tags, st |
| l[n].tag = crcFletcher16((u_short*) d.d_name, | l[n].tag = crcFletcher16((u_short*) d.d_name, |
| d.d_namlen / 2 + d.d_namlen % 2); | d.d_namlen / 2 + d.d_namlen % 2); |
| l[n].hash = crcAdler((u_char*) d.d_name, d.d_namlen); | l[n].hash = crcAdler((u_char*) d.d_name, d.d_namlen); |
| strlcpy(l[n].name, d.d_name, MAXPATHLEN); | strlcpy(l[n].name, d.d_name, sizeof l[n].name); |
| if (lm & 1) { | if (lm & 1) { |
| if (lstat(d.d_name, &sb) != -1) { | if (lstat(d.d_name, &sb) != -1) { |
| memset(szStr, 0, STRSIZ); | memset(szStr, 0, sizeof szStr); |
| #if defined(__OpenBSD__) | #if defined(__OpenBSD__) |
| strftime(szStr, STRSIZ, "%Y-%m-%d %H:%M:%S", | strftime(szStr, sizeof szStr, "%Y-%m-%d %H:%M:%S", |
| localtime((time_t*) &sb.st_mtim)); | localtime((time_t*) &sb.st_mtim)); |
| #else | #else |
| strftime(szStr, STRSIZ, "%Y-%m-%d %H:%M:%S", | strftime(szStr, sizeof szStr, "%Y-%m-%d %H:%M:%S", |
| localtime((time_t*) &sb.st_mtime)); | localtime((time_t*) &sb.st_mtime)); |
| #endif | #endif |
| switch (d.d_type) { | switch (d.d_type) { |
| case DT_FIFO: | case DT_FIFO: |
| strlcpy(szType, "fifo", STRSIZ); | strlcpy(szType, "fifo", sizeof szType); |
| break; | break; |
| case DT_CHR: | case DT_CHR: |
| strlcpy(szType, "char", STRSIZ); | strlcpy(szType, "char", sizeof szType); |
| break; | break; |
| case DT_DIR: | case DT_DIR: |
| strlcpy(szType, "dir", STRSIZ); | strlcpy(szType, "dir", sizeof szType); |
| break; | break; |
| case DT_BLK: | case DT_BLK: |
| strlcpy(szType, "block", STRSIZ); | strlcpy(szType, "block", sizeof szType); |
| break; | break; |
| case DT_REG: | case DT_REG: |
| strlcpy(szType, "file", STRSIZ); | strlcpy(szType, "file", sizeof szType); |
| break; | break; |
| case DT_LNK: | case DT_LNK: |
| strlcpy(szType, "link", STRSIZ); | strlcpy(szType, "link", sizeof szType); |
| break; | break; |
| case DT_SOCK: | case DT_SOCK: |
| strlcpy(szType, "socket", STRSIZ); | strlcpy(szType, "socket", sizeof szType); |
| break; | break; |
| /* OpenBSD does not have this type */ | /* OpenBSD does not have this type */ |
| #ifdef DT_WHT | #ifdef DT_WHT |
| case DT_WHT: | case DT_WHT: |
| strlcpy(szType, "wht", STRSIZ); | strlcpy(szType, "wht", sizeof szType); |
| break; | break; |
| #endif | #endif |
| case DT_UNKNOWN: | case DT_UNKNOWN: |
| default: | default: |
| strlcpy(szType, "unknown", STRSIZ); | strlcpy(szType, "unknown", sizeof szType); |
| break; | break; |
| } | } |
| snprintf(l[n].extra, STRSIZ, | snprintf(l[n].extra, sizeof l[n].extra, |
| "%s links=%d inode=%ld %d:%d perm=0%o size=%ld %s", | "%s links=%d inode=%ld %d:%d perm=0%o size=%ld %s", |
| szType, sb.st_nlink, (long) sb.st_ino, | szType, sb.st_nlink, (long) sb.st_ino, |
| sb.st_uid, sb.st_gid, sb.st_mode & 0x1fff, | sb.st_uid, sb.st_gid, sb.st_mode & 0x1fff, |
| Line 368 sync_dircmpList(const char *csDir1, const char *csDir2 | Line 368 sync_dircmpList(const char *csDir1, const char *csDir2 |
| l[n].ch = '>'; | l[n].ch = '>'; |
| l[n].tag = t; | l[n].tag = t; |
| l[n].hash = hash; | l[n].hash = hash; |
| strlcpy(l[n].name, d.d_name, MAXPATHLEN); | strlcpy(l[n].name, d.d_name, sizeof l[n].name); |
| if (lm & 1) { | if (lm & 1) { |
| if (lstat(d.d_name, &sb) != -1) { | if (lstat(d.d_name, &sb) != -1) { |
| memset(szStr, 0, STRSIZ); | memset(szStr, 0, sizeof szStr); |
| #if defined(__OpenBSD__) | #if defined(__OpenBSD__) |
| strftime(szStr, STRSIZ, "%Y-%m-%d %H:%M:%S", | strftime(szStr, sizeof szStr, "%Y-%m-%d %H:%M:%S", |
| localtime((time_t*) &sb.st_mtim)); | localtime((time_t*) &sb.st_mtim)); |
| #else | #else |
| strftime(szStr, STRSIZ, "%Y-%m-%d %H:%M:%S", | strftime(szStr, sizeof szStr, "%Y-%m-%d %H:%M:%S", |
| localtime((time_t*) &sb.st_mtime)); | localtime((time_t*) &sb.st_mtime)); |
| #endif | #endif |
| switch (d.d_type) { | switch (d.d_type) { |
| case DT_FIFO: | case DT_FIFO: |
| strlcpy(szType, "fifo", STRSIZ); | strlcpy(szType, "fifo", sizeof szType); |
| break; | break; |
| case DT_CHR: | case DT_CHR: |
| strlcpy(szType, "char", STRSIZ); | strlcpy(szType, "char", sizeof szType); |
| break; | break; |
| case DT_DIR: | case DT_DIR: |
| strlcpy(szType, "dir", STRSIZ); | strlcpy(szType, "dir", sizeof szType); |
| break; | break; |
| case DT_BLK: | case DT_BLK: |
| strlcpy(szType, "block", STRSIZ); | strlcpy(szType, "block", sizeof szType); |
| break; | break; |
| case DT_REG: | case DT_REG: |
| strlcpy(szType, "file", STRSIZ); | strlcpy(szType, "file", sizeof szType); |
| break; | break; |
| case DT_LNK: | case DT_LNK: |
| strlcpy(szType, "link", STRSIZ); | strlcpy(szType, "link", sizeof szType); |
| break; | break; |
| case DT_SOCK: | case DT_SOCK: |
| strlcpy(szType, "socket", STRSIZ); | strlcpy(szType, "socket", sizeof szType); |
| break; | break; |
| /* OpenBSD does not have this type */ | /* OpenBSD does not have this type */ |
| #ifdef DT_WHT | #ifdef DT_WHT |
| case DT_WHT: | case DT_WHT: |
| strlcpy(szType, "wht", STRSIZ); | strlcpy(szType, "wht", sizeof szType); |
| break; | break; |
| #endif | #endif |
| case DT_UNKNOWN: | case DT_UNKNOWN: |
| default: | default: |
| strlcpy(szType, "unknown", STRSIZ); | strlcpy(szType, "unknown", sizeof szType); |
| break; | break; |
| } | } |
| snprintf(l[n].extra, STRSIZ, | snprintf(l[n].extra, sizeof l[n].extra, |
| "%s links=%d inode=%ld %d:%d perm=0%o " | "%s links=%d inode=%ld %d:%d perm=0%o " |
| "size=%ld %s", szType, sb.st_nlink, | "size=%ld %s", szType, sb.st_nlink, |
| (long) sb.st_ino, sb.st_uid, sb.st_gid, | (long) sb.st_ino, sb.st_uid, sb.st_gid, |
| Line 436 sync_dircmpList(const char *csDir1, const char *csDir2 | Line 436 sync_dircmpList(const char *csDir1, const char *csDir2 |
| return -1; | return -1; |
| } | } |
| } | } |
| while (fgets(szLine, STRSIZ, f)) { | while (fgets(szLine, sizeof szLine, f)) { |
| if (!*szLine || *szLine == '#') | if (!*szLine || *szLine == '#') |
| continue; | continue; |
| Line 467 sync_dircmpList(const char *csDir1, const char *csDir2 | Line 467 sync_dircmpList(const char *csDir1, const char *csDir2 |
| l[n].ch = '>'; | l[n].ch = '>'; |
| l[n].tag = t; | l[n].tag = t; |
| l[n].hash = hash; | l[n].hash = hash; |
| strlcpy(l[n].name, str, MAXPATHLEN); | strlcpy(l[n].name, str, sizeof l[n].name); |
| if (lm & 1 && (str = strtok_r(NULL, "\r\n", &pbrk))) | if (lm & 1 && (str = strtok_r(NULL, "\r\n", &pbrk))) |
| strlcpy(l[n].extra, str, STRSIZ); | strlcpy(l[n].extra, str, sizeof l[n].extra); |
| n++; | n++; |
| } | } |