Reply
Thread Tools
Posts: 23 | Thanked: 23 times | Joined on Jul 2012
#1
On the N9, is there a way to get the system (usb-moded ?) to export the partition read-only. I don't want to get my N9 filled with viruses and other crap (or risk accidental file-deletion or the like) when plugging it into foreign Windoze machines ...

In the old days, USB-sticks had a physical read-only switch to accomplish exactly this ...

I suspect usb-moded doesn't support this, but would there be other ways ? Any ideas ?
 

The Following 2 Users Say Thank You to LinuxCub For This Useful Post:
peterleinchen's Avatar
Posts: 4,118 | Thanked: 8,901 times | Joined on Aug 2010 @ Ruhrgebiet, Germany
#2
I do not think this is possible , as it is the other host that is mounting the disk.
And vfat does not support any security options. Maybe if you go reformat to ext, you may get it safe (only give access to specific user). But then Windoze will not mount at all.

So even I would like to have smth like this I wont see it. But would like
to stay corrected!
__________________
SIM-Switcher, automated SIM switching with a Double (Dual) SIM adapter
--
Thank you all for voting me into the Community Council 2014-2016!

Please consider your membership / supporting Maemo e.V. and help to spread this by following/copying this link to your TMO signature:
[MC eV] Maemo Community eV membership application, http://talk.maemo.org/showthread.php?t=94257

editsignature, http://talk.maemo.org/profile.php?do=editsignature
 

The Following User Says Thank You to peterleinchen For This Useful Post:
Posts: 23 | Thanked: 23 times | Joined on Jul 2012
#3
Actually, since posting (isn't that always how it goes), I've been thinking something like this might be involved:

Setting up a loop-device, as read-only, referring to the original partition, and then exporting the loop device.

It is true that the external machine (Windoze, typically) would not understand that the partition is read-only, but I'm more concerned with protecting my data (on the N9), than not confusing the external machine.

But where to put the script that calls losetup ? Somewhere in /etc/init ? I haven't yet had time to experiment with this. Is it even allowed (my N9 is not jailbroken/incepted in any way, and I'm conservative that way) to put ones own scripts in /etc/init ?
 

The Following 2 Users Say Thank You to LinuxCub For This Useful Post:
peterleinchen's Avatar
Posts: 4,118 | Thanked: 8,901 times | Joined on Aug 2010 @ Ruhrgebiet, Germany
#4
I understand your need/wish. And idea about loop device is a nice idea.
In my N900 I fiddled with that and some scripts (cannot remember atm, but a search will show you). And ke-recv process is involved. pali made some improvements to this to automatically detect other file systems than vfat.
--edit
remembered:
/usr/sbin/osso-usb-mass-storage-mode-enable.sh
see attached file for any hints ...
--

But for N9 I am clueless. You may have a hex look into /usr/sbin/usbmoded ...

--
oh and btw
Without open mode / inception you most probably will MALF your device tinkering with soem system files. Beware.
Attached Files
File Type: txt osso-usb-mass-storage-enable.sh.txt (2.6 KB, 94 views)
__________________
SIM-Switcher, automated SIM switching with a Double (Dual) SIM adapter
--
Thank you all for voting me into the Community Council 2014-2016!

Please consider your membership / supporting Maemo e.V. and help to spread this by following/copying this link to your TMO signature:
[MC eV] Maemo Community eV membership application, http://talk.maemo.org/showthread.php?t=94257

editsignature, http://talk.maemo.org/profile.php?do=editsignature

Last edited by peterleinchen; 2013-07-04 at 21:27.
 

The Following 2 Users Say Thank You to peterleinchen For This Useful Post:
Posts: 46 | Thanked: 285 times | Joined on Dec 2005
#5
Originally Posted by LinuxCub View Post
On the N9, is there a way to get the system (usb-moded ?) to export the partition read-only.

I suspect usb-moded doesn't support this, but would there be other ways ? Any ideas ?
usb_moded does support that It uses /etc/modprobe.d/meego.conf for module loading parameters (standard linux module loading behaviour).

So find in there the options line for g_file_storage and add ro=1

After saving it, the next time you use mass-storage it should be read-only.

However I do not know how badly the security system will react to that so you better have open mode or use inception before doing it.
 

The Following 4 Users Say Thank You to Philippe For This Useful Post:
peterleinchen's Avatar
Posts: 4,118 | Thanked: 8,901 times | Joined on Aug 2010 @ Ruhrgebiet, Germany
#6
Originally Posted by Philippe View Post
usb_moded does support that It uses /etc/modprobe.d/meego.conf for module loading parameters (standard linux module loading behaviour).

So find in there the options line for g_file_storage and add ro=1
Hey Philippe,

big Thank You.
That works!

This is really "standard linux behaviour"? (seems I need to lear a lot more coming/staying from/on maemo)

So I tested to add ro=1 just behind g_file_storage,
and I needed to
killall usb_moded
and then after selecting mass storage mode my device was connected in read-only mode. Nice!

So only thing to do (as root):
Code:
sed -i s/g_file_storage/'g_file_storage ro=1'/ /etc/modprobe.d/meego.conf
to get write protection and
Code:
sed -i s/'g_file_storage ro=1'/g_file_storage/ /etc/modprobe.d/meego.conf
to get back write possibilty (at home or save PC).

Disclaimer:
I have tested with open mode (so no problem), but this meego.conf file is not in refhashlist and I have booted with stock kernel and it did not malf. So it will work. But I cannot take responsiblity.
__________________
SIM-Switcher, automated SIM switching with a Double (Dual) SIM adapter
--
Thank you all for voting me into the Community Council 2014-2016!

Please consider your membership / supporting Maemo e.V. and help to spread this by following/copying this link to your TMO signature:
[MC eV] Maemo Community eV membership application, http://talk.maemo.org/showthread.php?t=94257

editsignature, http://talk.maemo.org/profile.php?do=editsignature

Last edited by peterleinchen; 2013-07-05 at 19:29. Reason: added full sed command
 

The Following 2 Users Say Thank You to peterleinchen For This Useful Post:
Posts: 23 | Thanked: 23 times | Joined on Jul 2012
#7
Thank you all for helping ! Much appreciated.
 
coderus's Avatar
Posts: 6,436 | Thanked: 12,699 times | Joined on Nov 2011 @ Ängelholm, Sweden
#8
my choose is creating another 8gb partition and use it as mass storage for usb-moded.
__________________
Telegram | Openrepos | GitHub | Revolut donations
 
Community Council | Posts: 4,920 | Thanked: 12,867 times | Joined on May 2012 @ Southerrn Finland
#9
And my choice, of course is never exporting MyDocs at all

I do all my transfers in/out of device via sftp or rsync, usually over wlan but for smaller files (or not time critical) over 3g.
 
Posts: 46 | Thanked: 285 times | Joined on Dec 2005
#10
Originally Posted by peterleinchen View Post
Hey Philippe,

big Thank You.
That works!

This is really "standard linux behaviour"? (seems I need to lear a lot more coming/staying from/on maemo)
Great!

Well usb_moded uses modprobe internally and the newer versions maintained for mer/nemo switched to kmod (which did not exist at the time when usb_moded was implemented for the N9). But in either case that means that modules are loaded in the standard linux way, which means that module parameters, blacklists etc which are stored in /etc/modprobe.d are used. This way there is no need to recompile or change usb_moded to have it behave differently on the module level.

The source code is here btw : https://gitorious.org/meego-middleware/usb_moded (as Nokia was so kind to release it under LGPL for MeeGo)
 

The Following User Says Thank You to Philippe For This Useful Post:
Reply

Tags
harmattan, mydocs, partition, read-only, usb-moded


 
Forum Jump


All times are GMT. The time now is 19:04.