LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-04-2007, 01:49 AM   #1
saumitra
LQ Newbie
 
Registered: Mar 2007
Posts: 9

Rep: Reputation: 0
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
 
Old 04-05-2007, 04:36 PM   #2
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
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);
   };
--- rod.
 
Old 04-07-2007, 08:43 AM   #3
saumitra
LQ Newbie
 
Registered: Mar 2007
Posts: 9

Original Poster
Rep: Reputation: 0
yes i'm planning the same now..

just have to look where all these are IMPLEMENTED... (defined!)

any idea where are they??

i think they are specifically implemented in kernel/fs/<file system>/....

they are related to a file system.

so consider.. file->f_ops->write calls VFS_WRITE in any case..

so are there some functions for all file->f_ops->....

i can hook those to get in generic file system tracking??
 
Old 04-07-2007, 01:26 PM   #4
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
How did you implement the write function? The rest should be done the same way. Are you using fuse?

--- rod.
 
Old 04-07-2007, 11:44 PM   #5
saumitra
LQ Newbie
 
Registered: Mar 2007
Posts: 9

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by theNbomr
How did you implement the write function? The rest should be done the same way. Are you using fuse?

--- rod.

i implemented vfs_write function.

it has 4 parameters. ## MACHINE A##
1> file struct
2> buf
3> count (buf)
4> file pos (to be written at)


so i took
1>__ FILE NAME __ (not struct)
2> buf
3> count (buf)
4> file pos (to be written at)


so on ## MACHINE B ##

opened respective file structure with __FILE NAME __ i had...

so on machine B i have again,,.
1> file struct
2> buf
3> count (buf)
4> file pos (to be written at)

((btw initially files on both machines are same... exactly identicall in all aspects))
 
  


Reply

Tags
filesystems



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
I have a problem with this RPC (Remote Procedure Calls) gorett Programming 1 01-22-2007 10:58 PM
Executing graphical programs on a remote machine dreamtheater Linux - Networking 9 10-13-2006 09:52 AM
Which virtual machine can be used to emulate RH 7.3 on PIV to log system calls nedianz Linux - Security 1 03-14-2005 08:07 AM
which virtaul machine to use to log system calls by privileged proccesses nedianz Linux - Newbie 1 03-14-2005 06:10 AM
Which virtual machine can be used to emulate RH 7.3 on PIV to log system calls nedianz Linux - Software 0 03-14-2005 05:36 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:25 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
Open Source Consulting | Domain Registration