First, you can not convert the addresses to have just 8 digits. Memory addresses can and will have much larger values than could be represented with just 8 digits.
The reason why memory addresses are represented in /proc/pid/maps
as they are is on the line 283 in fs/proc/task_mmu.c
(or task_nommu.c
) in a recent kernel source tree:
283 seq_printf(m, "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu ",
284 start,
285 end,
286 flags & VM_READ ? 'r' : '-',
287 flags & VM_WRITE ? 'w' : '-',
288 flags & VM_EXEC ? 'x' : '-',
289 flags & VM_MAYSHARE ? 's' : 'p',
290 pgoff,
291 MAJOR(dev), MINOR(dev), ino);
What this boils down to is that in any memory address which has a hex string representation shorter than 8 digits, will get padded with leading zeros. Any value larger than that will be represented as it is, not truncated to 8 digits. That's just the way how printk()
's printf-style formatting works.
Now what to make out of all this? Probably you should take a minute to think about why would you want to truncate memory addresses to 8 digits. What do you think is the benefit of doing so?
Best Answer
Yes, that's the PID of ls.
POSIX defined
ls
as an external command, so anytime you runls
, the shell must create new process and runls
in that process.To do that, the shell will call execve() system call:
You can see, after new process was created,
/proc/self
belongs to context of that process, so it was expanded to the PID ofls
.