PatchworkOS  966e257
A non-POSIX operating system.
Loading...
Searching...
No Matches

Underlying type of a file descriptor. More...

Collaboration diagram for File:

Detailed Description

Underlying type of a file descriptor.

A file is the underlying type of a file descriptor. Note that internally the kernel does not use file descriptors, they are simply a per-process handle to a file. The kernel uses files directly.

Data Structures

struct  file_t
 File structure. More...
 
struct  file_ops_t
 File operations structure. More...
 
struct  poll_file_t
 Structure for polling multiple files. More...
 

Functions

file_tfile_new (const path_t *path, mode_t mode)
 Create a new file structure.
 
uint64_t file_generic_seek (file_t *file, int64_t offset, seek_origin_t origin)
 Helper function for basic seeking.
 

Function Documentation

◆ file_new()

file_t * file_new ( const path_t path,
mode_t  mode 
)

Create a new file structure.

This does not open the file, instead its used internally by the VFS when opening files.

There is no file_free() instead use UNREF().

Parameters
pathThe path of the file.
modeThe mode with which the file was opened, if no permissions are specified the maximum allowed permissions from the mount are used.
Returns
On success, the new file. On failure, returns NULL and errno is set to:
  • EINVAL: Invalid parameters.
  • EACCES: The requested mode exceeds the maximum allowed permissions.
  • ENOENT: The dentry of the path is negative.
  • EISDIR: The dentry of the path is a directory but mode does not specify MODE_DIRECTORY.
  • ENOTDIR: The dentry of the path is a file but mode specifies MODE_DIRECTORY.
  • ENOMEM: Out of memory.

Definition at line 32 of file file.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ file_generic_seek()

uint64_t file_generic_seek ( file_t file,
int64_t  offset,
seek_origin_t  origin 
)

Helper function for basic seeking.

This can be used by filesystems that do not have any special requirements for seeking.

Used by setting the file ops seek to this function.

Definition at line 92 of file file.c.