A simple ftp server for eCos

eCos is an open source, royalty-free, real-time operating system intended for embedded applications. It has a lot of highly configurable packages, but up to now there is no ftp server.

As I needed one for my project, I took the Troll-FTPd, stripped if of less important part and created a simple ftp server with minimum of the functions.


#include "ftpd.h"


  int chpwd(const char *user, const char *password)
    if (! strcmp(user, "stano"))
      return strcmp(password, "foo");

    return -1;


  ftp_server_t server;

  memset(&server, 0, sizeof(ftp_server_t));
  server.check_pwd = chpwd;
  server.firstport = 30000;
  server.lastport = 30500;
  //strcpy(server.chrootdir, "/fs");



As the mount table in the eCos is a bit special and opendir does not work on root, the ftp server uses a magic to construct the root directory and is only able to access filesystem having a single path element in the mount call - e.g. /fs. Alternatively you can restrict it to a subtree setting the chrootdir directly.

This is only a first shot at the server (I just needed something standard to transfer images for updating our application), the functionality is not yet complete, there are untested parts and there will be bugs. Feel free to send me patches.

Download: ecos-ftpserver-0.2.tar.gz

Bratislava, 31. 5. 2011

Stanislav Meduna
stano (AT) meduna.org