[Krafton Jungle] PintOS 2.0.0
크래프톤 정글 PintOS
 
Loading...
Searching...
No Matches
file.c File Reference
#include "filesys/file.h"
#include <debug.h>
#include "filesys/inode.h"
#include "threads/malloc.h"
Include dependency graph for file.c:

Classes

struct  file
 

Functions

struct filefile_open (struct inode *inode)
 
struct filefile_reopen (struct file *file)
 
struct filefile_duplicate (struct file *file)
 
void file_close (struct file *file)
 
struct inodefile_get_inode (struct file *file)
 
off_t file_read (struct file *file, void *buffer, off_t size)
 
off_t file_read_at (struct file *file, void *buffer, off_t size, off_t file_ofs)
 
off_t file_write (struct file *file, const void *buffer, off_t size)
 
off_t file_write_at (struct file *file, const void *buffer, off_t size, off_t file_ofs)
 
void file_deny_write (struct file *file)
 
void file_allow_write (struct file *file)
 
off_t file_length (struct file *file)
 
void file_seek (struct file *file, off_t new_pos)
 
off_t file_tell (struct file *file)
 

Function Documentation

◆ file_allow_write()

void file_allow_write ( struct file file)
131 {
132 ASSERT (file != NULL);
133 if (file->deny_write) {
134 file->deny_write = false;
136 }
137}
#define ASSERT(CONDITION)
Definition: debug.h:30
void inode_allow_write(struct inode *inode)
Definition: inode.c:303
#define NULL
Definition: stddef.h:4
Definition: file.c:7
struct inode * inode
Definition: file.c:8
bool deny_write
Definition: file.c:10
Here is the call graph for this function:
Here is the caller graph for this function:

◆ file_close()

void file_close ( struct file file)
53 {
54 if (file != NULL) {
57 free (file);
58 }
59}
void file_allow_write(struct file *file)
Definition: file.c:131
void inode_close(struct inode *inode)
Definition: inode.c:150
void free(void *)
Definition: malloc.c:202
Here is the call graph for this function:
Here is the caller graph for this function:

◆ file_deny_write()

void file_deny_write ( struct file file)
119 {
120 ASSERT (file != NULL);
121 if (!file->deny_write) {
122 file->deny_write = true;
124 }
125}
void inode_deny_write(struct inode *inode)
Definition: inode.c:293
Here is the call graph for this function:
Here is the caller graph for this function:

◆ file_duplicate()

struct file * file_duplicate ( struct file file)
41 {
42 struct file *nfile = file_open (inode_reopen (file->inode));
43 if (nfile) {
44 nfile->pos = file->pos;
45 if (file->deny_write)
46 file_deny_write (nfile);
47 }
48 return nfile;
49}
struct file * file_open(struct inode *inode)
Definition: file.c:17
void file_deny_write(struct file *file)
Definition: file.c:119
struct inode * inode_reopen(struct inode *inode)
Definition: inode.c:134
off_t pos
Definition: file.c:9
Here is the call graph for this function:
Here is the caller graph for this function:

◆ file_get_inode()

struct inode * file_get_inode ( struct file file)
63 {
64 return file->inode;
65}

◆ file_length()

off_t file_length ( struct file file)
141 {
142 ASSERT (file != NULL);
143 return inode_length (file->inode);
144}
off_t inode_length(const struct inode *inode)
Definition: inode.c:311
Here is the call graph for this function:
Here is the caller graph for this function:

◆ file_open()

struct file * file_open ( struct inode inode)
17 {
18 struct file *file = calloc (1, sizeof *file);
19 if (inode != NULL && file != NULL) {
20 file->inode = inode;
21 file->pos = 0;
22 file->deny_write = false;
23 return file;
24 } else {
26 free (file);
27 return NULL;
28 }
29}
void * calloc(size_t, size_t) __attribute__((malloc))
Definition: malloc.c:149
Definition: inode.c:30
Here is the call graph for this function:
Here is the caller graph for this function:

◆ file_read()

off_t file_read ( struct file file,
void *  buffer,
off_t  size 
)
73 {
74 off_t bytes_read = inode_read_at (file->inode, buffer, size, file->pos);
75 file->pos += bytes_read;
76 return bytes_read;
77}
off_t inode_read_at(struct inode *inode, void *buffer_, off_t size, off_t offset)
Definition: inode.c:183
static struct intq buffer
Definition: input.c:7
uint16_t size
Definition: mmu.h:0
int32_t off_t
Definition: off_t.h:9
Here is the call graph for this function:
Here is the caller graph for this function:

◆ file_read_at()

off_t file_read_at ( struct file file,
void *  buffer,
off_t  size,
off_t  file_ofs 
)
85 {
86 return inode_read_at (file->inode, buffer, size, file_ofs);
87}
Here is the call graph for this function:

◆ file_reopen()

struct file * file_reopen ( struct file file)
34 {
35 return file_open (inode_reopen (file->inode));
36}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ file_seek()

void file_seek ( struct file file,
off_t  new_pos 
)
149 {
150 ASSERT (file != NULL);
151 ASSERT (new_pos >= 0);
152 file->pos = new_pos;
153}
Here is the caller graph for this function:

◆ file_tell()

off_t file_tell ( struct file file)
158 {
159 ASSERT (file != NULL);
160 return file->pos;
161}
Here is the caller graph for this function:

◆ file_write()

off_t file_write ( struct file file,
const void *  buffer,
off_t  size 
)
97 {
98 off_t bytes_written = inode_write_at (file->inode, buffer, size, file->pos);
99 file->pos += bytes_written;
100 return bytes_written;
101}
off_t inode_write_at(struct inode *inode, const void *buffer_, off_t size, off_t offset)
Definition: inode.c:234
Here is the call graph for this function:
Here is the caller graph for this function:

◆ file_write_at()

off_t file_write_at ( struct file file,
const void *  buffer,
off_t  size,
off_t  file_ofs 
)
112 {
113 return inode_write_at (file->inode, buffer, size, file_ofs);
114}
Here is the call graph for this function:
Here is the caller graph for this function: