Development Experience of a senior Linux program developer

Source: Internet
Author: User
Tags ftp site
A senior Linux program developer's development experience-general Linux technology-Linux programming and kernel information. The following is a detailed description. Sppence Murray is one of the Linux developers and has long been a strong supporter of UNIX. This article describes the basic technology used by Murray and his colleagues in Codemonks Consulting in daily Linux development and application service work: shell script, I believe that all Linux developers will benefit from this useful and common technology.


Spence Murray is one of the founders of Codemonks Consulting. Since the earliest code written on SunOS in 1980s, Spence Murray has been committed to UNIX/Linux development. Since then, he has worked in IBM's AIX and SGI Irix to write cross-platform UNIX code for a long time, including HP/UX, Irix, Solaris/SunOS, sco unix, various BSD, MacOS X, and of course Linux. He has done everything from graphics/Video device drivers to UI code. The cross-platform Code Compiled by Murray includes the X Window System Xserver code and the core browser code as part of Netscape Navigator.

The most common Linux tools used by Murray are vi, bash, and Emacs. "Whether I am writing C, C ++, Java, shell scripts, or HTML, I switch back and forth among these tools most of the time," he said.


Linux secret weapon

Murray believes that for a Linux developer, shell is a powerful software development tool, which is not rated as much. "In every job I do, I need to use shell scripts to quickly read and modify common text or write code," he said. "It's lightweight and fast, and its short Command makes moving code back and forth a fast and painless process. As an editor, it will soon become the second instinct ".

For Murray, Emacs emerged later as a development tool. "In the early 1990s S, I tried to use Emacs as an IDE and soon switched to the foyer. Emacs is very powerful. In those days, I will always open an Emacs window and often open dozens of source files, each has the context I edited, the debugging session using gdb, And the bash script running in different source directories. There is a lot of information about Emacs, which can be said to be a terrible tool... In addition, you can run Emacs on any system that you want to spend time developing.

Since the first time using the simple environment vi supported by SunOS In The Middle Of 1980s, the Emacs editor has become a standard tool for Murray. "It can be used on UNIX of various genres, which is one of the main reasons I chose for cross-platform development," he said.


Linux developers: Understand your shell

Murray requires that you understand your shell. "Bash, tcsh, csh ?? Shell is your most basic software development tool, "he stressed. "It can do a lot of amazing things. All work depends on it ...... And its powerful functions ". As an example to illustrate the powerful functions of common shell scripts, there is a file that can be downloaded in the references section, including a set of scripts, used to obtain updated RPM packages released by Red Hat and merge them into the original and customized packages. After downloading and decompressing the file, you can find the script in the/developerworks/rpm_update_scripts directory. The final result is a directory that includes the latest version of all software packages and an hdlist file for network installation upgrades.

The following code snippet implements automatic updates to the Red Hat RPM package to create an installable version that uses the latest RPM. This is a basic step for anyone who maintains a public Linux server. For us, we usually maintain a large number of network services on many public Linux servers. The following are some scripts that can automatically update the latest security and functions.

The script below demonstrates that common shell programming technology can be widely used in various system configurations and program design applications. The script uses the bourne shell, which is the most common shell in different UNIX systems. This ensures that these very lightweight codes can be slightly modified or used on different UNIX systems without modification. It is easy to modify the Red Hat software package specification to apply it to other Linux releases.

Freshen. sh update the RPM package on the site using the specified RPM ftp to update the original RPM list. Execute the filter to replace the updated RPM package. Finally, the long release list is updated based on the new RPM Software Package obtained from the image Update site.


Listing 1. fresh. sh


#! /Bin/sh
Rh_ver = $1
Rh_path = $2
Update_dir =$ {rh_path}/RH $ {rh_ver}-updates
Custom_dir =$ {rh_path}/RH $ {rh_ver}-custom
Install_dir =$ {rh_path}/RH $ {rh_ver}-install

# Sanity check for the original directory.

# Create update and install directories if they don't exist

[-D $ {update_dir}] | mkdir $ {update_dir}
[-D $ {install_dir}/RedHat/RPMS] | mkdir-p $ {install_dir}/RedHat/RPMS

# Get latest updates from fresh rpms FTP site

./Get_update.sh $ {rh_ver }$ {update_dir}

# Create/update hardlinks from update, and custom directories
# To the install directory. We assume that original RPMS are already
# Hardlinked to the install directory, so all we need to do is filter
# Out any replaced by updated packages.

./Do-links.sh $ {update_dir }$ {install_dir}/RedHat/RPMS
[-D $ {custom_dir}] &./do-links.sh $ {custom_dir}
$ {Install_dir}/RedHat/RPMS

# Filter out all but the latest version of everything.

/Filter-rpms.pl $ install_dir/RedHat/RPMS

# Rebuild the hard disk lists
/Usr/lib/anaconda-runtime/genhdlist $ {install_dir}



Freshen. sh calls the do-links.sh and get_update.sh to set the source, destination (omitted from the source RPM package; hard link used to set the target RPM), and retrieve updates, respectively.

Listing 2. do-links.sh


#! /Bin/sh

Src = $1
Dest = $2

# For file in $ src/*; do
For file in 'Find $ src-name *. rpm-! -Name *. src. rpm-print '; do
Base = 'basename $ file ;'
If test! -F $ dest/$ base; then
Echo "Linking $ file ";
Ln $ file $ dest
Else
Echo "EXISTS: $ file ";
Fi
Done


Listing 3. get_update.sh


#! /Bin/sh
Rh_ver = $1
Dest = $2
Echo "Retrieving updates for version $ {rh_ver} to $ dest"
Lftp <EOF
Open ftp.freshrpms.net

Mirror-n pub/redhat/linux/updates/$ {rh_ver}/en/OS/i386 $ dest/i386
Mirror-n pub/redhat/linux/updates/$ {rh_ver}/en/OS/IST $ dest/IST
Mirror-n pub/redhat/linux/updates/$ {rh_ver}/en/OS/i586 $ dest/i568
Mirror-n pub/redhat/linux/updates/$ {rh_ver}/en/OS/i686 $ dest/i686
Mirror-n pub/redhat/linux/updates/$ {rh_ver}/en/OS/SRPMS $ dest/SRPMS
Mirror-n pub/redhat/linux/updates/$ {rh_ver}/en/OS/noarch $ dest/noarch

Java and Linux

In Codemonks, a lot of development work is completed in Java on Linux. The combination of these two tools provides a platform for creating commercial-quality Web applications, Murray said. "In the process of doing these projects, we found that we need to understand the customer's existing application code as a whole," he recalled. Locks. c (in the/developerworks/locks directory of the compressed file downloaded) is a code snippet for Java Virtual Machine Profiler Interface (JVMPI) read/write locks and a large amount of debugging code.

Representatives of Linux developers

"Do not write system-specific code when the situation permits," Murray said. Instead, he overcame the difficulty by "Writing cross-platform code ". The hired Murray insists that his biggest capital will always be "to write code with commercial quality, to build and provide network services, to customize the OS or kernel, and it is completely based on a reliable open-source platform ".

The following is a code snippet from a cross-platform custom IMAP server developed by developers of Linux and MacOS X. The Code implements a simple growth cache for processing strings. This avoids cache overflow (do not forget those security vulnerabilities), and does not need to be re-allocated every time you do something. It is implemented by maintaining a simple variable-length cache, which can be full or cleared. This cache has been used by an IMAP server for an experiment. This server is completed by a team after a week of intense work.

In addition to the implementation of a simple string buffer, this code also implements a variable-Size String Array. It completes a simple interface. After writing a string, you can mark it and continue writing the next one. In addition, this will save space allocation and organize messy Code together.

The complete IMAP server code will be released some time this year.


Listing 4. Part of the custom IMAP Server


# Ifndef HOED_BUF_H
# Define HOED_BUF_H

Typedef struct {
Char * str;
Int size;
Int length;
Int str_start;
Int max_size;

Int n_strings;
Int size_strings;
Int * str_posn;
Char ** str_set;
} Hoed_buf_t;

# If _ GNUC _> 2 | (_ GNUC _ = 2 & _ GNUC_MINOR _> 4)
# Define PRINTF (f, a) _ attribute _ (format (printf, f, )))
# Else
# Define PRINTF (f,)
# Endif

Extern hoed_buf_t * hoed_buf_alloc (int init_size, int max_size );
Extern void hoed_buf_free (hoed_buf_t *);
Extern void hoed_buf_reset (hoed_buf_t *);
Extern void hoed_buf_new_string (hoed_buf_t *);
Extern char ** hoed_buf_get_set (hoed_buf_t *, int * n_string );

Extern char * hoed_buf_put_char (hoed_buf_t *, char toadd );
Extern char * hoed_buf_sprintf (hoed_buf_t *, const char * format ,...)
PRINTF (2, 3 );
Extern char * hoed_buf_strcat (hoed_buf_t *, const char * append );
Extern char * hoed_buf_cat_sprintf (hoed_buf_t *, const char * format ,...)
PRINTF (2, 3 );

# Endif/* HOED_BUF_H */



A killer Linux Application

For Murray, there are two killer Linux applications: Emacs and Netscape Navigator. "Emacs may be the most impressive and widely used Linux-based application," he said. "The other is Netscape Navigator. Once, we wanted to support more than 20 types of UNIX, and I finished all the work on Linux ".

"What's interesting is that Linux-based applications may run on many different UNIX systems or even install Cygwin Windows systems," he continued ."

What is the future of Linux?

Currently, Murray is working on several Linux projects, from Distributed Office applications supporting email, messages, and shared databases to network applications using standard tools (standard tools include: apache/Tomcat, PHP, PostgreSQL, MySQL, and Linux ). Murray has his own company dedicated to providing host services for network services and network applications.

For Murray, the list of Linux-powered applications is growing. "There are many," he said. "The list of Oracle, WebSphere, Apache, PostgresQL, MySQL, Cyrus IMAP... is very long and growing ."

For Murray, this is the end of Linux. "All our servers run Linux. Regardless of the target platform, our main development is on Linux. We recommend Linux to users to run server applications," he said. "The pace of rapid development of Linux, the wide support of open source code organizations, and low development costs. If you combine these, you will know that Linux is a platform that is hard to beat ".
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.