首先下载下嵌入式linux服务器资源,linux-ftpd-0.17.tar.gz

下面我们将开始制作嵌入式linux下ftp服务器

1、解压资源

tar xvzf linux-ftpd-0.17.tar.gz

2、修改configure文件

vi configure,内容如下:

#!/bin/sh
#
# This file was generated by confgen version 2.
# Do not edit.
#PREFIX='/usr'
#EXECPREFIX='$PREFIX'
INSTALLROOT=''
BINMODE='755'
#DAEMONMODE='$BINMODE'
MANMODE='644'while [ x$1 != x ]; do case $1 in--help)
cat <<EOF
Usage: configure [options]--help                Show this message--with-debug          Enable debugging--without-shadow      Disable shadow password support--prefix=path         Prefix for location of files [/usr]--exec-prefix=path    Location for arch-depedent files [prefix]--installroot=root    Top of filesystem tree to install in [/]--binmode=mode        Mode for binaries [755]--daemonmode=mode     Mode for daemon binaries [same as binmode]--manmode=mode        Mode for manual pages [644]--with-c-compiler=cc  Program for compiling C source [guessed]
EOF
exit 0;;
--verbose) ;;
--quiet) ;;--subdir) . ../configure.defs;;--with-debug|--debug) DEBUG=1;;
--prefix=*) PREFIX=`echo $1 | sed 's/^[^=]*=//'` ;;
--exec-prefix=*) EXECPREFIX=`echo $1 | sed 's/^[^=]*=//'` ;;
--installroot=*) INSTALLROOT=`echo $1 | sed 's/^[^=]*=//'` ;;
--binmode=*) BINMODE=`echo $1 | sed 's/^[^=]*=//'` ;;
--daemonmode=*) DAEMONMODE=`echo $1 | sed 's/^[^=]*=//'` ;;
--manmode=*) MANMODE=`echo $1 | sed 's/^[^=]*=//'` ;;
--with-c-compiler=*) CC=`echo $1 | sed 's/^[^=]*=//'` ;;
--without-shadow|--disable-shadow) WITHOUT_SHADOW=1;;
*) echo "Unrecognized option: $1"; exit 1;;
esac
shift
done

上面我们能够清晰的看见configure的各个参数及作用,这里我不详细介绍各个参数的作用,这里我们如果想将ftpd服务器移植到嵌入式linux操作系统中,需要关注的主要是三个参数,分别是:prefix,installroot,with-c-compiler,其中prefix为installroot(文件系统根目录)目录下的具体目录,这里为什么需要将其与intallroot变量分开,主要是因为后续安装ftpd服务器时需要传递几个文件,所以需要根文件系统传递几个参数。

prefix:这里的值我们不用修改,一般ftpd被安装到文件系统目录下的/usr/sbin中

intallroot:文件系统的根目录,这里设置为/XXX/rootfs

with-c-compiler:交叉编译器的选择,嵌入式linux肯定是arm-linux-gcc,(在传递交叉编译工具时,如果文件中这样添加WITH-C-COMPILER='arm-linux-gcc',好像会报错,所

以我没直接在文件中传递这个参数,希望有大神能指点下为什么)

这是我们运行./configure --with-c-compiler=arm-linux-gcc尝试配置下,结果出现如下信息:

Directories: /usr/sbin /usr/man
   Checking if C compiler works... no
   Compiler arm-linux-gcc does not exist or cannot compile C; try another.

分析发现,我们传递的arm-linux-gcc出错,可是我的arm-linux-gcc编译内核都没问题,应该不会少文件,估计时configure文件内有错误,打开configure文件,找到错误信息

比对发现:

$CC __conftest.c -o __conftest || exit 1
          ./__conftest || exit 1

./__conftest肯定不能再linux下运行啊,所以果断将该文件中的./__conftest全部删除,总共8处。

继续运行./configure --with-c-compiler=arm-linux-gcc,这次输出信息Ok:

Directories: /usr/sbin /usr/man
Checking if C compiler works... yes
Checking if arm-linux-gcc accepts gcc warnings... yes
Checking if arm-linux-gcc accepts -O2... yes
Checking for yacc... bison -y
Checking for BSD signal semantics... yes
Checking for shadow... yes
Checking for crypt... -lcrypt
Checking for socklen_t... yes
Checking for snprintf declaration... ok
Checking for snprintf implementation... ok
Generating MCONFIG...

3、接下来我们开始编译

make,结果还是报错,

ftpcmd.y:108: error: array type has incomplete element type
ftpcmd.y:109: error: array type has incomplete element type
ftpcmd.y: In function 'yylex':
ftpcmd.y:1055: warning: cast discards qualifiers from pointer target type
ftpcmd.y:1081: warning: cast discards qualifiers from pointer target type
make[1]: *** [ftpcmd.o] Error 1
make[1]: Leaving directory `/GT2440/linux-ftpd-0.17/ftpd'

查看出错文件,vim ftpd/ftpcmd.y

发现这块应该是tab结构体定义文件,将该文件中822行开始的结构体定义放到代码前面,ok。

   1 /*2  * Copyright (c) 1985, 1988, 1993, 19943  *      The Regents of the University of California.  All rights reserved.4  *5  * Redistribution and use in source and binary forms, with or without6  * modification, are permitted provided that the following conditions7  * are met:8  * 1. Redistributions of source code must retain the above copyright9  *    notice, this list of conditions and the following disclaimer.10  * 2. Redistributions in binary form must reproduce the above copyright11  *    notice, this list of conditions and the following disclaimer in the12  *    documentation and/or other materials provided with the distribution.13  * 3. All advertising materials mentioning features or use of this software14  *    must display the following acknowledgement:15  *      This product includes software developed by the University of16  *      California, Berkeley and its contributors.17  * 4. Neither the name of the University nor the names of its contributors18  *    may be used to endorse or promote products derived from this software19  *    without specific prior written permission.20  *21  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND22  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE24  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE25  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL26  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS27  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)28  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT29  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY30  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF31  * SUCH DAMAGE.32  *33  *      @(#)ftpcmd.y    8.3 (Berkeley) 4/6/9434  *      NetBSD: ftpcmd.y,v 1.7 1996/04/08 19:03:11 jtc Exp35  *      OpenBSD: ftpcmd.y,v 1.16 1998/05/22 06:46:09 deraadt Exp36  */3738 /*39  * Grammar for FTP commands.40  * See RFC 959.41  */4243 %{4445 char ftpcmd_rcsid[] =46   "$Id: ftpcmd.y,v 1.11 1999/10/09 02:32:12 dholland Exp $";4748 #include <sys/param.h>49 #include <sys/socket.h>50 #include <sys/stat.h>5152 #include <netinet/in.h>53 #include <arpa/ftp.h>5455 #include <ctype.h>56 #include <errno.h>57 #include <glob.h>58 #include <pwd.h>59 #include <setjmp.h>60 #include <signal.h>61 #include <stdio.h>62 #include <stdlib.h>63 #include <string.h>64 #include <syslog.h>65 #include <time.h>66 #include <unistd.h>6768 #ifndef __linux__69 #include <tzfile.h>70 #else71 #define TM_YEAR_BASE 190072 #endif7374 #include "extern.h"7576 extern  struct sockaddr_in data_dest;77 extern  int logged_in;78 extern  struct passwd *pw;79 extern  int guest;80 extern  int logging;81 extern  int type;82 extern  int form;83 extern  int debug;84 extern  int timeout;85 extern  int maxtimeout;86 extern  int pdata;87 extern  char hostname[], remotehost[];88 extern  char proctitle[];89 extern  int usedefault;90 extern  int transflag;91 extern  char tmpline[];92 extern  int portcheck;93 extern  struct sockaddr_in his_addr;9495 off_t   restart_point;9697 static  int cmd_type;98 static  int cmd_form;99 static  int cmd_bytesz;100 char    cbuf[512];101 char    *fromname;102103 struct tab;104 static int       yylex __P((void));105 static void      sizecmd __P((char *));106 static void      help __P((struct tab *, char *));107 %}108109 %union {110         int     i;111         char   *s;112 }113114 %token115         A       B       C       E       F       I116         L       N       P       R       S       T117118         SP      CRLF    COMMA119120         USER    PASS    ACCT    REIN    QUIT    PORT121         PASV    TYPE    STRU    MODE    RETR    STOR122         APPE    MLFL    MAIL    MSND    MSOM    MSAM123         MRSQ    MRCP    ALLO    REST    RNFR    RNTO124         ABOR    DELE    CWD     LIST    NLST    SITE125         STAT    HELP    NOOP    MKD     RMD     PWD126         CDUP    STOU    SMNT    SYST    SIZE    MDTM127128         UMASK   IDLE    CHMOD129130         LEXERR131132 %token  <s> STRING133 %token  <i> NUMBER134135 %type   <i> check_login octal_number byte_size136 %type   <i> struct_code mode_code type_code form_code137 %type   <s> pathstring pathname password username138 %type   <i> host_port139140 %start  cmd_list141142 %{143 extern jmp_buf errcatch;144145 #define CMD     0       /* beginning of command */146 #define ARGS    1       /* expect miscellaneous arguments */147 #define STR1    2       /* expect SP followed by STRING */148 #define STR2    3       /* expect STRING */149 #define OSTR    4       /* optional SP then STRING */150 #define ZSTR1   5       /* SP then optional STRING */151 #define ZSTR2   6       /* optional STRING after SP */152 #define SITECMD 7       /* SITE command */153 #define NSTR    8       /* Number followed by a string */154155 struct tab {156         const char      *name;157         short   token;158         short   state;159         short   implemented;    /* 1 if command is implemented */160         const char      *help;161 };162163 struct tab cmdtab[] = {         /* In order defined in RFC 765 */164         { "USER", USER, STR1, 1,        "<sp> username" },165         { "PASS", PASS, ZSTR1, 1,       "<sp> password" },166         { "ACCT", ACCT, STR1, 0,        "(specify account)" },167         { "SMNT", SMNT, ARGS, 0,        "(structure mount)" },168         { "REIN", REIN, ARGS, 0,        "(reinitialize server state)" },169         { "QUIT", QUIT, ARGS, 1,        "(terminate service)", },170         { "PORT", PORT, ARGS, 1,        "<sp> b0, b1, b2, b3, b4" },171         { "PASV", PASV, ARGS, 1,        "(set server in passive mode)" },172         { "TYPE", TYPE, ARGS, 1,        "<sp> [ A | E | I | L ]" },173         { "STRU", STRU, ARGS, 1,        "(specify file structure)" },174         { "MODE", MODE, ARGS, 1,        "(specify transfer mode)" },175         { "RETR", RETR, STR1, 1,        "<sp> file-name" },176         { "STOR", STOR, STR1, 1,        "<sp> file-name" },177         { "APPE", APPE, STR1, 1,        "<sp> file-name" },178         { "MLFL", MLFL, OSTR, 0,        "(mail file)" },179         { "MAIL", MAIL, OSTR, 0,        "(mail to user)" },180         { "MSND", MSND, OSTR, 0,        "(mail send to terminal)" },181         { "MSOM", MSOM, OSTR, 0,        "(mail send to terminal or mailbox)" },182         { "MSAM", MSAM, OSTR, 0,        "(mail send to terminal and mailbox)" },183         { "MRSQ", MRSQ, OSTR, 0,        "(mail recipient scheme question)" },184         { "MRCP", MRCP, STR1, 0,        "(mail recipient)" },185         { "ALLO", ALLO, ARGS, 1,        "allocate storage (vacuously)" },186         { "REST", REST, ARGS, 1,        "<sp> offset (restart command)" },187         { "RNFR", RNFR, STR1, 1,        "<sp> file-name" },188         { "RNTO", RNTO, STR1, 1,        "<sp> file-name" },189         { "ABOR", ABOR, ARGS, 1,        "(abort operation)" },190         { "DELE", DELE, STR1, 1,        "<sp> file-name" },191         { "CWD",  CWD,  OSTR, 1,        "[ <sp> directory-name ]" },192         { "XCWD", CWD,  OSTR, 1,        "[ <sp> directory-name ]" },193         { "LIST", LIST, OSTR, 1,        "[ <sp> path-name ]" },194         { "NLST", NLST, OSTR, 1,        "[ <sp> path-name ]" },195         { "SITE", SITE, SITECMD, 1,     "site-cmd [ <sp> arguments ]" },196         { "SYST", SYST, ARGS, 1,        "(get type of operating system)" },197         { "STAT", STAT, OSTR, 1,        "[ <sp> path-name ]" },198         { "HELP", HELP, OSTR, 1,        "[ <sp> <string> ]" },199         { "NOOP", NOOP, ARGS, 1,        "" },200         { "MKD",  MKD,  STR1, 1,        "<sp> path-name" },201         { "XMKD", MKD,  STR1, 1,        "<sp> path-name" },202         { "RMD",  RMD,  STR1, 1,        "<sp> path-name" },203         { "XRMD", RMD,  STR1, 1,        "<sp> path-name" },204         { "PWD",  PWD,  ARGS, 1,        "(return current directory)" },205         { "XPWD", PWD,  ARGS, 1,        "(return current directory)" },206         { "CDUP", CDUP, ARGS, 1,        "(change to parent directory)" },207         { "XCUP", CDUP, ARGS, 1,        "(change to parent directory)" },208         { "STOU", STOU, STR1, 1,        "<sp> file-name" },209         { "SIZE", SIZE, OSTR, 1,        "<sp> path-name" },210         { "MDTM", MDTM, OSTR, 1,        "<sp> path-name" },211         { NULL,   0,    0,    0,        0 }212 };213214 struct tab sitetab[] = {215         { "UMASK", UMASK, ARGS, 1,      "[ <sp> umask ]" },216         { "IDLE", IDLE, ARGS, 1,        "[ <sp> maximum-idle-time ]" },217         { "CHMOD", CHMOD, NSTR, 1,      "<sp> mode <sp> file-name" },218         { "HELP", HELP, OSTR, 1,        "[ <sp> <string> ]" },219         { NULL,   0,    0,    0,        0 }220 };221 extern struct tab cmdtab[];222 extern struct tab sitetab[];223224 %}

重新编译,没有错误

4、安装ftpd,直接将ftpd拷贝到根文件系统目录下的/usr/sbin中,然后配置启动文件

在etc目录下的init.d/rcS文件中,添加如下内容:

# These are standard services.
#
ftpstreamtcpnowaitroot/usr/sbin/ftpd/usr/sbin/ftpd
#telnetstreamtcpnowaitroot/usr/sbin/telnetd/usr/sbin/telnetd -i

修改/etc/passwd文件,添加如下内容:

root::0:0:root:/:/bin/sh
ftp::14:50:FTP User:/var/ftp:
bin:*:1:1:bin:/bin:
daemon:*:2:2:daemon:/sbin:
nobody:*:99:99:Nobody:/:
plg:$1$wwtsqwnk$sWaEJGcJFTqaCW18sbUK7/:502:502:Linux User,,,:/home/plg:/bin/sh

但是,发现启动ftp服务后,需要挺长时间才能登陆上。因此推荐大家还是使用vsftpd-2.3.4,感觉比ftpd好用。

VSftpd-2.3.4使用:http://blog.csdn.net/alan00000/article/details/7194702

linux-ftpd-0.17制作ftpd嵌入式linux下的ftp服务器相关推荐

  1. arm linux udp 自发自收_嵌入式linux编程开发必备知识

    嵌入式linux是嵌入式开发必不可少的一份子,在科技高速发展的今天,嵌入式已然已经成为了最热门的技术之一了.对于想要学习好嵌入式的学员来说,现在学习好linux是很有必要的,因为这个是嵌入式的核心.那 ...

  2. linux QT 结束当前进程_嵌入式linux编程开发必备知识

    嵌入式linux是嵌入式开发必不可少的一份子,在科技高速发展的今天,嵌入式已然已经成为了最热门的技术之一了.对于想要学习好嵌入式的学员来说,现在学习好linux是很有必要的,因为这个是嵌入式的核心.那 ...

  3. (Linux无线网卡WIFI上网 三 )嵌入式Linux下的WIFI使用

    导航 (Linux无线网卡WIFI上网 一 )USB-WIFI驱动移植 (Linux无线网卡WIFI上网 二 )WPA_SUPPLICANT--Linux下的wifi管理工具移植 (Linux无线网卡 ...

  4. linux+创建一个v文件共享,win10与Ubantu双系统:Linux下开启FTP服务器与创建无线热点(实现文件共享)...

    如何在win系统下使用filelizza这个软件搭建FTP服务器,然后建立一个无线局域网,让平板终端连接以后,访问电脑硬盘的文件. 如果是只在win7环境下,一切都很简单,按照上文提供的教程就可以实现 ...

  5. Linux系统搭建多用户多目录不同权限访问的FTP服务器

    Linux系统搭建多用户多目录不同权限访问的FTP服务器 1 安装服务 [root@host-192-168-9-19 home]# yum -y install vsftpd 2 创建访问目录 创建 ...

  6. 虚拟机linux ftp慢,虚拟机Linux下配置FTP服务器的方法

    虚拟机Linux下配置FTP服务器的方法 1.确保虚拟机系统与宿主系统是桥接设置,以方便连接. 2.在虚拟机系统中安装ftp服务器,我安装的是vsftpd服务器.由于安装的虚拟机系统CentOS 中已 ...

  7. 国产化探索之路---中标麒麟 Linux系统下,FTP服务器部署

    中标麒麟 Linux系统下,FTP服务器部署 1.安装FTP软件包 yum install vsftpd -y 2.创建ftp用户密码 useradd ftpuserecho "ftpuse ...

  8. linux pwm 调屏_基于嵌入式Linux的LCD背光调节及驱动的实现

    0 引言 在手持式设备中,液晶显示屏的使用越来越广泛.由于LCD自身是不能发光的,它需要一个强劲的光源来给它提供背光,以便清晰地显示信息.这样的光源是非常耗电的,通常液晶显示屏的功耗常常占到系统总功耗 ...

  9. windows linux cpu 抢占式 时间片_嵌入式Linux中进程调度怎样来解析

    合作微信:xydf321456 Linux是一套免费使用和自由传播的类Unix操作系统,是一个基于POSIX和UNIX的多用户.多任务.支持多线程和多CPU的操作系统.它能运行主要的UNIX工具软件. ...

最新文章

  1. 重新定义 AI 服务器架构
  2. Android IOS WebRTC 音视频开发总结(二三)-- hurtc使用说明
  3. 用户空间和内核空间通讯之【proc文件系统】
  4. ubuntu 访问php没反应,linux - 在Ubuntu中,我对php.ini进行了更改,但没有任何反应 - Ubuntu问答...
  5. Go基础--goroutine和channel
  6. CentOS6.8 安装node.js npm
  7. android 表情,软键盘冲突解决方案(仿微博等SNS应用)
  8. 0010101 java_JAVA入门教程运算符和表达式
  9. Linux信号的产生和处理
  10. 熊猫烧香能破坏计算机硬件吗,熊猫烧香病毒会伤害电脑硬件吗?
  11. 如何用java线程池做分批次查询处理 java线程池ThreadPoolExecutor的使用
  12. python打开autocad软件_利用Python自动化操作AutoCAD的实现
  13. base64原理解析
  14. Python根据字幕文件自动给视频添加字幕
  15. 免费的QQ微信消息推送机器人
  16. ZigBee模块——从新冠、癌症防治看物联网智慧医疗的应用
  17. Apache Tomcat 文件包含漏洞(CNVD-2020-10487,对应 CVE-2020-1938)
  18. MATLAB 制作gif动态图
  19. iPhone开发基础教程笔记(二)--第三章 处理基本交互
  20. 用python模拟登录12306

热门文章

  1. Python 拼图成心2.0【重新梳理】【附完整代码】
  2. OTA争做“盲盒”生意,吹响“五一流量争夺战”号角?
  3. Ubuntu零基础教学-Ubuntu20.04系统所在分区sda5进行磁盘扩容|详细教程,建议收藏
  4. BLE蓝牙笔记----广播连接过程
  5. 计算机毕业设计Java办公自动化管理系统(源码+系统+mysql数据库+lw文档)
  6. C++友元函数和友元类
  7. [学习与探索]快手视频刷积分python脚本
  8. 三种实现图片截取的方法
  9. 性能测试调优JVM调优(三)之JMeter使用
  10. windows web服务器性能测试工具,Web 性能测试编辑器概述