Re: How to get the inode - no path_lookup

2012-08-13 Thread Rishi Agrawal
On Thu, Aug 9, 2012 at 12:39 PM, Rohan Puri rohan.pur...@gmail.com wrote:



 On Thu, Aug 9, 2012 at 8:45 AM, Rishi Agrawal 
 rishi.b.agra...@gmail.comwrote:



 On Wed, Aug 8, 2012 at 12:46 PM, Rohan Puri rohan.pur...@gmail.comwrote:



 On Tue, Aug 7, 2012 at 8:11 PM, Rishi Agrawal rishi.b.agra...@gmail.com
  wrote:

 Hi All,


 I had a module which used the path_lookup function to print the details
 of any file's inode. I now want to rewrite that module in order to show
 some juniors how to write some code in kernel.

 I am using 3.4.6 kernel, I tried finding out path_lookup but google
 showed that it has been removed.

 I tried the following code then which did not work

 .
 .
 .
 dentry = kern_path_create(AT_FDCWD, filename, path, 1);

 if (IS_ERR(dentry)) {
   printk(Failed to obtain the dentry);
return;
}

 its not returning dentry

 I again tried after seeing the implementation of vfs_stat function

 user_path_at(AT_FDCWD, filename, lookup_flags, path);

 but this also fails.


 I am using a proc interface to pass the filename, and copying the
 filename into a kernel buffer.

 How can I get a copy of vfs inode for a file name.


 Need to use vfs_path_lookup for this, present in fs/namei.c file, which
 would give you filled nameidata nd that contais inodes pointer.

 --
 Regards,
 Rishi Agrawal


 ___
 Kernelnewbies mailing list
 Kernelnewbies@kernelnewbies.org
 http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


 - Rohan


 vfs_path_lookup needs a dentry/mountpoint for the current path.

 How will I get those.


 /**
  * vfs_path_lookup - lookup a file path relative to a dentry-vfsmount pair
  * @dentry:  pointer to dentry of the base directory
  * @mnt: pointer to vfs mount of the base directory
  * @name: pointer to file name
  * @flags: lookup flags
  * @path: pointer to struct path to fill
  */


 --
 Regards,
 Rishi Agrawal

 If you dont have vfsmount's ptr, then you can make use of kern_path api
 with the LOOKUP_FOLLOW as second parameter. This will return the struct
 path ptr which contains vfsmount and the dentry's ptr. Now the dentry's ptr
 will contain the inode that you require.

 - Rohan


Thanks, used that and its working now

-- 
Regards,
Rishi Agrawal
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: How to get the inode - no path_lookup

2012-08-13 Thread Rohan Puri
On Mon, Aug 13, 2012 at 2:17 PM, Rishi Agrawal rishi.b.agra...@gmail.comwrote:



 On Thu, Aug 9, 2012 at 12:39 PM, Rohan Puri rohan.pur...@gmail.comwrote:



 On Thu, Aug 9, 2012 at 8:45 AM, Rishi Agrawal 
 rishi.b.agra...@gmail.comwrote:



 On Wed, Aug 8, 2012 at 12:46 PM, Rohan Puri rohan.pur...@gmail.comwrote:



 On Tue, Aug 7, 2012 at 8:11 PM, Rishi Agrawal 
 rishi.b.agra...@gmail.com wrote:

 Hi All,


 I had a module which used the path_lookup function to print the
 details of any file's inode. I now want to rewrite that module in order to
 show some juniors how to write some code in kernel.

 I am using 3.4.6 kernel, I tried finding out path_lookup but google
 showed that it has been removed.

 I tried the following code then which did not work

 .
 .
 .
 dentry = kern_path_create(AT_FDCWD, filename, path, 1);

 if (IS_ERR(dentry)) {
   printk(Failed to obtain the dentry);
return;
}

 its not returning dentry

 I again tried after seeing the implementation of vfs_stat function

 user_path_at(AT_FDCWD, filename, lookup_flags, path);

 but this also fails.


 I am using a proc interface to pass the filename, and copying the
 filename into a kernel buffer.

 How can I get a copy of vfs inode for a file name.


 Need to use vfs_path_lookup for this, present in fs/namei.c file,
 which would give you filled nameidata nd that contais inodes pointer.

 --
 Regards,
 Rishi Agrawal


 ___
 Kernelnewbies mailing list
 Kernelnewbies@kernelnewbies.org
 http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


 - Rohan


 vfs_path_lookup needs a dentry/mountpoint for the current path.

 How will I get those.


 /**
  * vfs_path_lookup - lookup a file path relative to a dentry-vfsmount
 pair
  * @dentry:  pointer to dentry of the base directory
  * @mnt: pointer to vfs mount of the base directory
  * @name: pointer to file name
  * @flags: lookup flags
  * @path: pointer to struct path to fill
  */


 --
 Regards,
 Rishi Agrawal

 If you dont have vfsmount's ptr, then you can make use of kern_path api
 with the LOOKUP_FOLLOW as second parameter. This will return the struct
 path ptr which contains vfsmount and the dentry's ptr. Now the dentry's ptr
 will contain the inode that you require.

 - Rohan


 Thanks, used that and its working now

 --
 Regards,
 Rishi Agrawal

 Good to know :)

- Rohan
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


[no subject]

2012-08-13 Thread Vivek Panwar
HI,

How KGDB works internally or how a gdb stub works internally with source
code for x86_64 arch. Can some one please suggest me the good docs for the
same.I am very new to this so want know whole detailed internally working
procedure for KGDB.

Thanks
Vivek
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re:

2012-08-13 Thread Fan Yang
2012/8/13 Vivek Panwar vivekpanwar2...@gmail.com

 HI,

 How KGDB works internally or how a gdb stub works internally with source
 code for x86_64 arch. Can some one please suggest me the good docs for the
 same.I am very new to this so want know whole detailed internally working
 procedure for KGDB.

 Thanks
 Vivek

 ___
 Kernelnewbies mailing list
 Kernelnewbies@kernelnewbies.org
 http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

 you can refer to this doc, see as the accessary to build you kgdb
environment.
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re:

2012-08-13 Thread Vivek Panwar
Thanks a lot .

On Mon, Aug 13, 2012 at 4:31 PM, Fan Yang lljyang...@gmail.com wrote:



 2012/8/13 Vivek Panwar vivekpanwar2...@gmail.com

 HI,

 How KGDB works internally or how a gdb stub works internally with source
 code for x86_64 arch. Can some one please suggest me the good docs for the
 same.I am very new to this so want know whole detailed internally working
 procedure for KGDB.

 Thanks
 Vivek

 ___
 Kernelnewbies mailing list
 Kernelnewbies@kernelnewbies.org
 http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies



___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re:

2012-08-13 Thread Anuz Pratap Singh Tomar
On Mon, Aug 13, 2012 at 12:04 PM, Vivek Panwar vivekpanwar2...@gmail.comwrote:

 Thanks a lot .

 On Mon, Aug 13, 2012 at 4:31 PM, Fan Yang lljyang...@gmail.com wrote:



 2012/8/13 Vivek Panwar vivekpanwar2...@gmail.com

  HI,

 How KGDB works internally or how a gdb stub works internally with source
 code for x86_64 arch. Can some one please suggest me the good docs for the
 same.I am very new to this so want know whole detailed internally working
 procedure for KGDB.

 Thanks
 Vivek


Please always use a subject line.


 ___
 Kernelnewbies mailing list
 Kernelnewbies@kernelnewbies.org
 http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies




 ___
 Kernelnewbies mailing list
 Kernelnewbies@kernelnewbies.org
 http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: invoking zcache w/o using a workload

2012-08-13 Thread Asim
Thanks Mulyadi for your response.

zcache has cleancache (a third level page cache) and front swap(swap
cache). I am trying to trigger clean cache and now the swap device.
But my guess is reducing the memory should also cause these evictions
rapidly.

Thanks,
Asim

On Sun, Aug 12, 2012 at 11:56 PM, Mulyadi Santosa
mulyadi.sant...@gmail.com wrote:
 Hi...

 On Mon, Aug 13, 2012 at 3:58 AM, Asim linka...@gmail.com wrote:
 Is there a way I can trigger zcache_get/put (specifically clean cache)
 with a simple unit test (as opposed to running a workload) ? This will
 greatly reduce my test/build time.

 I am a new user of zcache (due to playing with recent Mint release).

 I got impression that by reducing mapped memory you have (using mem=
 kernel parameter) and putting zram/zcache into high priority swap, is
 enough to quickly trigger allocation into zcache. of course, you need
 memory hogger for that, something like tail -f /dev/zero.

 CMIIW if misunderstood you...


 --
 regards,

 Mulyadi Santosa
 Freelance Linux trainer and consultant

 blog: the-hydra.blogspot.com
 training: mulyaditraining.blogspot.com

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: How to understand the macro __init?

2012-08-13 Thread Mulyadi Santosa
Hi.. :)

On Tue, Aug 14, 2012 at 9:14 AM, 王哲 wangzhe5...@gmail.com wrote:
 i use the __init for function print_k.
 in my opinion  after the fisrt invoking the print_k in the hello_init.
 the memory of print_k will be freed,and the second invoking will
 not be executed.but the result of second invoking is executing .

 why?

because you're still in module_init :)

right after modul init stage is done, _init marked function is thrown away...

-- 
regards,

Mulyadi Santosa
Freelance Linux trainer and consultant

blog: the-hydra.blogspot.com
training: mulyaditraining.blogspot.com

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies