executing vfs_write on remote machine, which other calls should be hooked?
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
executing vfs_write on remote machine, which other calls should be hooked?
hi,
Im working on a project, where i'm having two same copies of same files on two remote machines.
i'm tracking the changes in files from vfs_write in read_write.c
i hooked vfs_write and took its all parameters like buf, count, position...
opened _related file structure_ on remote machine and called vfs_write ON REMOTE MACHINE WITH THESE TRANSFERED PARAMETES...
so now, if i APPEND something to one file on machine A, same append is done on machine B!!
e.g.
if on machine A,
a.txt is "abcd"
then
if i do #echo "e" >> a.txt
vfs_write calls are called on both machies (for their file structure of a.txt ) with same parameters (position buffer etc)
its working fine for append..
NOW, i want to keep file on machine B exactly as on machine A at any point of time.. by carrying out all required calls.. WHICH ALL CALLS SHOULD I HOOK?????
PLEASE HELP!!
details of problem faced:
a.txt is "abcdefg"
i call #echo "XYZ" > a.txt NOTE: NO APPENT.. truncate is done..
RESULT :
machine A : a.txt = "XYZ"
machine B : a.txt = "XYZdefg"
please tell me which all other call i should hook and execute remotely ASAP.. thanks
I've only done a little bit of VFS stuff, using fuse, so maybe I'm way off base. But no one else has jumped in yet, so...
Isn't there actually a whole series of file_operations and/or inode_operations performed to create a new file? And don't you have to implement the functionality of all of those operations on both peers to faithfully track all changes? As I understand it, you would have to implement pretty well all of the functions in
Code:
struct file_operations {
int (*lseek) (struct inode *, struct file *, off_t, int);
int (*read) (struct inode *, struct file *, char *, int);
int (*write) (struct inode *, struct file *, const char *, int);
int (*readdir) (struct inode *, struct file *, void *, filldir_t);
int (*select) (struct inode *, struct file *, int, select_table *);
int (*ioctl) (struct inode *, struct file *, unsigned int, unsigned long);
int (*mmap) (struct inode *, struct file *, struct vm_area_struct *);
int (*open) (struct inode *, struct file *);
void (*release) (struct inode *, struct file *);
int (*fsync) (struct inode *, struct file *);
int (*fasync) (struct inode *, struct file *, int);
int (*check_media_change) (kdev_t dev);
int (*revalidate) (kdev_t dev);
};
... and ...
struct inode_operations {
struct file_operations * default_file_ops;
int (*create) (struct inode *,const char *,int,int,struct inode **);
int (*lookup) (struct inode *,const char *,int,struct inode **);
int (*link) (struct inode *,struct inode *,const char *,int);
int (*unlink) (struct inode *,const char *,int);
int (*symlink) (struct inode *,const char *,int,const char *);
int (*mkdir) (struct inode *,const char *,int,int);
int (*rmdir) (struct inode *,const char *,int);
int (*mknod) (struct inode *,const char *,int,int,int);
int (*rename) (struct inode *,const char *,int,struct inode *,const char *,int);
int (*readlink) (struct inode *,char *,int);
int (*follow_link) (struct inode *,struct inode *,int,int,struct inode **);
int (*readpage) (struct inode *, struct page *);
int (*writepage) (struct inode *, struct page *);
int (*bmap) (struct inode *,int);
void (*truncate) (struct inode *);
int (*permission) (struct inode *, int);
int (*smap) (struct inode *,int);
};
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.