Rewriting pup_event in C

What features/apps/bugfixes needed in a future Puppy
Message
Author
jamesbond
Posts: 3433
Joined: Mon 26 Feb 2007, 05:02
Location: The Blue Marble

#16 Post by jamesbond »

The problem discussed here is not just performance issues. The problem is also to 'unlock' drive management features present in many programs which were unused because of absence of backends in GIO. Till now, the ROX desktop was the only way to access the drives. If user uses another DE, (s)he is helpless unless (s)he can hack /sbin/pup_event_frontend_d .
I agree with this, but I think this has been solved in other ways before. I remember seeing floating drive tray icons in the days of puppy4. Not sure where what's the state of that now, and what was used to implement it.

But doing it in C, especially tying to GTK/GIO - hmmm ... upgrade GTK and stuff breaks. Well not always, but sometimes they do. I would rather we have a non-X daemon that communicates with a GUI tool. The GUI tool can change time to time (GTK/Qt/Xlib/whatever), but the daemon stays the same, so I prefer that daemon to be in script instead of C.

As jemimah said before, though (welcome back Jemimah, glad to see you back from hibernation), pup_event_frontend_d is doing much more than just icons. I'm also considering to replace it - but before I can do that I must understand every aspects of it :) Needless to say, there are many hooks beyond that file everywhere in the system (to name a few: save2flash, mount, umount ...)

If you still insist in C, like technosaurus said in another thread, there is always tcc and you can make a C script (yes, a C script - the real thing, not an oxymoron).

@Jemimah - I was considering udisk, but now you tell me it depends on a lot of other stuff that I don't want, I think I'd stay away. I thought freedesktop.org would implement lightweight stuff and let the DE takes care of the full functionality? Hmmm...
Fatdog64 forum links: [url=http://murga-linux.com/puppy/viewtopic.php?t=117546]Latest version[/url] | [url=https://cutt.ly/ke8sn5H]Contributed packages[/url] | [url=https://cutt.ly/se8scrb]ISO builder[/url]

User avatar
jemimah
Posts: 4307
Joined: Wed 26 Aug 2009, 19:56
Location: Tampa, FL
Contact:

#17 Post by jemimah »

jamesbond wrote:
@Jemimah - I was considering udisk, but now you tell me it depends on a lot of other stuff that I don't want, I think I'd stay away. I thought freedesktop.org would implement lightweight stuff and let the DE takes care of the full functionality? Hmmm...
PolicyKit looks like a hard dependency. Maybe it can be hacked. I haven't tried that yet.

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#18 Post by technosaurus »

@jamesbond
yes, I made a script for jwm that is part of my jwm_tools package and later adapted it as an example in "Sit" my simple icon tray here:
http://www.murga-linux.com/puppy/viewtopic.php?t=76431
but the code could just as easily be adapted to work with wbar or whatever (I don't know for sure on the gnome-centric file managers though, specifically because I avoided them after discovering they all had this issue ... eventually pushing me back to gtk1.2) - I could probably make a hacky version of gvfs based on it - enough to work with gio, but every time I have sat down to look for it, I have lost interest before finding the exact code - maybe jemimah's link to the patch will help point me in the right direction. ... I'd really like to get glib/gtk "fixed" before the next major abiword release though - last time I had to build it on Puppy-4.1 with a lot of rebuilt libs just to get it working.

btw scripting with tcc is a good tool for _developing_, but never as fast as precompiled ... but it may also save some size on smaller code <~4kb (elf garbage)
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

User avatar
jemimah
Posts: 4307
Joined: Wed 26 Aug 2009, 19:56
Location: Tampa, FL
Contact:

#19 Post by jemimah »

jemimah wrote:
jamesbond wrote:
@Jemimah - I was considering udisk, but now you tell me it depends on a lot of other stuff that I don't want, I think I'd stay away. I thought freedesktop.org would implement lightweight stuff and let the DE takes care of the full functionality? Hmmm...
PolicyKit looks like a hard dependency. Maybe it can be hacked. I haven't tried that yet.
I just had a look at the code. I was able to get it to compile and run without policykit. I'm not sure it's working, but I will try to get it to work for Saluki-2. It'd would be nice to have native disk handling in thunar.

akash_rawal
Posts: 229
Joined: Wed 25 Aug 2010, 15:38
Location: ISM Dhanbad, Jharkhand, India

#20 Post by akash_rawal »

jamesbond wrote: But doing it in C, especially tying to GTK/GIO - hmmm ... upgrade GTK and stuff breaks. Well not always, but sometimes they do. I would rather we have a non-X daemon that communicates with a GUI tool. The GUI tool can change time to time (GTK/Qt/Xlib/whatever), but the daemon stays the same, so I prefer that daemon to be in script instead of C.
I am not trying to change the source code of GIO or GTK. Nor gvfs does.

I am writing a GIO module, so that we don't need to install gvfs just for volume monitoring features. Nothing breaks in case of any upgrades unless GIO introduces incompatible API changes (which they must mention in documentation). This is not a hack.

I think there is a lot of confusion regarding this. Let me clarify.

Here's my design of the event management system:
Image

The GIO module that I am writing is a part of this implementation. It will make the programs communicate with the backend. So far I am having a good progress, without those heavy dependencies like gnome-disk-utility, udisks, gudev, PolicyKit, or even dbus.

The reason that you mentioned actually favours the backend to be written in C. The design you mentioned is already present in my volume monitor. It is in fact very easy to implement in C.

The frontend will be completely different process, outside of the event management. It will communicate with the backend just like all other programs.

User avatar
jemimah
Posts: 4307
Joined: Wed 26 Aug 2009, 19:56
Location: Tampa, FL
Contact:

#21 Post by jemimah »

This seems interesting. I'm definitely looking forward to testing it. I think replacing pup_event_frontend_d with something more flexible and extensible is a big step toward making puppy a "real" distro" (there are a few more places with a lot of ad hoc hard coded stuff that need work as well).

Getting gvfs volume monitoring to work is a separate (but important if you are not using rox) issue.

User avatar
jemimah
Posts: 4307
Joined: Wed 26 Aug 2009, 19:56
Location: Tampa, FL
Contact:

#22 Post by jemimah »

Ok so I've spent the entire weekend banging my head against getting drives to show up in thunar.

I've got no dice with either gvfs/udisks or the simple volume monitor posted here. :(

Getting errors like "Could not detect the volume corresponding to the device"

Akash_rawal, have you had any success with anything like this so far?

gcmartin

#23 Post by gcmartin »

jemimah wrote:Ok so I've spent the entire weekend banging my head against getting drives to show up in thunar. ...
Jemimah, as everyone knows I am no developer. But, could the visibility drives problems that have been an issue in Puppies over the past 8 months be related to what you are seeing?

If this yield a clue, to you or any of the developers, it may help.

User avatar
jemimah
Posts: 4307
Joined: Wed 26 Aug 2009, 19:56
Location: Tampa, FL
Contact:

#24 Post by jemimah »

Ok I figured out to set the PUP_VOLUME_MONITOR_USE environment variable and have now progressed to segfaults - yay, finally something that I understand how to debug!

Code: Select all

0  0x00000000 in ?? ()
#1  0xb78ab4d5 in g_drive_is_media_removable () from /usr/lib/libgio-2.0.so.0
#2  0x0808b0b5 in thunar_g_volume_is_removable (volume=0x8221660) at thunar-gio-extensions.c:487
#3  0x080c2c18 in thunar_shortcuts_model_init (model=0x8221240) at thunar-shortcuts-model.c:300
#4  0xb785e35e in g_type_create_instance () from /usr/lib/libgobject-2.0.so.0
#5  0xb784868e in ?? () from /usr/lib/libgobject-2.0.so.0
#6  0xb7847b25 in g_object_newv () from /usr/lib/libgobject-2.0.so.0
#7  0xb784795e in g_object_new () from /usr/lib/libgobject-2.0.so.0
I'm guessing this is because the implementation is not complete yet. I'd be really psyched if we could get this working.

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#25 Post by technosaurus »

jemimah, it may help to make a symlink to /media from /mnt ... but iirc, you already fixed that. aside from that all I can think of to add for dynamic drives would be to use inotify_add_watch for an IN_CREATE in /sys/block/ (i'm pretty sure most recent puppies after 4.3.X have inotify ) ... although I believe glib has a similar function - it may be gvfs based
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

User avatar
jemimah
Posts: 4307
Joined: Wed 26 Aug 2009, 19:56
Location: Tampa, FL
Contact:

#26 Post by jemimah »

I did fix the /media thing in both glib and in udisks (when I was playing with that - but I've given up on it since the dbus stuff makes debugging it nearly impossible).

I'm pretty sure the problem is that the gio is not returning enough information. Like with udisks, it would get a volume list but it could not figure out the device path names or filesystems.

I think with udisks, either udisks itself, udev, or glib is broken - but I can't figure out which.

I think a simple volume monitor like this one is a far nicer solution - though thunar stills needs gvfs if you want a trashcan.

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#27 Post by technosaurus »

all block devices get symlinks in /sys/block/<drive>
if you follow that symlink, the directory contains a directory(ies) representing the partition(s), but don't tell the fs type (however blkid will, along with UUID - or the deprecated guessfstype - no UUID)
/proc/partitions is a good alternative though - gives quite a bit of info

SpaceFM, the fork of PCManFM 0.5.X (not the one used by LXDE), has an implementation if you need some code to borrow - I posted a pet, but it is a bit outdated - the homepage has moved to:
http://ignorantguru.github.com/spacefm/
SpaceFM 0.7.5 does not require udisks (only udev). However, in order to mount or unmount devices as a non-root user, you will need pmount or udisks installed, or will need to specify a custom program to be used. A custom mount solution is currently under development. Also, enabling kernel polling ...
... this one is actually pretty nice

Another one that has support for mount/unmount-ing removable drives is rodent file manager (a fork of xffm)
http://xffm.org/
it monitors /proc/partitions, but it must be enabled at compile time with --enable-fstab-plugin ... that may actually make it easier to find the code (by grepping for ifdefs)
I like a lot of the ideas of this project, but the implementation of the ideas didn't seem to be polished yet.
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

User avatar
jemimah
Posts: 4307
Joined: Wed 26 Aug 2009, 19:56
Location: Tampa, FL
Contact:

#28 Post by jemimah »

I've tracked the problem to this function:

Code: Select all

GDrive *pup_volume_get_drive(GVolume *volume)
{
	PupVolume *self = PUP_VOLUME(volume);
	PVM_LOCK(self);
	Drive *drive = g_hash_table_lookup(self->monitor->drives, self->data->drv_sysname);
	GDrive *ret =  G_DRIVE(pup_drive_get(self->monitor, drive));
	PVM_UNLOCK(self);
	
	return ret;
}

drive ends up null and causes the segfault. But any fix I make here ends up with a segfault somewhere else.

User avatar
jemimah
Posts: 4307
Joined: Wed 26 Aug 2009, 19:56
Location: Tampa, FL
Contact:

#29 Post by jemimah »

technosaurus wrote:all block devices get symlinks in /sys/block/<drive>
if you follow that symlink, the directory contains a directory(ies) representing the partition(s), but don't tell the fs type (however blkid will, along with UUID - or the deprecated guessfstype - no UUID)
/proc/partitions is a good alternative though - gives quite a bit of info

SpaceFM, the fork of PCManFM 0.5.X (not the one used by LXDE), has an implementation if you need some code to borrow - I posted a pet, but it is a bit outdated - the homepage has moved to:
http://ignorantguru.github.com/spacefm/
SpaceFM 0.7.5 does not require udisks (only udev). However, in order to mount or unmount devices as a non-root user, you will need pmount or udisks installed, or will need to specify a custom program to be used. A custom mount solution is currently under development. Also, enabling kernel polling ...
... this one is actually pretty nice

Another one that has support for mount/unmount-ing removable drives is rodent file manager (a fork of xffm)
http://xffm.org/
it monitors /proc/partitions, but it must be enabled at compile time with --enable-fstab-plugin ... that may actually make it easier to find the code (by grepping for ifdefs)
I like a lot of the ideas of this project, but the implementation of the ideas didn't seem to be polished yet.
Any udisks implemntation doesn't help me since udisks doesn't even work from the command line. Can't figure out why.

akash_rawal
Posts: 229
Joined: Wed 25 Aug 2010, 15:38
Location: ISM Dhanbad, Jharkhand, India

#30 Post by akash_rawal »

At last! My volume monitor GIO module is almost complete. See first post.

I have tested GTK file chooser and pcmanfm2. pcmanfm2 works fine. GTK shows some assertion failures after unmounting a drive, but it still works.

For the GIO module to work, as jemimah had already figured out, you need to set PUP_VOLUME_MONITOR_USE environment variable. I set up this mechanism to protect 'innocent' programs from crashing.

Image

User avatar
jemimah
Posts: 4307
Joined: Wed 26 Aug 2009, 19:56
Location: Tampa, FL
Contact:

#31 Post by jemimah »

Dude! You are my new hero. Let me know how I can help you with this project!

User avatar
jemimah
Posts: 4307
Joined: Wed 26 Aug 2009, 19:56
Location: Tampa, FL
Contact:

#32 Post by jemimah »

Mounting is working (maybe some issues with ntfs).
EDIT: nevermind about ntfs - it seems fine now.

But unmounting is segfaulting

Code: Select all

Program received signal SIGSEGV, Segmentation fault.
0x0809e8f3 in ?? ()
(gdb) bt
#0  0x0809e8f3 in ?? ()
#1  0xb78ecac5 in g_simple_async_result_complete () from /usr/lib/libgio-2.0.so.0
#2  0xb7144524 in pup_volume_monitor_generic_cb (conv=0x8220b80, rcvd_data=0x8183f10, is_new=0, user_data=0x0, conv_user_data=0xb5e07598)
    at volume_monitor.c:324
#3  0xb713e3f9 in ps_conv_mgr_sorter_cb (sock=0x812f120, data=0xbffff514, user_data=0x81364c0) at conv.c:156
#4  0xb713be02 in pup_sock_common_marshaller (hook=0x0, marshal_data=0xbffff458) at core.c:250
#5  0xb774d91e in g_hook_list_marshal_check () from /usr/lib/libglib-2.0.so.0
#6  0xb713c22b in pup_sock_raise (sock=0x812f120, event=1, has_data=1, cb_data=0xbffff514) at core.c:240
#7  0xb713cff9 in pup_sock_try_receive_block (sock=0x812f120, timer=0x8183f90, data_read=0xbffff558, error=0xbffff5a8) at transfer.c:262
#8  0xb713d172 in pup_sock_receive (sock=0x812f120, timeout=0, num_blocks=4294967295, error=0xbffff5a8) at transfer.c:296
#9  0xb713d33f in pup_sock_input_callback (sock=0x812f120) at transfer.c:324
#10 0xb713c0e9 in pup_sock_event_source_dispatch (source=0x81467e8, callback=0, data=0x0) at core.c:376
#11 0xb775d2cd in g_main_dispatch () from /usr/lib/libglib-2.0.so.0
#12 0xb775def4 in g_main_context_dispatch () from /usr/lib/libglib-2.0.so.0
#13 0xb775e0dc in g_main_context_iterate () from /usr/lib/libglib-2.0.so.0
#14 0xb775e54d in g_main_loop_run () from /usr/lib/libglib-2.0.so.0

akash_rawal
Posts: 229
Joined: Wed 25 Aug 2010, 15:38
Location: ISM Dhanbad, Jharkhand, India

#33 Post by akash_rawal »

jemimah wrote: Mounting is working (maybe some issues with ntfs).
EDIT: nevermind about ntfs - it seems fine now.
If you are getting errors like "Error code 4 (Some other error)", then it is a known problem.

This occurs when drive is mounted, but /proc/mounts is not updated in time.

Do you know how to wait for kernel to update /proc/mounts? inotify doesn't seem to work.
jemimah wrote:

Code: Select all

(gdb) bt 
#0  0x0809e8f3 in ?? () 
It looks like problem of invalid function pointer.

I hope you are testing on Thunar?

I will now download thunar-volman to test it myself now. Thanks for info.

akash_rawal
Posts: 229
Joined: Wed 25 Aug 2010, 15:38
Location: ISM Dhanbad, Jharkhand, India

#34 Post by akash_rawal »

Well I'm unable to get Thunar running on GIO.

After installing thunar-volman from Ubuntu Lucid repository, and now I get this.
Image

How do you get Thunar use GIO instead of hal?

User avatar
jemimah
Posts: 4307
Joined: Wed 26 Aug 2009, 19:56
Location: Tampa, FL
Contact:

#35 Post by jemimah »

Thunar-volman is not needed.

Thunar itself can handle mounting/unmounting. You might need a pretty new version of thunar.
Attachments
screenshot.jpg
(43.57 KiB) Downloaded 798 times

Post Reply