Ignore:
Timestamp:
Jan 21, 2018, 12:10:09 AM (6 years ago)
Author:
coas-nagasima
Message:

prototoolに関連するプロジェクトをnewlibからmuslを使うよう変更・更新
ntshellをnewlibの下位の実装から、muslのsyscallの実装に変更・更新
以下のOSSをアップデート
・mruby-1.3.0
・musl-1.1.18
・onigmo-6.1.3
・tcc-0.9.27
以下のOSSを追加
・openssl-1.1.0e
・curl-7.57.0
・zlib-1.2.11
以下のmrbgemsを追加
・iij/mruby-digest
・iij/mruby-env
・iij/mruby-errno
・iij/mruby-iijson
・iij/mruby-ipaddr
・iij/mruby-mock
・iij/mruby-require
・iij/mruby-tls-openssl

File:
1 edited

Legend:

Unmodified
Added
Removed
  • EcnlProtoTool/trunk/ntshell/src/fdtable.c

    r321 r331  
    3535 *  @(#) $Id$
    3636 */
     37#include "shellif.h"
    3738#include <stdint.h>
    38 #include <stdio.h>
    39 #include <sys/unistd.h>
    40 #include <limits.h>
    4139#include <kernel.h>
    4240#include <t_syslog.h>
    4341#include <t_stdlib.h>
    4442#include <sil.h>
    45 #include <stdlib.h>
    46 #include <string.h>
    47 #include <stdio.h>
    48 #include <setjmp.h>
    49 #include "../../../musl-1.1.12/include/poll.h"
    5043#include "syssvc/serial.h"
    5144#include "syssvc/syslog.h"
     
    6154#include <net/if_var.h>
    6255#include <netinet/udp_var.h>
    63 #include <ethernet_api.h>
     56//#include <ethernet_api.h>
    6457#include "ff.h"
    6558#include "socket_stub.h"
    6659#include "kernel_cfg.h"
     60#include <string.h>
    6761
    6862#define SIO_PORTID 1
     
    7165#define IO_TYPE_SIO             1
    7266#define IO_TYPE_FILE    2
    73 #define IO_TYPE_TCP             3
    74 #define IO_TYPE_UDP             4
     67#define IO_TYPE_DIR             3
     68#define IO_TYPE_TCP             4
     69#define IO_TYPE_UDP             5
    7570
    7671static struct _IO_FILE fd_table[8 * sizeof(FLGPTN)] = {
    77         { 0, IO_TYPE_SIO, 0, stdio_close, stdin_read, stdio_write },
    78         { 1, IO_TYPE_SIO, 0, stdio_close, stdio_read, stdout_write },
    79         { 2, IO_TYPE_SIO, 0, stdio_close, stdio_read, stderr_write },
     72        { 0, IO_TYPE_SIO, 0, stdio_close, stdin_read, stdio_write, sio_seek, sio_ioctl },
     73        { 1, IO_TYPE_SIO, 0, stdio_close, stdio_read, stdout_write, sio_seek, sio_ioctl },
     74        { 2, IO_TYPE_SIO, 0, stdio_close, stdio_read, stderr_write, sio_seek, sio_ioctl },
    8075};
    8176#define fd_table_count (sizeof(fd_table) / sizeof(fd_table[0]))
     
    9489        }
    9590
    96         return -1;
     91        return -ENOMEM;
    9792}
    9893
     
    112107        struct _IO_FILE *fp = id_to_fd(type, id);
    113108        if (fp == NULL)
    114                 return -1;
     109                return -EBADF;
    115110
    116111        memset(fp, 0, sizeof(struct _IO_FILE));
     
    136131        fp->read = sio_read;
    137132        fp->write = sio_write;
     133        fp->seek = sio_seek;
     134        fp->ioctl = sio_ioctl;
    138135
    139136        return fp;
     
    160157        fp->read = file_read;
    161158        fp->write = file_write;
     159        fp->seek = file_seek;
     160        fp->ioctl = file_ioctl;
    162161
    163162        return fp;
     
    172171{
    173172        return id_to_fd(IO_TYPE_FILE, fileid);
     173}
     174
     175struct _IO_FILE *new_dir_fd(int fileid)
     176{
     177        int fd = new_fd(IO_TYPE_DIR, fileid);
     178        if ((fd < 0) || (fd >= fd_table_count))
     179                return NULL;
     180
     181        struct _IO_FILE *fp = &fd_table[fd];
     182        fp->close = dir_close;
     183        fp->read = dir_read;
     184        fp->write = dir_write;
     185        fp->seek = dir_seek;
     186        fp->ioctl = dir_ioctl;
     187
     188        return fp;
     189}
     190
     191int delete_dir_fd(int dirid)
     192{
     193        return delete_fd(IO_TYPE_DIR, dirid);
     194}
     195
     196struct _IO_FILE *dirid_to_fd(int dirid)
     197{
     198        return id_to_fd(IO_TYPE_DIR, dirid);
    174199}
    175200
     
    184209        fp->read = tcp_fd_read;
    185210        fp->write = tcp_fd_write;
     211        fp->seek = tcp_fd_seek;
     212        fp->ioctl = tcp_fd_ioctl;
    186213
    187214        return fp;
     
    208235        fp->read = udp_fd_read;
    209236        fp->write = udp_fd_write;
     237        fp->seek = udp_fd_seek;
     238        fp->ioctl = udp_fd_ioctl;
    210239
    211240        return fp;
     
    220249{
    221250        return id_to_fd(IO_TYPE_UDP, udpid);
    222 }
    223 
    224 int shell_isatty(int fd)
    225 {
    226         if ((fd < 0) || (fd >= fd_table_count))
    227                 return 0;
    228 
    229         struct _IO_FILE *fp = &fd_table[fd];
    230         if (fp->type == IO_TYPE_SIO)
    231                 return 1;
    232 
    233         return 0;
    234251}
    235252
     
    245262#define TMO_MAX INT_MAX
    246263
    247 int select(int n, fd_set *rfds, fd_set *wfds, fd_set *efds, struct timeval *tv)
     264int shell_select(int n, fd_set *__restrict rfds, fd_set *__restrict wfds, fd_set *__restrict efds, struct timeval *__restrict tv)
    248265{
    249266        ER ret;
     
    277294        }
    278295
    279         return -1;
    280 }
    281 
    282 int poll(struct pollfd *fds, nfds_t nfds, int timeout)
     296        return -EBADF;
     297}
     298
     299int shell_poll(struct pollfd *fds, nfds_t nfds, int timeout)
    283300{
    284301        ER ret;
     
    334351        }
    335352
    336         return -1;
     353        return -EBADF;
    337354}
    338355
     
    541558        }
    542559}
     560
     561int shell_ioctl(int fd, int request, void *arg)
     562{
     563        struct _IO_FILE *fp = fd_to_fp(fd);
     564        if (fp == NULL)
     565                return -EBADF;
     566
     567        return fp->ioctl(fp, request, arg);
     568}
Note: See TracChangeset for help on using the changeset viewer.