aboutsummaryrefslogtreecommitdiff
path: root/pfinet/linux-src/include/linux/file.h
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>2000-02-04 03:21:18 +0000
committerRoland McGrath <roland@gnu.org>2000-02-04 03:21:18 +0000
commit8880a73970b23f10c720011cb910c0e0e1e02975 (patch)
treed1ce76577a1ace5312fc0576a93d4d8db1e89323 /pfinet/linux-src/include/linux/file.h
parent8399aa4ab7b849da57f4c59039f091526c9e2f98 (diff)
parent9fd51e9b0ad33a89a83fdbbb66bd20d85f7893fb (diff)
downloadhurd-8880a73970b23f10c720011cb910c0e0e1e02975.tar.gz
hurd-8880a73970b23f10c720011cb910c0e0e1e02975.tar.bz2
hurd-8880a73970b23f10c720011cb910c0e0e1e02975.zip
Merge from vendor branch Linux:
Import of Linux 2.2.12 subset (ipv4 stack and related)
Diffstat (limited to 'pfinet/linux-src/include/linux/file.h')
-rw-r--r--pfinet/linux-src/include/linux/file.h71
1 files changed, 71 insertions, 0 deletions
diff --git a/pfinet/linux-src/include/linux/file.h b/pfinet/linux-src/include/linux/file.h
new file mode 100644
index 00000000..05f388f0
--- /dev/null
+++ b/pfinet/linux-src/include/linux/file.h
@@ -0,0 +1,71 @@
+/*
+ * 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;
+}
+
+/*
+ * 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