Re: Possibly OT: why doesn't od dump anything when given a directory as an arg?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Karthik Subramanian wrote:

Hi Folks,

I was dusting my old copy of Kernighan & Pike, and I remembered
working out most of the examples on an antiquated unix machine in
engineering school. I decided to try out some just for kicks, and I
discovered something:

In page 51 of K&P, there's an example that runs od on a directory, and
the dump actually shows the filenames. I tried doing that (running 'od
.' ) on my linux box, and got this instead:

od: .: Is a directory
0000000

So why doesn't od work on directories? Could somebody shed some light
on this, please!

Thanks in Advance,
Karthik.

hi there,

hope the trace below on "od" tells you why :
Note dns is a directory , an argument to "od" command.

open("dns", O_RDONLY|O_LARGEFILE) = 3
fstat64(3, {st_mode=S_IFDIR|0775, st_size=4096, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40056000
read(3, 0x40056000, 4096) = -1 EISDIR (Is a directory)
write(2, "od: ", 4od: ) = 4
write(2, "dns", 3dns) = 3
open("/usr/share/locale/en_US.iso885915/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en_US/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en.iso885915/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
write(2, ": Is a directory", 16: Is a directory) = 16
write(2, "\n", 1
) = 1
close(3) = 0
munmap(0x40056000, 4096) = 0
fstat64(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 0), ...}) = 0 /* Success */
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40056000
write(1, "0000000\n", 80000000
) = 8
munmap(0x40056000, 4096) = 0
_exit(1) = ?



hope that helps .

cheers,
Amith



--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux