LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices



Poll: filesystem managment the right way?
Poll Options
filesystem managment the right way?

You must log in and have one post to vote in this poll. If you don't have an account, you can register here.
Results will be available after the polls close.

The nominees are:

manual (mount as root or from fstab)
automatic (users can't/won't/don't know mount)
not important at all

Reply
 
Search this Thread
Old 03-13-2007, 03:22 PM   #31
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,776

Rep: Reputation: 481Reputation: 481Reputation: 481Reputation: 481Reputation: 481

What I have running right now should work for either kernel series without stepping on any toes.


Here's the relevant code which does things for the users:

Code:
#!/bin/bash

RESTART_USER_ID=`id -u`
PRG_CMD="usbwatch"
ALL_PRG_PIDS=`ps -C usbwatch|grep usbwatch|gawk '{print $1}'`
for EACH_PID in $ALL_PRG_PIDS; do
	ENVIRON_VALUES=`cat /proc/$EACH_PID/environ | tr "\000" "\n"`
	
	export $ENVIRON_VALUES
	APP_USER_ID=`id -u $USER`
	cd $PWD
	for EACH_VALUE in $ENVIRON_VALUES; do
	 TEST_PRG_NAME=`echo $EACH_VALUE | grep ^\_= | cut -d= -f2-`
	 if [ ! "$TEST_PRG_NAME" = "" ]; then
	   PRG_CMD=$TEST_PRG_NAME 
	 fi
	done
	kill -9 $EACH_PID
	# If this script is run by hotplug
	if [ $RESTART_USER_ID -eq $APP_USER_ID ]; then
	   #[[ "$ACTION" = "add" ]] && cp /etc/X11/usbwatch/usbmedia.lnk.hide /etc/X11/usbwatch/usbmedia.lnk
	   #[[ "$ACTION" = "remove" ]] && rm -f /etc/X11/usbwatch/usbmedia.lnk
	   #cp /etc/X11/usbwatch/usbmedia.lnk.hide /etc/X11/usbwatch/usbmedia.lnk
	   $PRG_CMD &
	else
	   if [ $RESTART_USER_ID -eq 0 ]; then
	      #[[ "$ACTION" = "add" ]] && cp /etc/X11/usbwatch/usbmedia.lnk.hide /etc/X11/usbwatch/.usbwatch/usbmedia.lnk
	      #[[ "$ACTION" = "remove" ]] && rm -f /etc/X11/usbwatch/usbmedia.lnk
	      #cp /etc/X11/usbwatch/usbmedia.lnk.hide /etc/X11/usbwatch/usbmedia.lnk
	      su $USER -c $PRG_CMD &
	   fi
	fi
done
exit 0
This code retstarts the program usbwatch as the user, for each user that is running the program.
To do something for a particular user, you'd need to do as SCerovec suggested and start some unique process as user or set some flag which hotplug can identify and then work with.

Last edited by gnashley; 03-13-2007 at 03:24 PM.
 
Old 03-20-2007, 03:01 PM   #32
SCerovec
Member
 
Registered: Oct 2006
Location: Cp6uja
Distribution: Slackware x86 and ARM and Porteus
Posts: 655

Original Poster
Rep: Reputation: 45
Smile nice but ...?

gnashley
the code looks nice and solid,
What does it do? Could you post comment about it's operation?

BTW,
do you know that in slackware 11.0 and on, one has either 2.4 kernel and hotplug running or a 2.6 kernel and udev running? How does that influence the operation of your script?
 
Old 03-20-2007, 05:16 PM   #33
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,776

Rep: Reputation: 481Reputation: 481Reputation: 481Reputation: 481Reputation: 481
I haven't gotten to the 2.6 part yet, but it seems to be a one-line thing anyway. I've been wrestling with other basic issues and have paid the price with a *lot* of system freezes on the way.
I had gotten things working okay where anytime you plugged in a USB device anyone who was running the program 'usbwatch' would get updated icons on their desktop showing the mounted partitions on the device.
Using the hotplug hook will let you do anything since it is a root process, but the hotplug hook is only activated when the device is plugged in or removed.
It's much tricker to get a certain device assigned to a certain user and to let the user safely mount/unmount the device.
The code I posted above was just the part which updates the icon-display. usbwatch is a slighly modified version of xtdesktop. To update the display I just quickly stop and restart it, after changing the display icon links to indicate status. This code gets called by the do-hotmnt which does the mounting. The hook in /etc/hotplug.d/usb calls do-hotmnt which mounts and then calls the above code to update the icons.

I've had to start over several times since then, but there's still some of the same code on there. Note that none of this refers to your hotmnt code at all. I had to simplify things in order (start) to work out the really hard stuff.

The interesting stuff from the above code is the /proc/pid/environ and su lines.
Sorry to make you wait still longer for a better look.
 
Old 03-21-2007, 02:37 PM   #34
SCerovec
Member
 
Registered: Oct 2006
Location: Cp6uja
Distribution: Slackware x86 and ARM and Porteus
Posts: 655

Original Poster
Rep: Reputation: 45
ok,
just go ahead with the good stuff. I see You finally got the grip about the issues of hot-plug events and mounts.
Few questions,
1. Is it hard to >># comment<< the code iniline? (If I could understand, I could may be, see things...)
2. Do graphics have anything to do with the mount-process ? (what window manager are you running?) -should they have?
3. I could see your code as a 'legacy' companion to my project, do you have any objections?
4. I would see a nice config file in, say /etc/, with easy to follow syntax :-) ...
5. Did you try the hotmnt script on a 2.4 kernel? It worked well for me (I had to be root).

I wish You success anyway, glad You got your hands in the 'mess' ;-)
 
Old 03-21-2007, 02:41 PM   #35
SCerovec
Member
 
Registered: Oct 2006
Location: Cp6uja
Distribution: Slackware x86 and ARM and Porteus
Posts: 655

Original Poster
Rep: Reputation: 45
BTW,
what happens when you got, say 4 users on a system, and one of them (guess who?) plugs in a flash-key. For whom will the 'bell toll' - who will be the owner of the files on that FS?
and
You mean that all users get the icons updated, right? who gets the mount permissions on a multi user system (a dual monitor working station)?
 
Old 03-22-2007, 05:18 AM   #36
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,776

Rep: Reputation: 481Reputation: 481Reputation: 481Reputation: 481Reputation: 481
Getting it to assign a device to a particular user is what I've been working on and seem to have gotten working yesterday.
When you run usbwatch, the initial icon includes a menu entry for 'capturing' a device. If the user chooses this option and then plugs in the device it will be assigned to only that user. Otherwise, plugging in a device will cause it to be visible to all users who are running the usbwatch program.

I'm using a special usbwatch group which allows users in the group to be able to safely unmount and remount partitions on the device assigned to them. This has to be so since we mount read-write and the user needs a way to sanely disconnect the device, which can only be done by unmounting or ejecting the device.

Disconnecting the device causes a a REMOVER to run which cleans up all the temp-files, links and directory entries which were created for the device.
This is not legacy code and should work fine with either 2.4 or 2.6 kernels. It does not depend on udev and should work with any version of hotplug. It does not create or need entries in the fstab for devices.

The program usbwatch is just xtdesktop slightly hacked. It uses only xlibs. It display icons on your desktop according to config files. I am using that abilty at the moment to display and update the cions on the desktop. But I have ideas of using other programs as well for this -bbdock may be the most promising. I've tried idesk but it refreshes the whole screen which is annoying and unnecessary.
The notification features are mostly separate in the code from the mounting features in order to make it easier to change later.
 
Old 04-01-2007, 04:17 AM   #37
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,776

Rep: Reputation: 481Reputation: 481Reputation: 481Reputation: 481Reputation: 481
Alright friends, I've finally beaten this thing into a usable condition -for kernel-2.4 at least. If you are able to run kernel-2.4 give it a try and study the code.
Getting it to work with kernel-2.6 may just be a matter of reactivating hotplug (since the default boot-up turns it off). There's some pretty interesting (and critical)lines in the code. SCerovec, take note of the way /usr/bin/Xusb-hotmount starts the usbwatch icon display. Instead of polling for changes and updating, the program is started with a trap for INT signals (-2). This makes it possible for the icon-menu actions to update the display when devices are mounted or unmounted. Each device gets it's own handler(for the menu entries) and remover for clean-up when the device is removed.
See the thread where I announced the program here:
http://www.linuxquestions.org/questi...d.php?t=542304

Get the package and/or sources here:
http://distro.ibiblio.org/pub/linux/...Xusb-hotmount/
 
Old 04-10-2007, 02:08 PM   #38
SCerovec
Member
 
Registered: Oct 2006
Location: Cp6uja
Distribution: Slackware x86 and ARM and Porteus
Posts: 655

Original Poster
Rep: Reputation: 45
As I got to code the 0.5.0 of hotmnt on Slack-current I realized that udev (v10x?) ain't calling me from /etc/udev/rules.d any more ??? Any clues?
 
Old 04-13-2007, 01:01 PM   #39
SCerovec
Member
 
Registered: Oct 2006
Location: Cp6uja
Distribution: Slackware x86 and ARM and Porteus
Posts: 655

Original Poster
Rep: Reputation: 45
Cool New release of hotmnt 0.5.0

The answer was as allways few hacks away;-) :
When I turned on "info" for udev's loglevel and plugged me flash-stick few times in and out in /var/log/messages was obvious:
He manager didn't know how to handle udev's input.
As I cleansed the manager's script, I overlooked few details...
Now its all in place and works very good.
As the mather of fact, I already gave the package to a friend of mine before I even released the poor thing on sourceforge.
So we are standing in front of another case of pre-release code leaking :-) to the public...

For the impatient and the curious:
http://sourceforge.net/project/showf...roup_id=174404

this is Slackware's native package. Just call installpkg upon it. For those rare among you out there that already installed the 0.4.x earlier it's upgradeable with upgradepkg too ;-)

enjoy...
 
Old 04-23-2007, 08:28 AM   #40
rkelsen
Senior Member
 
Registered: Sep 2004
Distribution: slackware
Posts: 1,808

Rep: Reputation: 234Reputation: 234Reputation: 234
Re: New release of hotmnt 0.5.0

Hi Steven,

In another thread earlier today, I was pointed to this thread by Gnashley. So, I have downloaded your hotmnt package and had a quick look, and have a couple of (minor) suggestions.

I notice that under /etc/rc.d, you have created a file called rc.local.new. This may be OK for installation, but makes clean removal of the package difficult. There is a mechanism in Slackware, which allows you to add stuff to the boot up process without actually editing any of the standard scripts. If you have recently installed Slackware-current, you'll see that under /etc/rc.d, there is now an init.d directory and a heap of rcX.d directories. If you place your rc.hotmnt script under the init.d directory and create symlinks to that script under the rcX.d directories, it'll run upon entering that runlevel (provided that /etc/rc.d/rc.sysvinit is executable). For example, if you wanted rc.hotmnt to run when booting into runlevel 3, you would create a symlink as follows: /etc/rc.d/rc3.d/S99hotmnt -> /etc/rc.d/init.d/rc.hotmnt. This will make the script run without the need to edit any of the standard scripts and facilitates clean removal of the package.

The other query I had was to do with your editing of /etc/fstab. This is something I'm not 100% comfortable with. Up until recently, HAL did exactly the same thing, and this was enough to put me off it. Newer versions of HAL no longer do this, but that doesn't make it any less complicated.

I did some experimenting with various scripts myself about a year ago. It sort of petered out, because I didn't have the time to mess with it and I had forgotten about it. I found that the Debian usbmount scripts worked the best for me. It was trivial to get them working with Slackware, but it would take forever to mount a CF card in my universal card reader and I couldn't figure out why. I also looked at another set of scripts called "usb-mount" (URL: http://users.actrix.co.nz/michael/usbmount.html) which looked promising, but I couldn't get them working properly. This package may be worth your looking at. It adds an icon to the user's desktop without needing to touch /etc/fstab.

Thanks for all your efforts!


Rob

Last edited by rkelsen; 04-23-2007 at 08:30 AM.
 
Old 04-24-2007, 11:08 AM   #41
SCerovec
Member
 
Registered: Oct 2006
Location: Cp6uja
Distribution: Slackware x86 and ARM and Porteus
Posts: 655

Original Poster
Rep: Reputation: 45
Thumbs up That's fine

Hi rkelsen.
Thank you for your time.

Regaring /etc/init.d it's due for the next release :-)
This one still belongs to 10.2. Your suggestion is in place. I just couldn't find a better way at the moment. Any volunteers?

Regarding 'messing' with /etc/fstab, is there any other place where mount-information can be placed? I didn't feel confortable with over-complicated scripts too, so I did write this one. The aim is to be rock-solid and bullet-proof. There IMHO simply is no other way. Except for mounting without a mountpoint and fstab-entry but this is a horrorable way to go too.
I just want a mountpoint and a line in fstab for every USB-volume I plug in... so do the newbies out there too.

Regarding the other projects, I'm out to read them ASAP...

Best regards
 
Old 04-24-2007, 03:17 PM   #42
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,776

Rep: Reputation: 481Reputation: 481Reputation: 481Reputation: 481Reputation: 481
Yeah thanks, rkelson. I downloaded usbmount and submount to look at them.
Personally, I've tried to find a specific solution for USB devices as I think floppies and cdroms are better handled by supermount or autofs since these drives are usually installed as fixed hardware and are single-file-system devices. My program tries especially to handle multi-partition devices on a fully anonymous basis, meaning that, by default no mount points are left after unmounting and no entries are made to the fstab. Both these points have been better addressed in SCerovec's code.
(Steve, I'm still hoping we might pull our code together sometime -that's why I haven't put more codelines for option-parsing) I am using hotplug, but SCerovec's code uses udev. They are both pretty equally effective. The DEVICE variable is the best key to use for creating fstab entries as it's the only way to uniquely identify a particular device. My code will, later, allow for looking at the fstab to see if there's a unique idebtifier and use the supplied mount options. I think Steve has been looking at using file_system LABEL tags, but these are not unique. Using the UUID of the device is better, but some devcies don't have them.
I do have a solution for creating desktop icons and updating them, including a method so that a particular user can request that the device be 'assigned' to that user and the icons placed on the right DISPLAY. It's all Xlibs so it works with any desktop environment.
The mounting code is pretty separated from the icon-notification stuff and devcies get mounted even if no one is running the device requester. Using the same mounting code, I also worked out another desktop notification method using a diskmounter DockApp. I modified the code slightly so that instead of reading /etc/fstab it reads the conf file(with syntax just like fstab). This method is a little easier to use, maybe a little stricter and doesn't show individual icons for each device. Instead you click to scroll throught the partitions. And it has its' own GUI config program. Drawback is dependence on libProplist from WindowMaker.
I do include some basic conf file parsing in the Xlibs version. The whole device gets an icon and each partition gets its' own icon with a righ-click menu. Double clicking the icon opens the mount-point with the filer you choose in your conf file. Parttition can be mounted or left unmounted by default(Journalled file systems are slow to mount). Using the righ-click menu, parititons acan be mounted or unmounted individually and the icons get updated to show mount status. The main-device icon has menu entries for unmounting or mounting all partitions on the device or disconnecting, etc. Interesting things to learn and work out here...
 
Old 04-24-2007, 09:00 PM   #43
rkelsen
Senior Member
 
Registered: Sep 2004
Distribution: slackware
Posts: 1,808

Rep: Reputation: 234Reputation: 234Reputation: 234
Quote:
Originally Posted by SCerovec
Except for mounting without a mountpoint and fstab-entry but this is a horrorable way to go too.
I just want a mountpoint and a line in fstab for every USB-volume I plug in... so do the newbies out there too.
Obviously, you need a mountpoint to mount a filesystem upon, but why does it require an fstab entry? I still don't understand why you would need it.

Since I noticed that you guys have been talking about this stuff the other day, I've been thinking about it non-stop (I'm blaming you two - SCerovec and Gnashley ). I had to go back to re-examine my slightly modified version of Debian's usbmount package. Also, I found that Vector Linux uses a muchly modified version of Michael Hamilton's usbmount, so I downladed it for a looksee. It's called "VL-hot". The big drawback with it is that it requires the sg3utils package as well as a program called 'disktype'. Debian's usbmount package can be made to work on standard Slackware (well, version 11 onwards anyhow) without the need to add anything. On my 10.2 rig, I had to install a set of utilities which are now part of Pat's udev package.

So, I was up until 1:15 am last night mucking around with it, and I now have a handful of scripts which are a hodge-podge of Debian's usbmount and VL-hot, with some minor changes to make it all work together.
Quote:
Originally Posted by gnashley
Personally, I've tried to find a specific solution for USB devices as I think floppies and cdroms are better handled by supermount or autofs since these drives are usually installed as fixed hardware and are single-file-system devices.
I agree Gnashley, it's the USB stuff I'm interested in as well. Personally, I use mtools for handling floppies and I am of the opinion that optical drives are handled pretty well by KDE, which is my desktop of choice.

Anyhow, after some frustration (mainly at my own lack of understanding), I now have a setup which works as follows:

Insert a USB key, and an icon appears on the desktop. Remove the same USB key, and the icon disappears. This all happens without touching fstab. I'm still messing with getting it to unmount properly from the right-click context menu. I think I need a separate script for that.

If you guys are interested, I'll upload a Slackware package of my efforts to date.

Edit: I have tested this on 10.2 and -current. It works on both of these. Is the format of udev rules under 11 the same as -current? If so, it should work on 11 as well.

Edit #2: WRT the right-click unmount option - I'm thinking that this isn't necessary. I've set it up to run the "sync" command instead, with the label "Prepare for Removal".

Edit #3: I've uploaded a package to http://members.optusnet.com.au/rkels...2-noarch-1.tgz. Be warned though, at a hefty 9 kilobytes, it might kill your bandwidth!! You may need to edit some settings in a file called /etc/usbmount/usbmount.conf, but it works for me on Slackware-current as it is.

Cheers,

Rob

Last edited by rkelsen; 04-25-2007 at 02:46 AM.
 
Old 04-25-2007, 04:46 AM   #44
SCerovec
Member
 
Registered: Oct 2006
Location: Cp6uja
Distribution: Slackware x86 and ARM and Porteus
Posts: 655

Original Poster
Rep: Reputation: 45
Smile honorable fellow-hackers

First I apologize for the loss of sleep to rkelsen, that's a horrible thing to happen to a hacker. I know where You stud there pal ;-)
Thanks to both of You for considering my code and for the links. Unfortunately I couldn't find the time for my homework regarding the mentioned packages. They are still on the queue...

Regarding anonymous mounting:
Code:
# this set will mount(!) anything that arrives with VFAT: strait to /mnt/hd
_HM_PRTPTN[5]="sd[a-z][1-9]"

    _HM_IGNORE[5]="false"
    _HM_FSTYPE[5]="vfat"
    _HM_OPTS[5]="umask=0,rw,users,noatime,sync"<-- add sync
    _HM_FSTAB[5]="ignore"<-- don't update fstab
    _HM_MNTPNT[5]="/mnt/hd"<-- stack here all that arrives
    _HM_FSCK[5]="ignore"
    _HM_MOUNT[5]="true"<-- do mount it
The question is, how would a newbie know to umount that from a GUI? It's supposed just to work. And OTOH the sync is quite depressing for its lack of speed for VFAT fs.

Regarding gnashley's proposition: Pall we have a merger of enterprises in our future (I wery like Your way of using Xlib). In fact I'm still need a X-interface and a GUI-configurator to pass up to 0.9 at all. The hotplug is, however, troubling me: what is his future? Time will show... And the icons exported to X for mounting must be themeable. Everything else is *roger* to me.
@gnashley
If we would merge, should we give it a new name?
@rkelsen
What's Your pack's name?

Best regards.
 
Old 04-25-2007, 04:50 AM   #45
SCerovec
Member
 
Registered: Oct 2006
Location: Cp6uja
Distribution: Slackware x86 and ARM and Porteus
Posts: 655

Original Poster
Rep: Reputation: 45
Wink Red the news while they are hot

I just submitted hotmnt to linuxpackages the other day. It took me two shots to do it:
I had bad permissions on some dirs on the first package...
The corrected package is on sourceforge.net too.
http://downloads.sourceforge.net/hot...se_mirror=osdn
For your pleasure.
 
  


Reply

Tags
administration, automation, filesystems


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
scan hot plug drives support !! vinay_r99 Linux - Hardware 5 07-08-2008 01:10 AM
USB device hot plug failed sometime raytzer_liao Linux - Hardware 1 06-08-2006 01:31 PM
Beta testing Beta 8 -- Boot Loader screws up 1kyle Suse/Novell 0 03-27-2006 04:36 AM
How to turn off hot plug?? msulik1 Linux - Laptop and Netbook 1 02-07-2006 02:42 PM
USB Hot Plug Problems... reply2vinay Linux - Hardware 1 07-22-2005 09:44 AM


All times are GMT -5. The time now is 08:57 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration