Category Archives: General

Identifying what is holding up your boot speed in Linux

For a while now, I was not happy with the speed my Debian GNU/Linux booted. It was taking approximately 1:10 minutes to drop me in the GDM prompt. Today, I decided that I will try to probe into what exactly is happening. I have already heard of bootchart a few years ago. However I never had a chance to use it. So, I installed bootchart. I am not going to talk in detail about the installation. It is available in Debian and Ubuntu repositories. If you are using some other distribution, you can either find it in the repository or compile it from the source.

After installation, reboot the system and add 'init=/sbin/bootchartd' to the 'kernel' command line arguments in Grub. This will use bootchartd as init and bootstartd will in turn start the original init. If alternative init environment like init-ng is used, there might be additional arguments needed. Please consult the bootchartd man page for more information. Once the systems boots, the data collected is available in /var/log/bootchart.tgz. Run bootchart to generate bootchart.png from /var/log/bootchart.tgz.

After doing this, I figured out that udevadm is taking almost 30 seconds. I later figured out that the udev rule that tries to rename 'wlan0' to 'eth1' is the culprit (search on Google). Then I commented the 'eth1' line in /etc/udev/rules.d/70-persistent-net.rules, rebooted and did the bootchart thing again. I was happy to see that a portion of around 30 seconds is now removed from my boot time. That’s great!

Before udev fix After udev fix
Bootchart before udev fix Bootchart after udev fix

AT&T Store Apple iPhone 3G preorder status checking

I have pre-ordered Apple iPhone 3G from my neighboring AT&T store last Sunday (Jul 20). I have done this as purchasing from the Apple Store wouldn’t let me to apply my FAN discounts on the plan. Applying it latter would reflect only after a couple of billing cycles. Also I don’t wanna get into the crazy line. I didn’t join the true Apple cult yet. I was just curious about the status of the pre-order and I checked the status online and found that the status query mechanism can be exploited to post automated queries. Here is a small ruby script that I wrote to check bulk statuses. This would also give you a clue on where you are in preorder line.
Read more »

Completely clueless

On my OpenSolaris. What could be more exciting than this?

praveen@athena:~$ /opt/sfw/bin/emacs
Fatal error (11).Segmentation Fault (core dumped)
 
praveen@athena:~$ file core
core:           ELF 32-bit LSB core file 80386 Version 1, from 'emacs'
 
praveen@athena:~$ gdb -c core /opt/sfw/bin/emacs
GNU gdb 6.3.50_2004-11-23-cvs
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-pc-solaris2.11"...(no debugging symbols found)
 
Core was generated by `/opt/sfw/bin/emacs'.
Program terminated with signal 11, Segmentation fault.
Reading symbols from /opt/sfw/lib/libXaw3d.so.5...(no debugging symbols found)...done.
Loaded symbols for /opt/sfw/lib/libXaw3d.so.5
Reading symbols from /usr/lib/libXmu.so...done.
Loaded symbols for /usr/lib/libXmu.so
Reading symbols from /usr/lib/libXt.so.4...done.
Loaded symbols for /usr/lib/libXt.so.4
Reading symbols from /usr/lib/libSM.so.6...done.
Loaded symbols for /usr/lib/libSM.so.6
Reading symbols from /usr/lib/libICE.so.6...done.
Loaded symbols for /usr/lib/libICE.so.6
Reading symbols from /usr/lib/libXext.so.0...done.
Loaded symbols for /usr/lib/libXext.so.0
Reading symbols from /usr/lib/libtiff.so.3...done.
Loaded symbols for /usr/lib/libtiff.so.3
Reading symbols from /usr/lib/libjpeg.so.62...done.
Loaded symbols for /usr/lib/libjpeg.so.62
Reading symbols from /usr/lib/libpng12.so.0...done.
Loaded symbols for /usr/lib/libpng12.so.0
Reading symbols from /lib/libz.so.1...done.
Loaded symbols for /lib/libz.so.1
Reading symbols from /lib/libm.so.2...done.
Loaded symbols for /lib/libm.so.2
Reading symbols from /opt/sfw/lib/libungif.so.4...done.
Loaded symbols for /opt/sfw/lib/libungif.so.4
Reading symbols from /usr/lib/libXpm.so.4...done.
Loaded symbols for /usr/lib/libXpm.so.4
Reading symbols from /usr/lib/libX11.so...Segmentation Fault (core dumped)
 
praveen@athena:~$ file core 
core:           ELF 32-bit LSB core file 80386 Version 1, from 'gdb'

Modifying Control and Caps Lock keys under OpenSolaris and Linux

Since I started using Emacs, I started using the Control key more than I had used it before. That is when I started using my Caps Lock key as Control key. In the beginning, I swapped the Control key and the Caps Lock key. However while doing pair programming on my computer, my colleagues found this setup a bit unfriendly. So, I decided to give up my Caps Lock key and started using Caps Lock as an additional Control key. Under Linux, Gnome has an option to do this using the “Keyboard Preferences” application. However I was not able to find this option in OpenSolaris Gnome. So, I have to take the old xmodmap way of doing this. This works under Linux as well. I hope that this would work on all UNIX variants that uses xmodmap. But I haven’t verified it personally.

To make Caps Lock key as an additional Control key, add the following to .Xmodmap file in your home directory. This configuration is automatically applied when you restart your X (Gnome) session. For the first time, you can manually apply this by running xmodmap ~/.Xmodmap.

!
! Make Caps Lock as an additional Control.
!
remove Lock = Caps_Lock
add Control = Caps_Lock

Please note that ! is the commenting character for xmodmap files.

But if you want to retain the Caps Lock function and swap it back to Control key, add the following to your .Xmodmap file.

!
! Swap Caps Lock and Control.
!
remove Lock = Caps_Lock
remove Control = Control_L
keysym Control_L = Caps_Lock
keysym Caps_Lock = Control_L
add Lock = Caps_Lock
add Control = Control_L

Privacy issue in Chennai Passport Office status enquiry page

I have no affiliation with the Passport Office. I wouldn’t be able to answer any questions about passport statuses. Please don’t ask me about your case.

The site of Regional Passport Office of Chennai has a page to inquire about the passport application case status. If you just enter the passport application file number, the status of the case is provided. The output has information about the full name of the applicant, passport number, date of birth and the date of delivery of the passport. Please note that the input that is needed to fetch this data is just the application file number. No other verification information needed. This is a serious privacy issue. You can’t let your passport number and date of birth to be seen by random people. On the worse side, one can write a script to go through a list of file numbers and collect a database of these valuable information.

If I am correct, when I used this facility in 2003, I had to enter the application file number and my date of birth to fetch the information about any case. This was providing some level of authentication before disclosing the information about a case. Maybe this feature was broken and nobody noticed it. I have sent a mail to the Regional Passport Officer about this issue. I hope that they fix this issue soon.

Dumping core file from set-UID, set-GID ‘ed processes in Linux

Lately I was encountering segmentation fault with one of our processes and found that it was not dumping core file even though we asked it by using appropriate ulimit setting. It was set-UIDed root. Then I discovered that the default behavior of set-UID, set-GID processes is not to dump core unless explicitly asked by prctl(2). In order to dump core, the following has to be done.

prctl( PR_SET_DUMPABLE, 1 );

I haven’t dealt a lot with set-UIDed processes. This was a valuable information to be leaned. Here is more information about this option.

       PR_SET_DUMPABLE
              (Since Linux 2.3.20) Set the  state  of  the  flag  determining
              whether  core dumps are produced for this process upon delivery
              of a signal whose default behavior is to produce a  core  dump.
              (Normally  this flag is set for a process by default, but it is
              cleared when a set-user-ID or set-group-ID program is  executed
              and  also  by various system calls that manipulate process UIDs
              and GIDs).  In kernels up to and including 2.6.12, arg2 must be
              either  0 (process is not dumpable) or 1 (process is dumpable).
              Between kernels 2.6.13 and 2.6.17, the value 2 was also permit‐
              ted, which caused any binary which normally would not be dumped
              to be dumped readable by root only; for security reasons,  this
              feature  has  been  removed.   (See  also  the  description  of
              /proc/sys/fs/suid_dumpable in proc(5).)

Remote file editing on GNU Emacs using TRAMP

I have been using GNU Emacs for programming for nearly 9 years now. It is exciting to keep discovering new extensions to Emacs throughout. I have heard of Ange-FTP before that can be used for remote file editing using FTP. However, I have never tried remote file editing on a local Emacs session. In most of the scenarios, I was dealing with editing files on the remote machines by invoking Emacs locally on those machines. But this time, I felt that invoking GNU Emacs (22) on my tiny VPS would be an overkill. So, I decided to try out remote file editing from a local Emacs session.

Even though I knew that I can do this with AgneFTP, I didn’t really care to read the info about it as I don’t run FTP on my server. The first hit on Google when I searched about remote file editing on Emacs was TRAMP (Transparent Remote [file] Access, Multiple Protocol). I am using GNU Emacs 23 trunk snapshot. TRAMP is included by default in GNU Emacs 22+. Configuration of TRAMP was quite simple. I had to load the module and set the protocol for remote access. Just a two liner in my .emacs did the trick.

(require 'tramp)
(add-to-list 'tramp-default-method-alist '("praveen.kumar.in" "" "ssh"))

The three entries for tramp-default-method-alist element are host, user and protocol. You can fill in the host, the user or both. Another interesting use of TRAMP is editing files as root on local machine. This can be quite handy as well. Take a look at TRAMP user guide for full configuration options. Once I added these lines, I was able to open /home/praveen/.bashrc on my server using the file name as /praveen.kumar.in:~/.bashrc in the normal find-file (C-x C-f) function. Happy remote editing!

Breaking a long silence!

I have been a highly inactive blogger these days. It doesn’t mean that I have too many things to take care of. For some reason, I felt that I lost interest in blogging for some time now. Every week I would have found at least a couple things to write about. I would also start a new post. However, I would end up canceling it after I had typed a few lines. Maybe I turned too lazy to write something. But not anymore! I decided to break the long period of inactivity.

As a part of the new start, I have just upgraded my journal to use WordPress 2.5. I have also decided to throw away my old clumsy theme. I temporarily use the “WordPress Classic” theme. I am planning to tweak the same theme to match my color preferences. I am also thinking if I should try modifying the “WordPress Default” theme to use fluid width and use it. But I won’t be doing it before next weekend. I would reserve a couple of posts to talk about WordPress 2.5 and my thoughts about WordPress theming.

What it means is that you (looks like I have at least 10 regular readers of my blog still) would be seeing regular activities in my journal from now on. I am also curious to know about the ones who are subscribed to my feed. If you don’t mind, please leave me a comment. Thanks for your support, readers!

What a lousy weekend!

Lousy

CppUnit CompilerOutputter error output and Emacs

I am casually evaluating CppUnit lately. It is pretty good. I was using the CompileOutputter as the outputter for CppUnit tests. However, the default settings for gcc is not Emacs friendly for multi-directory projects. To overcome this, I had to set the location format of the CompilerOuputter to "%p:%l:".

CppUnit::CompilerOutputter *outputter = new CppUnit::CompilerOutputter( &runner.result(), std::cerr );
outputter->setLocationFormat( "%p:%l:" );
runner.setOutputter( outputter  );
bool wasSuccessful = runner.run();

I didn’t see any other documentation for this apart from the CompilerOutputter.h itself that says the following.

/* The location format is a string in which the occurence of the following character
 * sequence are replaced:
 *
 * - "%l" => replaced by the line number
 * - "%p" => replaced by the full path name of the file ("G:\\prg\\vc\\cppunit\\MyTest.cpp")
 * - "%f" => replaced by the base name of the file ("MyTest.cpp")
 */