[cs631apue] Sorting working on Linux, but not Unix

Jason Ajmo jajmo at stevens.edu
Fri Sep 29 12:53:37 EDT 2017


Thanks for clarifying NetBSD vs. Unix.

I have verified the function is being executed, but I just found some more
interesting behavior. I stuck a print statement in the block where it
compares filesizes, and the output is interesting.

On NetBSD:
Comparing .test: 3 and print.o: 11496
Comparing helpers.c: 1846 and .test: 3
Comparing sort.o: 3720 and .test: 3
Comparing include: 4096 and .test: 3
Comparing GNUmakefile: 566 and .test: 3
Comparing helpers.o: 3968 and .test: 3
Comparing print_recurse.c: 1494 and .test: 3
Comparing ls: 22842 and .test: 3
Comparing print_recurse.o: 2848 and .test: 3
Comparing print_dir.o: 3256 and .test: 3
Comparing ls.o: 7504 and .test: 3
Comparing print.c: 7045 and .test: 3
Comparing sort.c: 6206 and .test: 3
Comparing ls.c: 3283 and .test: 3
Comparing print_dir.c: 1672 and .test: 3
Comparing README: 1392 and .test: 3
Comparing Makefile: 546 and .test: 3
Comparing print.o: 11496 and .test: 3

On Linux:
<snip>
Comparing include: 4096 and helpers.o: 4152
Comparing include: 4096 and print_recurse.o: 3112
Comparing print_dir.o: 3664 and print_recurse.o: 3112
Comparing helpers.c: 1846 and print_recurse.o: 3112
Comparing helpers.c: 1846 and print_recurse.c: 1494
Comparing .test: 3 and ls.o: 7888
Comparing print.c: 7045 and sort.c: 6206
Comparing ls.o: 7888 and print.c: 7045
Comparing .test: 3 and print.c: 7045
Comparing .test: 3 and sort.c: 6206
Comparing ls.c: 3283 and print_dir.c: 1672
Comparing Makefile: 546 and print.o: 12800
Comparing README: 1392 and print.o: 12800
Comparing README: 1392 and Makefile: 546
Comparing ls.c: 3283 and print.o: 12800
Comparing ls.c: 3283 and README: 1392
Comparing print_dir.c: 1672 and README: 1392
<snip>

So now it's clear why it's not sorting properly. On NetBSD the size is
always being compared to 3, the size of the test 'hidden' file. But I have
no idea why...

On Fri, Sep 29, 2017 at 12:17 PM Jan Schaumann <jschauma at stevens.edu> wrote:

> Jason Ajmo <jajmo at stevens.edu> wrote:
> > Code: https://gist.github.com/jajmo/5e4e7827fd5b52549132a6a6364c4e53
> > The following are sorted based on filesize, descending (ls -lS)
> > On Linux, the objects are linked with -lbsd, and include bsd/bsd.h.
> >
> > Output on Unix:
>
> I think you mean 'NetBSD', which is a Unix-like OS.
> https://en.wikipedia.org/wiki/Unix-like
>
> > [vagrant at vagrant midterm]$ ./ls -lS
> > total 216
> > -rw-r--r--  1 vagrant 1000  1846 Sep 28 16:29 helpers.c
> > -rw-r--r--  1 vagrant 1000  3376 Sep 29 15:59 sort.o
>
> Weird.  Looks like no sorting is taking place at all.  Have you
> confirmed that the code block you think is being executed is in fact
> being executed?
>
> -Jan
> _______________________________________________
> cs631apue mailing list
> cs631apue at lists.stevens.edu
> https://lists.stevens.edu/mailman/listinfo/cs631apue
>
-- 
Jason Ajmo
Stevens Institute of Technology
B.S. Cybersecurity '17
M.S. Computer Science '18
0x56FA3123
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.stevens.edu/pipermail/cs631apue/attachments/20170929/9cbd1628/attachment-0001.html>


More information about the cs631apue mailing list