root/fs/ncpfs/ioctl.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. ncp_ioctl

   1 /*
   2  *  ioctl.c
   3  *
   4  *  Copyright (C) 1995 by Volker Lendecke
   5  *
   6  */
   7 
   8 #include <asm/segment.h>
   9 #include <linux/errno.h>
  10 #include <linux/fs.h>
  11 #include <linux/ncp_fs.h>
  12 #include <linux/ioctl.h>
  13 #include <linux/sched.h>
  14 #include <linux/mm.h>
  15 #include <linux/ncp.h>
  16 
  17 int
  18 ncp_ioctl (struct inode * inode, struct file * filp,
     /* [previous][next][first][last][top][bottom][index][help] */
  19            unsigned int cmd, unsigned long arg)
  20 {
  21         int result;
  22         struct ncp_ioctl_request request;
  23         struct ncp_server *server;
  24 
  25         switch(cmd) {
  26         case NCP_IOC_NCPREQUEST:
  27 
  28                 if (!suser())
  29                 {
  30                         return -EPERM;
  31                 }
  32                 
  33                 if ((result = verify_area(VERIFY_READ, (char *)arg,
  34                                           sizeof(request))) != 0)
  35                 {
  36                         return result;
  37                 }
  38 
  39                 memcpy_fromfs(&request, (struct ncp_ioctl_request *)arg,
  40                               sizeof(request));
  41 
  42                 if (   (request.function > 255)
  43                     || (request.size >
  44                         NCP_PACKET_SIZE - sizeof(struct ncp_request_header)))
  45                 {
  46                         return -EINVAL;
  47                 }
  48 
  49                 if ((result = verify_area(VERIFY_WRITE, (char *)request.data,
  50                                           NCP_PACKET_SIZE)) != 0)
  51                 {
  52                         return result;
  53                 }
  54 
  55                 server = NCP_SERVER(inode);
  56                 ncp_lock_server(server);
  57 
  58                 /* FIXME: We hack around in the server's structures
  59                    here to be able to use ncp_request */
  60 
  61                 server->has_subfunction = 0;
  62                 server->current_size =
  63                         request.size + sizeof(struct ncp_request_header);
  64                 memcpy_fromfs(server->packet, request.data,
  65                               request.size+sizeof(struct ncp_request_header));
  66 
  67                 
  68                 ncp_request(server, request.function);
  69 
  70                 DPRINTK("ncp_ioctl: copy %d bytes\n",
  71                         server->reply_size);
  72                 memcpy_tofs(request.data, server->packet,
  73                             server->reply_size);
  74 
  75                 ncp_unlock_server(server);
  76 
  77                 return server->reply_size;
  78 
  79         case NCP_IOC_GETMOUNTUID:
  80                 if ((result = verify_area(VERIFY_WRITE, (uid_t*) arg,
  81                                           sizeof(uid_t))) != 0)
  82                 {
  83                         return result;
  84                 }
  85                 put_fs_word(NCP_SERVER(inode)->m.mounted_uid, (uid_t*) arg);
  86                 return 0;
  87 
  88         default:
  89                 return -EINVAL;
  90         }
  91         
  92         return -EINVAL;
  93 }

/* [previous][next][first][last][top][bottom][index][help] */