rdesktop USB-redirection save removal

0

We have several HP Thin-Clients of type t5545 in use. We redirect USB-Media to the terminalserver. Because the t5545 runs a debian customized by hp, we can treat it like a debian in some way.

First, I'll explain how usb-redirection is configured:

  • automatically mount it to /tmp/tmpfs/media
  • /tmp/tmpfs/media is redirected as disk "Z" via rdesktop-parameter -r disk:sharename=path
  • in case of removed usb-media udev will run a script to umount -l the device and delete the mountpoint

The environment:

  • Thin-Clients run linux: root@mac-addr:/tmp/tmpfs/media# uname -a
    Linux mac-addr 2.6.26-2-686 1 SMP Wed Nov 4 20:45:37 UTC 2009 i686 GNU/Linux
  • Terminalserver runs Windows Server 2008 R2

Problem: When users write to usb-media, it seams to be written instantly. But in fact the file needs a few seconds to be written even if it has only a few kb. Server 2008 R2 doesn't show any hint about that. If the user removes his usb-media directly after writing to the usb-media, the file won't be at his usb-media.

Question: Is there anything I can do to inform the user about the write-progress? If possible, that shouldn't be a third-party tool that has to be installed on the thinclient because there's very less space.

Edit: No ideas? The solution shouldn't be like the windows-7-known save removal of usb-media. It would be fine if there's even a notification if the write-progress is ongoing or ready.

Update:
No solution yet! There's still the chance to get the 150 reputation points!

I need one of these 2 points:
- a way to inform the user when the write-process is done, or...
- a script/little application with no dependencies (because the flash-disk is almost full) that allows save removal of usb-media

Edit:
I would really like to give that bounty away. Hurry up ;)

wullxz

Posted 2011-05-16T09:27:24.940

Reputation: 2 400

Wait, Rdesktop to 2008 R2? I have never made this to work! It always disconnects instantly... – sinni800 – 2011-05-16T11:23:55.920

Yes it works... mostly... According to dpkg -l | grep rdesktop there's rdesktop 1.6.0-1.36 customized by hp installed. They had to apply a patch to resolve some usb-redirection errors like not beeing able to delete non-empty-directories and an additional udev-rule to unmount usb-media automatically when it's unplugged. But apart from that, it works. – wullxz – 2011-05-16T12:37:09.513

Huh, last time I tried it it didn't work, I have to try again... – sinni800 – 2011-05-16T13:49:07.997

Answers

1

Mount your local stuff (/tmp/tmpfs/* in your case) with sync option.

Bgs

Posted 2011-05-16T09:27:24.940

Reputation: 268

meanwhile, we don't supervise the client anymore. Nevertheless, this hint would mostly prevent data from getting lost and I accept this answer for this reason.
However, I'm not able to test this solution - I only read the manpage of mount to learn what the sync option does.
– wullxz – 2012-07-23T21:49:52.740

1

The problem is not with RDESKTOP nor with Windows. It's from the way how Linux (and other OS) works with Removable Media. They are supposed to be removed safely and then be unplugged in order to make sure freshly written data has been synced.

What you can do is to inform your system to make those "syncs" more often.

you can write a C daemon which would do it for you. Or you can dig into the kernel module settings and specify not to use write-cache.

bakytn

Posted 2011-05-16T09:27:24.940

Reputation: 1 537

I could've written a C daemon but I'm not a good programmer and even less a linux programmer. I understand your idea and thought of it, too, but it's not possible for me to implement it. However, you gave me no solution but good hints - I vote you up anyway. – wullxz – 2012-07-23T21:54:21.190

0

This is a tricky one. If I got this right, you want a user to wait a few seconds before removing their USB drive, which appears as a folder inside their remote desktop session. My only idea to solve this would to be use this utility which will see the folder(mount point) has gotten new data and then can trigger a script to launch a dialog box (I'd use autohotkey) that would alert the user, "You have recently inserted a USB device, please wait 20 seconds after the last time you save data to your USB before removing it. Otherwise, your data may not save properly." Have it monitor Z:\ to see if a folder is created.

Or, have you tried freerdp? It might not contain the delay which you mention.

yeedl

Posted 2011-05-16T09:27:24.940

Reputation: 1 056

the problem is, that my client is a thin-client. There's not much space left on the flash-disk. I would like to have a solution that allows save removal of usb-media or that notfies me exactly after all write-tasks are ended. I don't know what files will be written to usb-media and how large they will be. That means: it could be, that 20 seconds aren't enough to wait... I want to be save with that. – wullxz – 2011-05-25T16:16:52.073

but if people are in an RDP session and something pops up on their machine outside their RDP, will they see it? take a look at this utility: http://iwatch.sourceforge.net/index.html

– yeedl – 2011-05-31T00:01:47.683

okay... I have to look at this. Sadly I have many tasks today and can't test it within the next 24 hours. Can you tell me how much disk space this package needs? Are there any dependancies? If nothing works, I'll have to write a little script for the server and the thin-client to allow the user to unmount the usb-stick (that shouldn't be too difficult). – wullxz – 2011-05-31T09:39:28.967

sadly iwatch has too much dependencies that aren't installed yet on the thinclient. That wouldn't fit on the flash-disk. Do you have other ideas? – wullxz – 2011-06-01T10:03:04.637

0

You can use fuser to see which pid is using a mount point.

/media/sdc1 is working? fuser -vm /media/sdc1 will show user, pid, access and command. You will need some script to do the trick. Check if F access (open file for writing) is up.

E.g. Checking if someone is using sr0:

$ fuser -m /dev/sr0 -v

USER PID ACCESS COMMAND /dev/sr0:
dvd 17298 F.... xfburn

dvd

Posted 2011-05-16T09:27:24.940

Reputation: 212