I'm looking for a solution for being notified about files and directories modifications using inotify or any other API when the files are located on a file-system on a custom board that is configured as a USB device. My Linux is buildroot and deployed on a custom board. I've connected the board to a Host machine running Ubuntu. After creating the file-system on the board I can copy files into the target board with no problems. What I would like to achieve is to get notifications about changes in files and directories on the Linux OS running on the board where the file-system is located. For example, is someone is copying a txt file from the Ubuntu host into the mounted directory I will get a notification on the target board.
What I've been able to do so far is to be notified that a change on the file-system has occurred but could not achieve a specific notification about exactly what has changed. This is how I've accomplished that:
On the target board I've created a file based file-system using:
dd if=/dev/zero of=/tmp/test bs=1M count=500
Then I created a file based file system out of it:
mkdosfs /tmp/test
Then I then started to listen to file-system events (on the target board) with:
inotifywait /tmp/test
Then I copied a foo.txt file onto the mounted directory on the Ubuntu Host side.
I then received a notification (on the target board) that /tmp/test has been modified.
What I want to achieve is to get notification about foo.txt on the board, and once I will be notified about that file I want to have access to it, also on the board. I have no problem if the final solution would be to get notifications about a predefined directory on the mounted file-system if that would be easier.
Is there any way to achieve what I'm asking?
Thanks!
Related
I am looking for a method to transfer files between Raspberry Pi and a computer with Linux OS on.
I need to do so without FileZilla file transfer.
I wonder if there is a script to do it automatically .
I have an array of files and a corrosponding array of IP's of the receiving Servers on a network how can i map the files to the servers and send them in turn .
any bit of advice is very much appreciated.
So you need transfers files from Pi to multiple Linux computers. If you only have a limited number of computers you need to transfer to, then you can do so manually for each computer, using the scp command.
For example let's say the you need to transfer all files with extension .c found in directory /foo in the Pi to the server named barserver in the directory /foobar. From the Pi you can run:
$ scp /foo/*.c username#barserver:/foobar/
Or equivalently from the server you can run:
$ scp username#piaddress/foo/*.c /foobar/
If you have so many servers that doing it manually would be tedious, then you could write a script.
Maybe it's a little overdone, but you may want to check out Fabric: Generally a deployment tool, but I'm using ist to handle all of my file transfers between all my 4 Raspi's, Uploading config files and starting/stopping services.
I just want to show root directory and external mounted drivers (USB, CD) if available on Linux as multiple QTreeViews. As following
/
USB
CD
But, for now I can only show external mounted drivers under root directory.
You will have to build your own QAbstractItemModel (and not use QFileSystemModel) as QFileSystemModel will show you the tree files as they are.
If you are a beginner I strongly advise you to think differently your user interface as making tree model is not an easy task.
Or you can use several QFileSystemModel that would be initialized with different paths with QFileSystemModel::setRootPath :
one the VFS root
one for /media (you can even extract all mount point here /proc/mounts or use the /sys interface)
and so on.
External drives can not be viewed on Linux with QFileSystemModel
from Qt Manual:
QDir::Drives List disk drives (ignored under Unix).
I have an embedded linux device running a USB gadget kernel module to make the mmc available to the host PC(such as Windows or Linux).
When I update the file in mmc, it won't sync with host PC unless I rmmod and insmod again. Is there any better way to update new files? And how can I detect a file is modified by host PC? I'm using C programming on my linux device.
Thanks.
(1) There really isn't a better way to update new files. You need to take turns and only access the mmc from Linux or Windows, one at a time.
(2) You can't easily do that.
When you say "When I update the file in mmc", I assume that you have the mmc mounted in the linux device, and are updating files from linux at the same time that Windows has mounted the device. I don't think this is advisable. The host (Windows) may cache file and/or directory information from the mmc, and if the embedded Linux changes that information unexpectedly, it may produce errors from the Windows FS, and could corrupt the mmc.
If you want to share files between the embedded Linux and host Windows, and be able to modify them from either OS without taking turns, an alternative solution would be to use the network device gadget and run Samba file sharing on the embedded Linux side to export the filesystem where the mmc is mounted on the Linux side.
I am working on Linux 3.14.28, build with buildroot for an embeded system.
How can I read the file /sys/devices/i2c.4/i2c-1/1-0052/eeprom without root privilege?
Is there a solution to permanently change permission instead of changing it on each reboot of Linux with a script.
I'm not using udev but static table. I easily manage to change permission:
using device_table_dev.txt for /dev files
using device_table.txt for /home/files
But it has no effect on /sys/devices/i2c.4/i2c-1/1-0052/eeprom
First and foremost, don't use static table. It really doesn't make any sense to not use devtmpfs these days, unless you're using a kernel older than 2.6.32.
Then, the device table is about changing permission of files in /dev. The permission of files in /sys is directly controlled by the kernel itself.
You need to adapt the permissions of the i2c bus device file /dev/i2c-*, not the eeprom file in /sys.
Using udev following rule should do the job:
KERNEL=="i2c-[0-9]*", GROUP="dialout"
Generally something similar should be also possible with static table as you can handle /dev/i2c-* like every other /dev/* file.
I have a ASUS laptop with Fedora 13. My problem is that any USB storage I connect does not automount. I have other computer with Fedora 13 which does not have the problem.
I have not be able to find any difference in configuration between my laptop and other computers that work.
So to try to trace down the problem I started to looomk for documentation on how it was supposed to work. I have looked at udev, devkit, hal , dbus, polkit, gnome and others.
I want to know which events, logs, config files and monitor programs that I can use to track down the events that takes place from when I attach an USB stick and until i have a window up and running in GNOME.
So far I have traced that udev detects the disk and creates /dev/sdb (and /dev/sdb1 for partition 1) and that event about device added is sent as messages on dbus. I am able to mount the disk manually with udisks but not with gnome-disk-utility (palmiset).
There is many different applications involved to automount a disk, I want to find out where in the chain of events does it fail.
I just found the reason it did not mount. I had a leftover file from earlier udev version. File 60-persistent-storage.rules existed in both /etc/udev/rules.d and in /lib/udev/rules.d . The former overruled the last one. When removing the one in /etc/udev/rules.d the USB drives mounted correctly again.