|
2013-11-05
, 01:07
|
Posts: 2,225 |
Thanked: 3,822 times |
Joined on Jun 2010
@ Florida
|
#32
|
|
2013-11-05
, 03:38
|
Posts: 2,225 |
Thanked: 3,822 times |
Joined on Jun 2010
@ Florida
|
#33
|
Besides that, here's a headscratcher (although the question is just a pure why rather than it getting in the way of a solution at the moment): /dev/shm DOES show up as mounted if you run 'mount'. rdmod segfaults. Then you run 'mount -t tmpfs tmpfs /dev/shm'. /dev/shm shows up in the same exact way in 'mount' output again. No change what so ever. Yet rdmod stops segfaulting.
|
2013-11-05
, 08:31
|
Posts: 1,808 |
Thanked: 4,272 times |
Joined on Feb 2011
@ Germany
|
#34
|
Partial answer to my own question: /proc/mounts is where the actually accurate mounts data is, 'mount' with no arguments seems to print out a list that doesn't reflect the current mounts, at least at that stage of boot. *Shrug*
mount -n -o size=64M,nosuid,nodev,noatime -t tmpfs tmpfs /dev/shm
rm -f /etc/mtab cat /proc/mounts > /etc/mtab
The Following 5 Users Say Thank You to reinob For This Useful Post: | ||
|
2013-11-06
, 00:58
|
Posts: 2,225 |
Thanked: 3,822 times |
Joined on Jun 2010
@ Florida
|
#35
|
You just opened the "/etc/mtab vs /proc/mounts (or /proc/self/mounts)" pandora box
The actual information regarding mounted filesystems (as seen by the kernel) is in /proc/mounts (or /proc/self/mounts if you want to be chroot-compatible).
The program "mount" writes to /etc/mtab. The program "umount" writes (deletes lines from) /etc/mtab.
Normally /etc/mtab contains the same information as (or rather, information consistent with) /proc/mounts.
However if the computer crashes it doesn't get a chance to delete /etc/mtab, so upon reboot /etc/mtab will contain stuff that possibly is not relevant anymore. For that reason some people make /etc/mtab be a symlink to /proc/[self/]mounts. However this breaks other stuff.
Ideally /etc/mtab should be wiped during (early) boot, i.e. before anything is mounted. I don't know (at the moment) if/how Maemo5 handles this.
EDIT: In /etc/init.d/rcS you have
and a bit laterCode:mount -n -o size=64M,nosuid,nodev,noatime -t tmpfs tmpfs /dev/shm
Code:rm -f /etc/mtab cat /proc/mounts > /etc/mtab
and for completeness, if I look in my /dev/shm I have a 20-byte file called "sem.nokiacal" containing, in hex:
"01000000 00000000 00000000 00000000"
/usr/bin/cal-tool uses libphread.so, so I guess it uses sem_open(3) to create a named semaphore. It is (I think) the kernel which takes care of creating the named file under /dev/shm.
so basically sem_open("/my_semaphoe", ...) will create /dev/shm/sem.my_semaphore
|
2013-11-06
, 07:52
|
Posts: 2,225 |
Thanked: 3,822 times |
Joined on Jun 2010
@ Florida
|
#36
|
The Following 4 Users Say Thank You to Mentalist Traceur For This Useful Post: | ||
|
2013-11-06
, 08:18
|
Posts: 3,074 |
Thanked: 12,961 times |
Joined on Mar 2010
@ Sofia,Bulgaria
|
#37
|
The Following 3 Users Say Thank You to freemangordon For This Useful Post: | ||
|
2013-11-06
, 08:27
|
Posts: 2,225 |
Thanked: 3,822 times |
Joined on Jun 2010
@ Florida
|
#38
|
|
2013-11-06
, 08:56
|
Posts: 2,225 |
Thanked: 3,822 times |
Joined on Jun 2010
@ Florida
|
#39
|
The Following User Says Thank You to Mentalist Traceur For This Useful Post: | ||
|
2013-11-06
, 08:57
|
Posts: 2,225 |
Thanked: 3,822 times |
Joined on Jun 2010
@ Florida
|
#40
|
gcc -lcal -o [name you want the output file to have; without -o flag, defaults to "a.out"] [name of source file]
Tags |
command line, on device, r&d mode |
|
For everyone else who's curious, my understanding is: Semaphores need a spot in shared memory that they can be stored in (it can be shared either between different threads in a single process, or between different processes - libcal uses the latter). I guess the default location for that is whatever virtual filesystem /dev/shm is mounted as. At the stage were my preinit shell prompt runs, /dev/shm is not mounted, so the sempahore creation fails.
Thankfully, /dev/shm is a simple tmpfs filesystem in typical Linuxes, so "mount -t tmpfs tmpfs /dev/shm" as root is sufficient; then rdmod runs with no segfaults!
Furthermore, now that I understand this, I can understand more of the straces of rdmod vs. cal-tool. It seems that cal-tool, upon detecting that /dev/shm is missing (it doesn't seem to be catching the segfault, rather I assume it actually checks for it somehow), it seems to call mmap, after which it creates the semaphore in /tmp/ instead of /dev/shm/. (This is an educated guess interpretation based on the fact that there is a stat() call on /dev/shm, followed by an mmap() call, followed by a stat() on /tmp, whereas rdmod just does the first stat and then segfaults. My strace reading skills are still in their early stages.) [Edit]Correction, it's statfs(), not 'stat()', that it calls on the directories, and more importantly, the mmap does not seem to be the thing that matters in this situation, as a closer look shows there's a bunch of mmap calls all over the place leading up to the segfault and I don't think that that one mmap has anything to do with cal-tool managing to switch to using /tmp as a spot for its semaphore.[/Edit]
(In retrospect last year when I was trying to figure this stuff out with strace on cal-tool vs my rdmod I should've known to look into /dev/shm (as it gets stat'ed right before the segfault, which I had seen last year) but at the time I had no context to know what it meant, and I think eithout understanding that semaphores were used I'd've prob'ly not realized the significance of anything I found at the time even if I did think to attribute any significance to /dev/shm.)
The next few steps are to figure out how to either mount /dev/shm from rdmod when needed, or I think even better, do what cal-tool does and use mmap somehow.
If you want to donate in support of anything that I do, you can do so with either of these options:
PayPal | Bitcoin: 1J4XG2z97iFEKNZXThHdFHq6AeyWEHs8BJ | [Will add other donation options eventually]
Last edited by Mentalist Traceur; 2013-11-04 at 23:41.