Philipp
Philipp

Reputation:

Linux: Support File Operations

Has someone maybe a good source where all available file operations like fopen, fread, mkdir, etc are described? When I am googleing for Linux file operations most pages explain me how the filesystem hierarchy looks like.

Upvotes: 2

Views: 3528

Answers (5)

Josh Kelley
Josh Kelley

Reputation: 58412

The functions you're asking about actually fall under several categories - file stream I/O (fopen, fread, etc.), lower-level file descriptor I/O (open, read, etc.), and filesystem/directory manipulation (chown, mkdir, etc.).

For an overview of file stream I/O functions, see man stdio.

For searching Google, try "posix file api" instead of "linux file operations."

You can also check the GNU C Libary Manual:

Upvotes: 5

dmeister
dmeister

Reputation: 35654

There a several file operations APIs on different levels of the stack, e.g. POSIX API, Standard C API, Linux VFS API (as Jeremy mentioned), and the FUSE API. All the APIs do more or less the same thing, but the details are very different.

These two APIs are the most important for the normal user.

A good book about the topic is "Advanced Programming in the UNIX Environment" by Stevens and Rago

Upvotes: 1

shodanex
shodanex

Reputation: 15446

use man 2 open and man 2 mkdir. at the bottom of this man pages are the name of related command.

Alternatively, if you search a browseable version of this man pages, you can try here

Upvotes: 0

Jeremy Powell
Jeremy Powell

Reputation: 3486

I 'm not sure if this helps, but this is directly out of the kernel source:

struct file_operations {
    struct module *owner;
    loff_t (*llseek) (struct file *, loff_t, int);
    ssize_t (*read) (struct file *, char *, size_t, loff_t *);
    ssize_t (*write) (struct file *, const char *, size_t, loff_t *);
    int (*readdir) (struct file *, void *, filldir_t);
    unsigned int (*poll) (struct file *, struct poll_table_struct *);
    int (*ioctl) (struct inode *, struct file *, unsigned int, unsigned long);
    int (*mmap) (struct file *, struct vm_area_struct *);
    int (*open) (struct inode *, struct file *);
    int (*flush) (struct file *);
    int (*release) (struct inode *, struct file *);
    int (*fsync) (struct file *, struct dentry *, int datasync);
    int (*fasync) (int, struct file *, int);
    int (*lock) (struct file *, int, struct file_lock *);
    ssize_t (*readv) (struct file *, const struct iovec *, unsigned long, loff_t *);
    ssize_t (*writev) (struct file *, const struct iovec *, unsigned long, loff_t *);
    ssize_t (*sendpage) (struct file *, struct page *, int, size_t, loff_t *, int);
    unsigned long (*get_unmapped_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned long);
};

Filesystems generally register all their implementations to these callbacks.

Upvotes: 4

mipadi
mipadi

Reputation: 411182

Yep -- use the man pages. man fopen, man fread, man mkdir, etc., will describe the usage of those functions. Many man pages also have a "See Also" section that will direct you to the man pages of related functions, sort of like a primitive Wikipedia. :)

Upvotes: 1

Related Questions