Subversion Repositories shark

Rev

Rev 1063 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 pj 1
 
1063 tullio 2
/*
3
 * This program is free software; you can redistribute it and/or modify
4
 * it under the terms of the GNU General Public License as published by
5
 * the Free Software Foundation; either version 2 of the License, or
6
 * (at your option) any later version.
7
 *
8
 * This program is distributed in the hope that it will be useful,
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
 * GNU General Public License for more details.
12
 *
13
 * You should have received a copy of the GNU General Public License
14
 * along with this program; if not, write to the Free Software
15
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
 *
17
 */
18
 
2 pj 19
#include <fs/types.h>
20
#include <fs/errno.h>
21
#include <fs/task.h>
22
#include <fs/maccess.h>
23
#include <fs/dirent.h>
24
 
25
#include "file.h"
26
#include "inode.h"
27
#include "fileop.h"
28
#include "fs.h"
29
 
30
#include "debug.h"
31
 
32
int k_readdir(int fd, struct dirent *den)
33
{
34
  __pid_t pid;
35
  int     ret;
36
 
37
  call_to_fs();
38
 
39
  printk5("k_readdir: START");
40
 
41
  /* don't try to use a bad file descriptor */
42
  pid=__get_pid();
43
  if (check_fd(pid,fd)) {
44
    printk(KERN_INFO "k_readdir: using bad file descriptor");
45
    return_from_fs(-EBADF);
46
  }
47
 
48
  /* don't try to read a regular file */
49
  if (!file_ptr(pid,fd)->f_flag_isdir) return_from_fs(-EBADF);
50
 
51
  /* don't try to read into not user memory */
52
  if (!__verify_write(den,sizeof(struct dirent))) return_from_fs(-EVERIFY);
53
 
54
  printk5("k_readdir: parameters check pass... calling specific readdir");
55
 
56
  ret=file_ptr(pid,fd)->f_op->readdir(file_ptr(pid,fd),den);
57
 
58
  printk5("k_readdir: END");
59
 
60
  return_from_fs(ret);
61
}