websrv makefile updated; added support for more web pages to websrv; ZDE improvement...
[ZeXOS.git] / kernel / core / ioctl.c
blob401abbcd3caa218b904337c7856ca114ee0d6f1a
1 /*
2 * ZeX/OS
3 * Copyright (C) 2009 Tomas 'ZeXx86' Jedrzejek (zexx86@gmail.com)
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #include <system.h>
21 #include <string.h>
22 #include <config.h>
23 #include <ioctl.h>
25 int ioctl_call (unsigned id, void *buf, int l)
27 switch (id) {
28 case IOIFADDRSET:
30 struct ioifaddr_t *io = buf;
32 if (l != sizeof (struct ioifaddr_t))
33 return -1;
35 netif_t *netif = netif_findbyname (io->dev);
37 if (!netif)
38 return -1;
40 netif_ip_addr (netif, io->ipv4);
41 netif_ipv6_addr (netif, io->ipv6);
43 return 0;
45 case IOIFADDRGET:
47 struct ioifaddr_t *io = buf;
49 if (l != sizeof (struct ioifaddr_t))
50 return -1;
52 netif_t *netif = netif_findbyname (io->dev);
54 if (!netif)
55 return -1;
57 memcpy (&io->ipv4, &netif->ip, sizeof (net_ipv4));
58 memcpy (&io->ipv6, netif->ipv6, sizeof (net_ipv6));
60 return 0;
62 case IOATAREAD:
64 struct ioatarq_t *io = buf;
66 if (l != sizeof (struct ioatarq_t))
67 return -1;
69 dev_t *dev = dev_find (io->dev);
71 if (!dev)
72 return -1;
74 partition_t p;
75 p.base_io = 0;
77 if (!dev->handler (DEV_ACT_READ, &p, io->data, "", io->sector))
78 return -1;
80 return 0;
82 case IOATAWRITE:
84 struct ioatarq_t *io = buf;
86 if (l != sizeof (struct ioatarq_t))
87 return -1;
89 dev_t *dev = dev_find (io->dev);
91 if (!dev)
92 return -1;
94 partition_t p;
95 p.base_io = 0;
97 if (!dev->handler (DEV_ACT_WRITE, &p, io->data, "", io->sector))
98 return -1;
100 return 0;
104 return 1;