diff --git a/CHANGES.txt b/CHANGES.txt index 41909027b49b23cf4dc56589f028c9dd2a407295..77d1b2be6194efe0f90419b52744ac51dbbb4e9f 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -68,6 +68,9 @@ of file system and not local system. Created new conversion function and changed a couple of other spots that had similar bug. Reported by Rob Joyce. +4/11/09: Bug Fix: Fixed issue 2662168 re: warning messages on macs +when reading the raw character device. patch by Rob Joyce. + ---------------- VERSION 3.0.0 -------------- 0/00/00: Update: Many, many, many API changes. diff --git a/tsk3/img/raw.c b/tsk3/img/raw.c index 3a362673b8ef272c2d127aa1bf4f32f868251c83..515f1d00536430e9fab9b0d546b1632b7df05a3c 100644 --- a/tsk3/img/raw.c +++ b/tsk3/img/raw.c @@ -210,30 +210,34 @@ raw_open(const TSK_TCHAR * image) "raw_open: Trying Windows device with share_write mode\n"); raw_info->fd = CreateFile(image, FILE_READ_DATA, - FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); + FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, + OPEN_EXISTING, 0, NULL); } if (raw_info->fd == INVALID_HANDLE_VALUE) { tsk_error_reset(); tsk_errno = TSK_ERR_IMG_OPEN; // print string of commonly found errors - if (GetLastError() == ERROR_ACCESS_DENIED) { - snprintf(tsk_errstr, TSK_ERRSTR_L, - "raw_open file: %" PRIttocTSK " (Access Denied)", image); - } - else if (GetLastError() == ERROR_SHARING_VIOLATION) { - snprintf(tsk_errstr, TSK_ERRSTR_L, - "raw_open file: %" PRIttocTSK " (Sharing Violation)", image); - } + if (GetLastError() == ERROR_ACCESS_DENIED) { + snprintf(tsk_errstr, TSK_ERRSTR_L, + "raw_open file: %" PRIttocTSK " (Access Denied)", + image); + } + else if (GetLastError() == ERROR_SHARING_VIOLATION) { + snprintf(tsk_errstr, TSK_ERRSTR_L, + "raw_open file: %" PRIttocTSK + " (Sharing Violation)", image); + } else if (GetLastError() == ERROR_FILE_NOT_FOUND) { - snprintf(tsk_errstr, TSK_ERRSTR_L, - "raw_open file: %" PRIttocTSK " (File not found)", image); - } - else { - snprintf(tsk_errstr, TSK_ERRSTR_L, - "raw_open file: %" PRIttocTSK " (%d)", image, - (int)GetLastError()); - } + snprintf(tsk_errstr, TSK_ERRSTR_L, + "raw_open file: %" PRIttocTSK " (File not found)", + image); + } + else { + snprintf(tsk_errstr, TSK_ERRSTR_L, + "raw_open file: %" PRIttocTSK " (%d)", image, + (int) GetLastError()); + } return NULL; } } @@ -248,7 +252,7 @@ raw_open(const TSK_TCHAR * image) tsk_errno = TSK_ERR_IMG_OPEN; snprintf(tsk_errstr, TSK_ERRSTR_L, "raw_open file: %" PRIttocTSK " GetFileSize: %d", - image, (int)GetLastError()); + image, (int) GetLastError()); return NULL; } img_info->size = dwLo | ((TSK_OFF_T) dwHi << 32); @@ -265,7 +269,7 @@ raw_open(const TSK_TCHAR * image) tsk_errno = TSK_ERR_IMG_OPEN; snprintf(tsk_errstr, TSK_ERRSTR_L, "raw_open file: %" PRIttocTSK - " DeviceIoControl: %d", image, (int)GetLastError()); + " DeviceIoControl: %d", image, (int) GetLastError()); return NULL; } @@ -286,13 +290,13 @@ raw_open(const TSK_TCHAR * image) return NULL; } - /* We don't use the stat output because it doesn't work on raw - * devices and such */ - img_info->size = lseek(raw_info->fd, 0, SEEK_END); - lseek(raw_info->fd, 0, SEEK_SET); - #if defined(__APPLE__) - /* OS X doesn't support SEEK_END on devices */ + /* OS X doesn't support SEEK_END on char devices */ + if ((stat_buf.st_mode & S_IFMT) != S_IFCHR) { + img_info->size = lseek(raw_info->fd, 0, SEEK_END); + lseek(raw_info->fd, 0, SEEK_SET); + } + if (img_info->size == 0) { int blkSize; long long blkCnt; @@ -303,7 +307,12 @@ raw_open(const TSK_TCHAR * image) } } } -#endif // apple +#else + /* We don't use the stat output because it doesn't work on raw + * devices and such */ + img_info->size = lseek(raw_info->fd, 0, SEEK_END); + lseek(raw_info->fd, 0, SEEK_SET); +#endif #endif raw_info->seek_pos = 0;