Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Fri 31 Oct 2014, 08:23
All times are UTC - 4
 Forum index » Taking the Puppy out for a walk » Suggestions
Rewriting pup_event in C
Moderators: Flash, Ian, JohnMurga
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
Page 5 of 7 Posts_count   Goto page: Previous 1, 2, 3, 4, 5, 6, 7 Next
Author Message
jemimah


Joined: 26 Aug 2009
Posts: 4309
Location: Tampa, FL

PostPosted: Mon 07 May 2012, 09:06    Post_subject:  

akash_rawal wrote:
jemimah wrote:

Here's the code for mounting.
Code:

gchar *mntpnt = g_build_filename(PUP_EVENT_MNTPNT, (gchar *) input, NULL);
gchar *cmd = g_strdup_printf("tmount '%s'", vol->unix_dev);
g_mkdir_with_parents(mntpnt, S_IRWXU | S_IRWXG | S_IRWXO);
g_spawn_command_line_sync(cmd, NULL, &stderr_data, &exitcode, &error);
//g_chmod(mntpnt, S_IRWXU | S_IRWXG | S_IRWXO);
g_free(cmd);


The correct code is:
Code:

gchar *mntpnt;
if (vol->label && (g_strcmp0(vol->label, "") != 0))
    mntpnt = g_build_filename(PUP_EVENT_MNTPNT, vol->label, NULL);
else
    mntpnt = g_build_filename(PUP_EVENT_MNTPNT, (gchar *) input, NULL);



Rest of the code remains as original. This will also save you from extra hassle of finding labels.


Thanks, that helps a lot.

I do like to use tmount (which is adapted from drive_all) because it does things like offer to fuser the drive when it can't be unmounted.
Back to top
View user's profile Send_private_message Visit_website 
jemimah


Joined: 26 Aug 2009
Posts: 4309
Location: Tampa, FL

PostPosted: Mon 07 May 2012, 09:08    Post_subject:  

akash_rawal wrote:
jemimah wrote:

but for some reason the blkid command returns incomplete output when run from a script called by udev as opposed to the command line. I can't figure out why.

udev removes the entire environment , including PATH variable. You have to re-export it yourself or use full path to blkid.


It's not a PATH issue. Blkid correctly returns info about every drive except the one in question. It's bizarre.
Back to top
View user's profile Send_private_message Visit_website 
jemimah


Joined: 26 Aug 2009
Posts: 4309
Location: Tampa, FL

PostPosted: Mon 07 May 2012, 10:24    Post_subject:  

The daemon crashes when loopback devices are unmounted.

Code:
Volume loop5:
   unix_dev=/dev/loop5
   label=(null)
   fstype=squashfs
   uuid=(null)
   drv_sysname=(null)
   mntpnt=/mnt/+initrd+mnt+dev_save+blender-2.61-i686.sfs
   mntflags = 0 | VOLUME_IS_READ_ONLY
*** glibc detected *** pup-volume-monitor: double free or corruption (fasttop): 0x080762a0 ***
======= Backtrace: =========
/lib/libc.so.6[0xb7552c9d]
/lib/libc.so.6[0xb7554247]
/lib/libc.so.6(cfree+0x62)[0xb7556df2]
/usr/lib/libglib-2.0.so.0(g_free+0x27)[0xb76c35e6]
/usr/lib/libpupevent.so.0(volume_free_mem+0x5c)[0xb766d67c]
pup-volume-monitor[0x804b565]
pup-volume-monitor[0x804bccf]
/usr/lib/libglib-2.0.so.0[0xb76e5cf8]
/usr/lib/libglib-2.0.so.0[0xb76e56db]
/lib/libpthread.so.0[0xb762f02f]
/lib/libc.so.6(clone+0x5e)[0xb75b5d1e]
======= Memory map: ========
08048000-0804d000 r-xp 00000000 07:01 216        /initrd/pup_rw/usr/bin/pup-volume-monitor
0804d000-0804e000 rwxp 00004000 07:01 216        /initrd/pup_rw/usr/bin/pup-volume-monitor
0804e000-08093000 rwxp 00000000 00:00 0          [heap]
b6b00000-b6b21000 rwxp 00000000 00:00 0
b6b21000-b6c00000 ---p 00000000 00:00 0
b6cd5000-b6ce1000 r-xp 00000000 07:00 7568       /initrd/pup_ro2/usr/lib/libgcc_s.so.1
b6ce1000-b6ce2000 rwxp 0000b000 07:00 7568       /initrd/pup_ro2/usr/lib/libgcc_s.so.1
b6ce2000-b6ce3000 ---p 00000000 00:00 0
b6ce3000-b74e5000 rwxp 00000000 00:00 0
b74e5000-b74e8000 r-xp 00000000 07:00 9932       /initrd/pup_ro2/lib/libuuid.so.1.3.0
b74e8000-b74e9000 rwxp 00002000 07:00 9932       /initrd/pup_ro2/lib/libuuid.so.1.3.0
b74e9000-b7623000 r-xp 00000000 07:00 9861       /initrd/pup_ro2/lib/libc-2.10.1.so
b7623000-b7625000 r-xp 0013a000 07:00 9861       /initrd/pup_ro2/lib/libc-2.10.1.so
b7625000-b7626000 rwxp 0013c000 07:00 9861       /initrd/pup_ro2/lib/libc-2.10.1.so
b7626000-b7629000 rwxp 00000000 00:00 0
b7629000-b763c000 r-xp 00000000 07:00 9933       /initrd/pup_ro2/lib/libpthread-2.10.1.so
b763c000-b763d000 r-xp 00012000 07:00 9933       /initrd/pup_ro2/lib/libpthread-2.10.1.so
b763d000-b763e000 rwxp 00013000 07:00 9933       /initrd/pup_ro2/lib/libpthread-2.10.1.so
b763e000-b7640000 rwxp 00000000 00:00 0
b7640000-b7666000 r-xp 00000000 07:00 9865       /initrd/pup_ro2/lib/libm-2.10.1.so
b7666000-b7667000 r-xp 00025000 07:00 9865       /initrd/pup_ro2/lib/libm-2.10.1.so
b7667000-b7668000 rwxp 00026000 07:00 9865       /initrd/pup_ro2/lib/libm-2.10.1.so
b7668000-b766f000 r-xp 00000000 07:01 356        /initrd/pup_rw/usr/lib/libpupevent.so.0.0.0
b766f000-b7670000 rwxp 00006000 07:01 356        /initrd/pup_rw/usr/lib/libpupevent.so.0.0.0
b7670000-b7671000 rwxp 00000000 00:00 0
b7671000-b7794000 r-xp 00000000 07:00 7492       /initrd/pup_ro2/usr/lib/libglib-2.0.so.0.3200.1
b7794000-b7795000 rwxp 00122000 07:00 7492       /initrd/pup_ro2/usr/lib/libglib-2.0.so.0.3200.1
b7795000-b7796000 rwxp 00000000 00:00 0
b7796000-b779c000 r-xp 00000000 07:00 9898       /initrd/pup_ro2/lib/librt-2.10.1.so
b779c000-b779d000 r-xp 00005000 07:00 9898       /initrd/pup_ro2/lib/librt-2.10.1.so
b779d000-b779e000 rwxp 00006000 07:00 9898       /initrd/pup_ro2/lib/librt-2.10.1.so
b779e000-b779f000 r-xp 00000000 07:00 8151       /initrd/pup_ro2/usr/lib/libgthread-2.0.so.0.3200.1
b779f000-b77a0000 rwxp 00000000 07:00 8151       /initrd/pup_ro2/usr/lib/libgthread-2.0.so.0.3200.1
b77a0000-b77b8000 r-xp 00000000 07:00 9888       /initrd/pup_ro2/lib/libblkid.so.1.1.0
b77b8000-b77ba000 rwxp 00017000 07:00 9888       /initrd/pup_ro2/lib/libblkid.so.1.1.0
b77ba000-b77c6000 r-xp 00000000 07:00 9921       /initrd/pup_ro2/lib/libudev.so.0.11.1
b77c6000-b77c7000 rwxp 0000b000 07:00 9921       /initrd/pup_ro2/lib/libudev.so.0.11.1
b77c7000-b77c8000 rwxp 00000000 00:00 0
b77c8000-b77e2000 r-xp 00000000 07:00 9953       /initrd/pup_ro2/lib/ld-2.10.1.so
b77e2000-b77e3000 r-xp 00019000 07:00 9953       /initrd/pup_ro2/lib/ld-2.10.1.so
b77e3000-b77e4000 rwxp 0001a000 07:00 9953       /initrd/pup_ro2/lib/ld-2.10.1.so
bfcce000-bfcef000 rw-p 00000000 00:00 0          [stack]
ffffe000-fffff000 r-xp 00000000 00:00 0          [vdso]
Aborted

#
Back to top
View user's profile Send_private_message Visit_website 
jemimah


Joined: 26 Aug 2009
Posts: 4309
Location: Tampa, FL

PostPosted: Mon 07 May 2012, 11:18    Post_subject:  

It seems like some sort of probing needs to happen for optical drives. Udev doesn't seem to generate any events when a CD/DVD is inserted.

Also I'm not sure how to get audio CDs to show up on the desktop. They don't seem to have any volumes associated with them.
Back to top
View user's profile Send_private_message Visit_website 
jamesbond

Joined: 26 Feb 2007
Posts: 2230
Location: The Blue Marble

PostPosted: Tue 08 May 2012, 08:54    Post_subject:  

jemimah wrote:
It seems like some sort of probing needs to happen for optical drives. Udev doesn't seem to generate any events when a CD/DVD is inserted.

Also I'm not sure how to get audio CDs to show up on the desktop. They don't seem to have any volumes associated with them.


Sigh Confused http://forum.tinycorelinux.net/index.php?topic=12176.0. Some solution here: http://www.linuxquestions.org/questions/linux-software-2/udev-not-detecting-change-in-media-for-optical-drive-930081/.

I ended up running cddetect_quick once every few seconds to generate udev events.

_________________
Fatdog64, Slacko and Puppeee user. Puppy user since 2.13.
Contributed Fatdog64 packages thread
Back to top
View user's profile Send_private_message 
akash_rawal

Joined: 25 Aug 2010
Posts: 232
Location: ISM Dhanbad, Jharkhand, India

PostPosted: Sat 12 May 2012, 08:12    Post_subject:  

jemimah wrote:

My personal thought on rewriting the event manager are this.

You need to get buy-in from Barry to use it in woof if you want it to go mainstream. The best way to do this, IMO, is to start small, debug the heck out of it, and keep it modular.

I think you are right.

Now what I have planned is that I will implement a plugin support in the volume monitor, and then attempt to write a subset of module and firmware loading. Then we'll see whether it is working better.

I have already started this task.
Back to top
View user's profile Send_private_message 
akash_rawal

Joined: 25 Aug 2010
Posts: 232
Location: ISM Dhanbad, Jharkhand, India

PostPosted: Sat 12 May 2012, 08:22    Post_subject:  

jemimah wrote:
akash_rawal wrote:
jemimah wrote:

but for some reason the blkid command returns incomplete output when run from a script called by udev as opposed to the command line. I can't figure out why.

udev removes the entire environment , including PATH variable. You have to re-export it yourself or use full path to blkid.


It's not a PATH issue. Blkid correctly returns info about every drive except the one in question. It's bizarre.

Strange.

If I were to say that device nodes were not ready yet, then my volume monitor should also not work due to exactly same problem.
Back to top
View user's profile Send_private_message 
akash_rawal

Joined: 25 Aug 2010
Posts: 232
Location: ISM Dhanbad, Jharkhand, India

PostPosted: Sat 12 May 2012, 08:29    Post_subject:  

jemimah wrote:
It seems like some sort of probing needs to happen for optical drives. Udev doesn't seem to generate any events when a CD/DVD is inserted.

Also I'm not sure how to get audio CDs to show up on the desktop. They don't seem to have any volumes associated with them.


Support for optical drives has been postponed for a while.

GIO API seems to be capable of handling optical drives. Only hurdle is that no events are raised for them and they have to be probed periodically. Maybe this can add an additional dependency.
Back to top
View user's profile Send_private_message 
jemimah


Joined: 26 Aug 2009
Posts: 4309
Location: Tampa, FL

PostPosted: Sat 12 May 2012, 11:23    Post_subject:  

akash_rawal wrote:
jemimah wrote:
akash_rawal wrote:
jemimah wrote:

but for some reason the blkid command returns incomplete output when run from a script called by udev as opposed to the command line. I can't figure out why.

udev removes the entire environment , including PATH variable. You have to re-export it yourself or use full path to blkid.


It's not a PATH issue. Blkid correctly returns info about every drive except the one in question. It's bizarre.

Strange.

If I were to say that device nodes were not ready yet, then my volume monitor should also not work due to exactly same problem.


Yeah, even if I put in a very long sleep I get the same results. During the sleep, I can get the correct results from the command line. It's odd.

EDIT: No the above is wrong. It doesn't work from the commandline either until the udev event queue is finished. Guess_fstype doesn't always work either until the queue is finished.

Therefore, I need to have pup-volume-monitor kick off my script - it can't be done from udev as far as I can tell.

_________________
http://saluki-linux.com

Edited_time_total
Back to top
View user's profile Send_private_message Visit_website 
jemimah


Joined: 26 Aug 2009
Posts: 4309
Location: Tampa, FL

PostPosted: Sat 12 May 2012, 11:28    Post_subject:  

akash_rawal wrote:
jemimah wrote:
It seems like some sort of probing needs to happen for optical drives. Udev doesn't seem to generate any events when a CD/DVD is inserted.

Also I'm not sure how to get audio CDs to show up on the desktop. They don't seem to have any volumes associated with them.


Support for optical drives has been postponed for a while.

GIO API seems to be capable of handling optical drives. Only hurdle is that no events are raised for them and they have to be probed periodically. Maybe this can add an additional dependency.


It kindof works for DVDs if I run the probing from another script. But the new drives won't show up on the desktop or in Thunar unless I restart them.

How do I get the daemon to update everything?

_________________
http://saluki-linux.com
Back to top
View user's profile Send_private_message Visit_website 
jemimah


Joined: 26 Aug 2009
Posts: 4309
Location: Tampa, FL

PostPosted: Sat 12 May 2012, 13:33    Post_subject:  

I've been looking at this more closely. So I've got udev generating change events:


Code:
UDEV  [1336829402.295403] add      /devices/pci0000:00/0000:00:1d.7/usb1/1-2/1-2.4/1-2.4:1.0/host16/target16:0:0/16:0:0:0/block/sr0 (block)
UDEV  [1336829402.306227] change   /devices/pci0000:00/0000:00:1d.7/usb1/1-2/1-2.4/1-2.4:1.0/host16/target16:0:0/16:0:0:0/block/sr0 (block)
KERNEL[1336829410.629103] change   /devices/pci0000:00/0000:00:1d.7/usb1/1-2/1-2.4/1-2.4:1.0/host16/target16:0:0/16:0:0:0/block/sr0 (block)
UDEV  [1336829410.641071] change   /devices/pci0000:00/0000:00:1d.7/usb1/1-2/1-2.4/1-2.4:1.0/host16/target16:0:0/16:0:0:0/block/sr0 (block)



And the pup-volume-monitor is working

Code:
Drive sr0:
   unix_dev=/dev/sr0
   model=CDDVDW SE-S084C
   vendor=TSSTcorp
   props = 0 | DRIVE_USB | DRIVE_SCSI | DRIVE_REMOVABLE | DRIVE_FLASH
Drive changed
Drive sr0:
   unix_dev=/dev/sr0
   model=CDDVDW SE-S084C
   vendor=TSSTcorp
   props = 0 | DRIVE_USB | DRIVE_SCSI | DRIVE_REMOVABLE | DRIVE_FLASH
Drive changed
Drive sr0:
   unix_dev=/dev/sr0
   model=CDDVDW SE-S084C
   vendor=TSSTcorp
   props = 0 | DRIVE_USB | DRIVE_SCSI | DRIVE_REMOVABLE | DRIVE_FLASH
Volume changed
Volume sr0:
   unix_dev=/dev/sr0
   label=SERENITY
   fstype=udf
   uuid=
   drv_sysname=sr0
   mntpnt=
   mntflags = 0


But optical drives do no show up on the desktop unless I restart it. Also the drive does not disappear if i eject the disk or if I unplug the whole drive (it's usb).

I think change events are not being handled correctly.

_________________
http://saluki-linux.com
Back to top
View user's profile Send_private_message Visit_website 
jamesbond

Joined: 26 Feb 2007
Posts: 2230
Location: The Blue Marble

PostPosted: Sun 13 May 2012, 00:30    Post_subject:  

jemimah wrote:
I've been looking at this more closely. So I've got udev generating change events:


Code:
UDEV  [1336829402.295403] add      /devices/pci0000:00/0000:00:1d.7/usb1/1-2/1-2.4/1-2.4:1.0/host16/target16:0:0/16:0:0:0/block/sr0 (block)
UDEV  [1336829402.306227] change   /devices/pci0000:00/0000:00:1d.7/usb1/1-2/1-2.4/1-2.4:1.0/host16/target16:0:0/16:0:0:0/block/sr0 (block)
KERNEL[1336829410.629103] change   /devices/pci0000:00/0000:00:1d.7/usb1/1-2/1-2.4/1-2.4:1.0/host16/target16:0:0/16:0:0:0/block/sr0 (block)
UDEV  [1336829410.641071] change   /devices/pci0000:00/0000:00:1d.7/usb1/1-2/1-2.4/1-2.4:1.0/host16/target16:0:0/16:0:0:0/block/sr0 (block)



How do you get this without doing ioctl call on the device? Shocked

_________________
Fatdog64, Slacko and Puppeee user. Puppy user since 2.13.
Contributed Fatdog64 packages thread
Back to top
View user's profile Send_private_message 
akash_rawal

Joined: 25 Aug 2010
Posts: 232
Location: ISM Dhanbad, Jharkhand, India

PostPosted: Sun 13 May 2012, 02:12    Post_subject:  

If you do manage to generate udev events for optical drives, it will be detected as an internal hard drive or usb flash drive.

You won't have options like ejecting and loading the tray till the support for optical drives is added.
Back to top
View user's profile Send_private_message 
amigo

Joined: 02 Apr 2007
Posts: 2263

PostPosted: Sun 13 May 2012, 02:41    Post_subject:  

CD/DVD drives themselves do not generate any sort of signal when the door is opened or closed. The only way to tell is by polling the device and checking to see whether a disk is there -audio discs are particularly hard to detect.
On my old system, I use a program called 'autorun' to handle CD drives. It runs as a daemon and can be configured to handle different types of disks. If a CD is detected and is mountable, then it is mounted and opened with rox. If it is blank, then it starts my CD burner -can't remember what it does with audio disks...
Back to top
View user's profile Send_private_message 
disciple

Joined: 20 May 2006
Posts: 6449
Location: Auckland, New Zealand

PostPosted: Sun 13 May 2012, 05:29    Post_subject:  

Do you have that in your repo somewhere?
_________________
DEATH TO SPREADSHEETS
- - -
Classic Puppy quotes
- - -
Beware the demented serfers!
Back to top
View user's profile Send_private_message 
Display_posts:   Sort by:   
Page 5 of 7 Posts_count   Goto page: Previous 1, 2, 3, 4, 5, 6, 7 Next
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
 Forum index » Taking the Puppy out for a walk » Suggestions
Jump to:  

Rules_post_cannot
Rules_reply_cannot
Rules_edit_cannot
Rules_delete_cannot
Rules_vote_cannot
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1205s ][ Queries: 13 (0.0093s) ][ GZIP on ]