Subversion Repositories shark

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 pj 1
 
2
#include <fs/types.h>
3
#include <fs/errno.h>
4
#include <fs/task.h>
5
#include <fs/maccess.h>
6
 
7
#include "file.h"
8
#include "inode.h"
9
#include "dentry.h"
10
#include "fileop.h"
11
#include "fs.h"
12
 
13
#include "debug.h"
14
 
15
int k_close(int fd)
16
{
17
  struct file *f;
18
  __pid_t pid;
19
 
20
  call_to_fs();
21
 
22
  /* don't try to use a bad file descriptor */
23
  pid=__get_pid();
24
  if (check_fd(pid,fd)) {
25
    printk(KERN_INFO "k_close: using bad file descriptor");
26
    return_from_fs(-EBADF);
27
  }
28
 
29
  /* don't try to close a directory */
30
  if (file_ptr(pid,fd)->f_flag_isdir) return_from_fs(-EBADF);
31
 
32
  f=free_fd(pid,fd);
33
  if (f==NULL) return_from_fs(-EBADF);
34
 
35
  f->f_op->close(f->f_dentry->d_inode,f);
36
  unlock_dentry(f->f_dentry);
37
 
38
  free_file(f);
39
  return_from_fs(EOK);
40
}