Here are some gcc extensions syntax in the linux kernel.
1. typeof(VARIABLE): You can find this at list_head related macros
2.range extension
3.zero-length arrays. IEEE 1394.
4. __builtin_expect. Layer II entry point use likely() and unlikely()
5.__builtin_prefetch. You can find this at list_head related macros
More details, visit IBM developer works
FYI:
IBM GCC hacks in the linux kernel
Tuesday, December 02, 2008
Wednesday, November 26, 2008
run or cancel autoexec.bat at windows nt/xp/vista
From Microsoft INFO: Configuring Parsing of the AUTOEXEC.BAT File Q124551
FYI:
http://support.microsoft.com/kb/124551/en-us/
Modify the following value within HKEY_CURRENT_USER:
Software\Microsoft\Windows NT\CurrentVersion\Winlogon\ParseAutoexec
1 = autoexec.bat is parsed
0 = autoexec.bat is not parsed
FYI:
http://support.microsoft.com/kb/124551/en-us/
Tuesday, November 25, 2008
doxygen addon- Moritz
If you need more template for output document of doxygen, try this open source-Moritz.
FYI:
http://sourceforge.net/projects/moritz
FYI:
http://sourceforge.net/projects/moritz
Monday, October 20, 2008
Communication over ethernet mac layer without TCP/IP part 1
I use two different o.s. at a embedded system. Altohough, there are so many solutations such as broadcast, IP sockets, non-reliable IP-less protocol and so on, but they can not meet our requerments.
Here are my concept:
A protocol must base on ethernet layer II and has capability to do TCP-friendly stuff. The requerments are below:
Here are my concept:
A protocol must base on ethernet layer II and has capability to do TCP-friendly stuff. The requerments are below:
- Can set or get system parameter between A and B.
- This protocol must be extendable from dual systems to multiple systems.
- It can not fix at client and server mode. These two (or more) system can be client and server at the same time.
- We can transfer large file or multipart request/response over a transaction. And the upper layer applications do not have to worry about fragmentations.
- This protocol must provide Event/Notify. A could register events which is occurred at B. After registation, B must send notify while some events happened.
- How to define session and transations?
- How to encoding payload ?
- How to implement re-transmit ?
- others
Tuesday, October 14, 2008
Change pipe to non-blocking mode
The default pipe(...) is one blocking fd. If you need non-blocking IO, you can refer fowling sample code:
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
int main(void) {
int fd[2], pipeAttr;
/*fd[0] for reader, fd[1] for writer*/
pipe(fd);
fnctl(fd[0], pipeAttr, F_GETFL);
pipeAttr |= O_NONBLOCK;
fnctl(fd[0], F_SETFL,
pipeAttr);
do_something(fd);
close(fd[0]);
close(fd[1]);
}
viod do_something(int fd[]) {
/*......*/
}
Zombie while create child thread
I use pthread_create(...) to generate child thread. The child thread becomes zombie after I termite program. After some "google" pages, the answer comes out: join child thread at main process.
errno.h
If you want to use errno at c program, you must include errno.h not declare "extern int errno".
char *strerror(int) is used to display error text.
There are two related header files at kernel source directory:
include/$(ARCH)/errno.h
asm-generic/errno-base.h
char *strerror(int) is used to display error text.
There are two related header files at kernel source directory:
include/$(ARCH)/errno.h
asm-generic/errno-base.h
Thursday, July 24, 2008
10 essential tricks for admins from IBM
Vallard Benincosa posted article about how to administrate linux. Here are one of ticks:
FYI:
Lazy Linux: 10 essential tricks for admins (http://www.ibm.com/developerworks/linux/library/l-10sysadtips/index.html)
Trick 3: Collaboration with screen
David, the high-maintenance user from product engineering, calls: "I need you to help me understand why I can't compile supercode.c on these new machines you deployed."
"Fine," you say. "What machine are you on?"
David responds: " Posh." (Yes, this fictional company has named its five production servers in honor of the Spice Girls.) OK, you say. You exercise your godlike root powers and on another machine become David:
# su - david
Then you go over to posh:
# ssh posh
Once you are there, you run:
# screen -S foo
Then you holler at David:
"Hey David, run the following command on your terminal: # screen -x foo."
This will cause your and David's sessions to be joined together in the holy Linux shell. You can type or he can type, but you'll both see what the other is doing. This saves you from walking to the other floor and lets you both have equal control. The benefit is that David can watch your troubleshooting skills and see exactly how you solve problems.
At last you both see what the problem is: David's compile script hard-coded an old directory that does not exist on this new server. You mount it, recompile, solve the problem, and David goes back to work. You then go back to whatever lazy activity you were doing before.
The one caveat to this trick is that you both need to be logged in as the same user. Other cool things you can do with the screen command include having multiple windows and split screens. Read the man pages for more on that.
But I'll give you one last tip while you're in your screen session. To detach from it and leave it open, type: Ctrl-A D . (I mean, hold down the Ctrl key and strike the A key. Then push the D key.)
You can then reattach by running the screen -x foo command again.
FYI:
Lazy Linux: 10 essential tricks for admins (http://www.ibm.com/developerworks/linux/library/l-10sysadtips/index.html)
Monday, June 30, 2008
Wine
I need to use IE sometimes, and there is one thing, I should run IE on Linux. The first thought is "Setup a Microsoft windows", but I do not setup one. So, I need a package to be a VM or provide Windows API on Linux. Finally, Wine is my best choose.
By Wine, it is easy for you to use windows applications on Linux platform. Here are inductions from Wine web site:
FYI:
http://www.winehq.org/
By Wine, it is easy for you to use windows applications on Linux platform. Here are inductions from Wine web site:
Wine is an Open Source implementation of the Windows API on top of X, OpenGL, and Unix.
Think of Wine as a compatibility layer for running Windows programs. Wine does not require Microsoft Windows, as it is a completely free alternative implementation of the Windows API consisting of 100% non-Microsoft code, however Wine can optionally use native Windows DLLs if they are available. Wine provides both a development toolkit for porting Windows source code to Unix as well as a program loader, allowing many unmodified Windows programs to run on x86-based Unixes, including Linux, FreeBSD, Mac OS X, and Solaris.
More information can be read in the articles Why Wine is so important, and Debunking Wine Myths. If you are wondering how well a particular application works in Wine, please examine the Applications Database. For installation instructions and step-by-step help with running Wine, take a look at the User Guide.
Wine is free software. The licensing terms are the GNU Lesser General Public License version 2.1.
FYI:
http://www.winehq.org/
Monday, June 16, 2008
Software generator
I find some software generators.
For Linux:
I only try CommView. There is a version for evaluation. You can use tcpdump formated file as source too.
For Linux:
- packETH : GUI-based. So, I need X windows system to use this package. You can edit your won packet or load a tcpdump-formated file as source.
- scapy: text-based, Write by Python. You have to install python 2.4 or above version. If you need some extra feature, you also need to install gnuplot library, gnuplot-py, numpy, and PyX.
I only try CommView. There is a version for evaluation. You can use tcpdump formated file as source too.
Thursday, June 12, 2008
Saturday, May 17, 2008
Chang default IGMP version in Linux
Set default IGMP version of your NICs is 2:
echo 2 > /proc/sys/net/ipv4/conf/all/force_igmp_version
Set default IGMP version of your NICs is 3:
echo 3 > /proc/sys/net/ipv4/conf/all/force_igmp_version
echo 2 > /proc/sys/net/ipv4/conf/all/force_igmp_version
Set default IGMP version of your NICs is 3:
echo 3 > /proc/sys/net/ipv4/conf/all/force_igmp_version
jiffies comparison
If you want to compare time in kernel module, you can user flowing macro to avoid jiffies overflow :
/*in kernel/linux/include/linux/jiffies.h*/
time_after(a,b)
time_before(a,b)
time_after_eq(a,b)
time_before_eq(a,b)
If you compare jiffies directly, you will get wrong result sometimes.
/*in kernel/linux/include/linux/jiffies.h*/
time_after(a,b)
time_before(a,b)
time_after_eq(a,b)
time_before_eq(a,b)
If you compare jiffies directly, you will get wrong result sometimes.
Monday, February 18, 2008
Ask user change password at first login
After you add a user and set default password. If you want to this user change his/her password at first time login, there are some command you can issue:
1.usermod -L USERNAME
2.chage -d 0 USERNAME
3.usermod -U USERNAME
FYI:
Red Hat Knowledgebase
1.usermod -L USERNAME
2.chage -d 0 USERNAME
3.usermod -U USERNAME
FYI:
Red Hat Knowledgebase
Thursday, January 24, 2008
group file and shadow file
I manually modify /etc/group file, so the shadow file does not up-to-date. The will be fine when I use this server, but if I edit user/group information by GUI tool, it will pop up complain message. There are some commands to solve this problem pwconv, pwunconv, grpconv, and grpunconv. From man page, you can totally know how to use it.
FYI:
pwconv creates shadow from passwd and an optionally existing shadow.
pwunconv creates passwd from passwd and shadow and then removes shadow.
grpconv creates gshadow from group and an optionally existing gshadow.
grpunconv creates group from group and gshadow and then removes
FYI:
pwconv creates shadow from passwd and an optionally existing shadow.
pwunconv creates passwd from passwd and shadow and then removes shadow.
grpconv creates gshadow from group and an optionally existing gshadow.
grpunconv creates group from group and gshadow and then removes
Thursday, January 17, 2008
Outlook signatures
The files of signatures are placed in:
Folder: Documents and Settings\$USERNAME\Application Data\Microsoft\Signatures
Folder: Documents and Settings\$USERNAME\Application Data\Microsoft\Signatures
Sunday, January 13, 2008
PHP permission denied
If you use SeLinux, there is a little bit modification. Because the security problmes, you must tell your system that which modules is trusted. After you run "apachectl start" and the unhappy error shows below:
XXXX. PHP5 cannot restore segment prot afterreloc: Permission denied
You should disable SELinux or issue "chcon -t texrel_shlib_t /usr/local/apache2/modules/*.so"
XXXX. PHP5 cannot restore segment prot afterreloc: Permission denied
You should disable SELinux or issue "chcon -t texrel_shlib_t /usr/local/apache2/modules/*.so"
Monday, January 07, 2008
Translate Decimal / IP dotted quad
Here are simple functions to translate decimal/ip dotted quad in python.
Usage:
>dot2dec("64.233.189.99")
1089060195L
>dec2dot(1089060195L)
'64.233.189.99'
>
FYI:
python google group
Usage:
>dot2dec("64.233.189.99")
1089060195L
>dec2dot(1089060195L)
'64.233.189.99'
>
import types
def dot2dec(ipForm, useHex = False):
if type(ipForm) == types.StringType:
ipf = ipForm.split(".")
elif type(ipForm) in (types.ListType, types.TupleType):
ipf = ipForm
elif type(ipForm) in (types.LongType, types.IntType):
return None
return reduce(lambda a,b: long(a)*256 + long(b), ipf)
def dec2dot(numbericIP):
if type(numbericIP) == types.StringType and not numbericIP.isdigit() :
return None
numIP = long(numbericIP)
return "%d.%d.%d.%d" % ((numIP>>24)&0xFF, (numIP>>16)&0xFF, (numIP>>8)&0xFF, numIP&0xFF)
FYI:
python google group
Thursday, January 03, 2008
Chang default IGMP version in windows
The default version of IGMP in windows XP is Version 3. If you want to change to version 2, please flowing setups below:
1.Add new filed in registries and set default value is 3:
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters]
"IGMPVersion"=dword:00000003
2.reboot
1.Add new filed in registries and set default value is 3:
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters]
"IGMPVersion"=dword:00000003
2.reboot
CaptureSetup VLAN tags
These days, network adapter becomes more and more smart. It filters VLAN tags automatic, so you can not read this filed from packet filter such as Wireshark. If your network adapter is old or simple enough, you do not have to worry about this problem otherwise, you should add extra variable at your registries within your windows.For example, If you use Broadcom NIC, you need to do flowing steps below:
1.Find TxCoalescingTicks.
2.Add new string value which named PreserveVlanInfoInRxPacket and default value is 1.
3.Reboot.
FYI:
The Wireshark CaptureSetup VLAN
1.Find TxCoalescingTicks.
2.Add new string value which named PreserveVlanInfoInRxPacket and default value is 1.
3.Reboot.
FYI:
The Wireshark CaptureSetup VLAN
Apache POI
Apache announce new release of POI. Current version is 3.01 beta. POI is java implementation of the OLE 2 compound document format.
FYI:
Apache POI project
FYI:
Apache POI project
Subscribe to:
Posts (Atom)