Archive for the ‘服务器’ Category

Use BusyBox to learn C and Linux

Wednesday, June 10th, 2009

BusyBox is an open-source software application that provides many standard Unix tools, much like the larger (but more capable) GNU Core Utilities. BusyBox is designed to be a small executable for use with Linux, which makes it ideal for special purpose Linux distributions and embedded devices. It has been called "The Swiss Army Knife of Embedded Linux".

Get the source code under Debian/Ubuntu:

sudo apt-get source busybox

Find the standard Unix tools:

find ./ -name "pwd.c"
find ./ -name "ls.c"

The code of pwd.c is simple:

/* vi: set sw=4 ts=4: */
/*
 * Mini pwd implementation for busybox
 *
 * Copyright (C) 1995, 1996 by Bruce Perens <bruce@pixar.com>.
 *
 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
 */

#include "libbb.h"

/* This is a NOFORK applet. Be very careful! */

int pwd_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int pwd_main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED)
{
  char *buf;

  buf = xrealloc_getcwd_or_warn(NULL);
  if (buf != NULL) {
    puts(buf);
    free(buf);
    return fflush(stdout);
  }

  return EXIT_FAILURE;
}

In this way, you can learn C and Linux step by step :)

C89和C99标准比较

Monday, June 8th, 2009

Funny command tool 'cdecl'

Thursday, June 4th, 2009

ubuntu8.10设置记录

Sunday, March 1st, 2009

ubuntu8.04设置记录

Wednesday, June 4th, 2008