Re: procfs and file operations

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, 26 Jun 2010, Mulyadi Santosa wrote:

> Hi...
>
> On Sat, Jun 26, 2010 at 03:53, Chris <chris.maier85@xxxxxx> wrote:
> > I read the pages 83-90 in the LDD3 and the sources
> > (http://lxr.linux.no/#linux+v2.6.34/include/linux/proc_fs.h).
> >
> > Now, I am a little confused. The struct proc_dir_entry contains a
> > struct file_operations. Thus I can implement all standard file
> > operations on a proc file entry?
>
> AFAIK, only read and write (if it is meant to be writeable). Note:
> these days you need to use sequential write and read. refer to Rob
> PJ Day's articles on how to do such thing. Rob, please, go ahead on
> this...

  not only read and write -- you can certainly also implement lseek. ,
at the very least. and even though it's getting a bit dated, /proc
files are covered fairly well in LDD3, which is available online at
http://lwn.net/Kernel/LDD3/.  see chapter 4.

  also, you don't *need* to use the seq_file implementation, that's
just a newer way to use proc files that gets around an old length
limitation on how much you could print from a single proc file.  but
there are still lots of examples of the older interface in the kernel
the last time i looked.  read that chapter in LDD3, it explains it
fairly well.  and here's where i become a bit conflicted.

  ironically (and i'm trying very hard not to be self-serving again),
i just happen to be writing the section on proc files for my online
kernel programming course so while i'm happy to still answer basic
questions here, i feel like i have to limit myself to not reproducing
everything i'm going to put in that section, since that would be
unfair to the registered students who've paid for the course.

  argh.  i hate conflicts of interest.  but read LDD3, it's a very
good coverage of proc files.

rday

-- 

========================================================================
Robert P. J. Day                               Waterloo, Ontario, CANADA

        Top-notch, inexpensive online Linux/OSS/kernel courses
                        http://crashcourse.ca

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux