cs35Llab5

cs35Llab5 - by function sort_files. 2. Within the...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
1. Download coreutils-with-bug wget http://www.cs.ucla.edu/classes/winter08/cs35L/assign/coreutils-with-bug.tar.gz 2. Untar gzip -cd coreutils-with-bug.tar.gz | tar xvf - 3. Change working directory to coreutils-with-bug cd coreutils-with-bug/ 4. Configure with prefix ./configure --prefix=/ramdisk/home/knoppix/Desktop/cu 5. Configure make file flag CFLAGS from -02 to -00 vi Makefile 6. Compile make 7. Simulate bug mkdir test cd test touch -d '1918-11-11 11:00 GMT' wwi-armistice touch now sleep 1 touch now1 ./ls -lt wwi-armistice now now1 -rw-r--r-- 1 knoppix knoppix 0 Nov 11 1918 wwi-armistice -rw-r--r-- 1 knoppix knoppix 0 Feb 8 22:15 now1 -rw-r--r-- 1 knoppix knoppix 0 Feb 8 22:15 now 8. Load ls under gdb gdb ls --------------Debug------------------ 1. After going through ls.c in Kwrite, I found out that the -t paramter/option configures the sort_type variable, and the time sorting functionality is provided
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: by function sort_files. 2. Within the sort_files function, several helper functions are used: compare_ctime, compare_mtime, compare_atime 3. After tracing into those three helper functions, I found out that all of them uses another function, timespec_cmp, which is located in timespec.h. 4. It seemed that timespec_cmp's return value becomes incorrect when the time difference is too big (overflow?). To fix it, instead of simply returning the difference, the function now returns -1 when a.tv_sec is less than b.tv_sec, returns 1 when a.tv_sec is greater than b.tv_sec, and if both cases dont meet, return the difference between the a.tv_nsec and b.tv_nsec return (a.tv_sec < b.tv_sec ? -1 : a.tv_sec > b.tv_sec ? 1 : a.tv_nsec - b.tv_nsec);------------------------------------9. Generate the patch file with cvs cvs diff -u timespec.h.orig timespec.h > lab5.patch...
View Full Document

This note was uploaded on 06/02/2009 for the course CS 35L taught by Professor Eggert during the Spring '09 term at UCLA.

Page1 / 2

cs35Llab5 - by function sort_files. 2. Within the...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online