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_fs_info info;
  24         struct ncp_server *server = NCP_SERVER(inode);
  25 
  26         switch(cmd) {
  27         case NCP_IOC_NCPREQUEST:
  28 
  29                 if (   (permission(inode, MAY_WRITE) != 0)
  30                     && (current->uid != server->m.mounted_uid))
  31                 {
  32                         return -EACCES;
  33                 }
  34                 
  35                 if ((result = verify_area(VERIFY_READ, (char *)arg,
  36                                           sizeof(request))) != 0)
  37                 {
  38                         return result;
  39                 }
  40 
  41                 memcpy_fromfs(&request, (struct ncp_ioctl_request *)arg,
  42                               sizeof(request));
  43 
  44                 if (   (request.function > 255)
  45                     || (request.size >
  46                         NCP_PACKET_SIZE - sizeof(struct ncp_request_header)))
  47                 {
  48                         return -EINVAL;
  49                 }
  50 
  51                 if ((result = verify_area(VERIFY_WRITE, (char *)request.data,
  52                                           NCP_PACKET_SIZE)) != 0)
  53                 {
  54                         return result;
  55                 }
  56 
  57                 ncp_lock_server(server);
  58 
  59                 /* FIXME: We hack around in the server's structures
  60                    here to be able to use ncp_request */
  61 
  62                 server->has_subfunction = 0;
  63                 server->current_size = request.size;
  64                 memcpy_fromfs(server->packet, request.data, request.size);
  65 
  66                 ncp_request(server, request.function);
  67 
  68                 DPRINTK("ncp_ioctl: copy %d bytes\n",
  69                         server->reply_size);
  70                 memcpy_tofs(request.data, server->packet, server->reply_size);
  71 
  72                 ncp_unlock_server(server);
  73 
  74                 return server->reply_size;
  75 
  76         case NCP_IOC_GET_FS_INFO:
  77 
  78                 if (   (permission(inode, MAY_WRITE) != 0)
  79                     && (current->uid != server->m.mounted_uid))
  80                 {
  81                         return -EACCES;
  82                 }
  83                 
  84                 if ((result = verify_area(VERIFY_WRITE, (char *)arg,
  85                                           sizeof(info))) != 0)
  86                 {
  87                         return result;
  88                 }
  89 
  90                 memcpy_fromfs(&info, (struct ncp_fs_info *)arg,
  91                               sizeof(info));
  92 
  93                 if (info.version != NCP_GET_FS_INFO_VERSION)
  94                 {
  95                         DPRINTK("info.version invalid: %d\n", info.version);
  96                         return -EINVAL;
  97                 }
  98 
  99                 info.addr        = server->m.serv_addr;
 100                 info.mounted_uid = server->m.mounted_uid;
 101                 info.connection  = server->connection;
 102                 info.buffer_size = server->buffer_size;
 103 
 104                 memcpy_tofs((struct ncp_fs_info *)arg, &info, sizeof(info));
 105                 return 0;               
 106 
 107         case NCP_IOC_GETMOUNTUID:
 108 
 109                 if (   (permission(inode, MAY_READ) != 0)
 110                     && (current->uid != server->m.mounted_uid))
 111                 {
 112                         return -EACCES;
 113                 }
 114                 
 115                 if ((result = verify_area(VERIFY_WRITE, (uid_t*) arg,
 116                                           sizeof(uid_t))) != 0)
 117                 {
 118                         return result;
 119                 }
 120                 put_fs_word(server->m.mounted_uid, (uid_t*) arg);
 121                 return 0;
 122 
 123         default:
 124                 return -EINVAL;
 125         }
 126         
 127         return -EINVAL;
 128 }

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