Subversion Repositories shark

Rev

Rev 2 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed


#include <fs/types.h>
#include <fs/errno.h>
#include <fs/task.h>
#include <fs/maccess.h>

#include "file.h"
#include "inode.h"
#include "dentry.h"
#include "fileop.h"
#include "fs.h"

#include "debug.h"

int k_closedir(int fd)
{
  struct file *f;
  __pid_t pid;

  call_to_fs();
 
  /* don't try to use a bad file descriptor */
  pid=__get_pid();
  if (check_fd(pid,fd)) {
    printk(KERN_INFO "k_closedir: using bad file descriptor");
    return_from_fs(-EBADF);
  }

  /* don't try to close a file */
  if (!file_ptr(pid,fd)->f_flag_isdir) return_from_fs(-EBADF);
 
  f=free_fd(pid,fd);
  if (f==NULL) return_from_fs(-EBADF);

  f->f_op->close(f->f_dentry->d_inode,f);
  unlock_dentry(f->f_dentry);
 
  free_file(f);
  return_from_fs(EOK);
}