Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Format specifier for printk loff_t types?

I am working on a Linux character device driver for a school assignment and am not sure how to print the *ppos passed into my read function which is of type loff_t.

I know I must use printk rather than the standard library printf from within the kernel but I can't seem to figure out the proper format specifier.

like image 333
Anthony Jack Avatar asked Nov 18 '12 05:11

Anthony Jack


1 Answers

loff_t is just a typedef. To determine which format specifier to use, you should look for its definition:

  • typedef __kernel_loff_t loff_t
  • typedef long long __kernel_loff_t

Then you can refer to the Kernel's documentation to see how to format a "long long" (%lld).

like image 199
Christophe Vu-Brugier Avatar answered Sep 18 '22 12:09

Christophe Vu-Brugier