File: file.h

package info (click to toggle)
kernel-source-2.2.19 2.2.19.1-4woody1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 92,100 kB
  • ctags: 276,892
  • sloc: ansic: 1,710,384; asm: 58,709; makefile: 10,198; sh: 2,398; perl: 907; tcl: 570; lisp: 218; cpp: 186; awk: 133; sed: 72
file content (80 lines) | stat: -rw-r--r-- 1,761 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*
 * Wrapper functions for accessing the file_struct fd array.
 */

#ifndef __LINUX_FILE_H
#define __LINUX_FILE_H

extern void __fput(struct file *);

/*
 * Check whether the specified task has the fd open. Since the task
 * may not have a files_struct, we must test for p->files != NULL.
 */
extern inline struct file * fcheck_task(struct task_struct *p, unsigned int fd)
{
	struct file * file = NULL;

	if (p->files && fd < p->files->max_fds)
		file = p->files->fd[fd];
	return file;
}

/*
 * Check whether the specified fd has an open file.
 */
extern inline struct file * fcheck(unsigned int fd)
{
	struct file * file = NULL;

	if (fd < current->files->max_fds)
		file = current->files->fd[fd];
	return file;
}

extern inline struct file * fget(unsigned int fd)
{
	struct file * file = fcheck(fd);

	if (file)
		file->f_count++;
	return file;
}

extern int get_unused_fd(void);   /* in fs/open.c */

static inline void put_unused_fd(unsigned int fd)
{
	FD_CLR(fd, current->files->open_fds);
	if (fd < current->files->next_fd)
		current->files->next_fd = fd;
}

/*
 * Install a file pointer in the fd array.
 */
extern inline void fd_install(unsigned int fd, struct file *file)
{
	current->files->fd[fd] = file;
}

/*
 * 23/12/1998 Marcin Dalecki <dalecki@cs.net.pl>: 
 * 
 * Since those functions where calling other functions, it was compleatly 
 * bogous to make them all "extern inline".
 *
 * The removal of this pseudo optimization saved me scandaleous:
 *
 * 		3756 (i386 arch) 
 *
 * precious bytes from my kernel, even without counting all the code compiled
 * as module!
 *
 * I suspect there are many other similar "optimizations" across the
 * kernel...
 */
extern void fput(struct file *file); 
extern void put_filp(struct file *file);

#endif