Skip to content

Commit 3feeaeb

Browse files
committed
1 parent 13d6ca8 commit 3feeaeb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+167758
-0
lines changed

AUTHORS.sh

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#! /bin/sh
2+
3+
# Create the AUTHORS file, by searching the git history.
4+
5+
# Run as "AUTHORS.sh" to get complete history
6+
# Run with "AUTHORS.sh commitish..commitish" for history between tags
7+
8+
# shortlog will canonicalize the names using the file .mailmap
9+
git shortlog -s ${1-} |
10+
cut -b8- # strip the commit counts

Makefile

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
#
2+
# Makefile for the FREAX-kernel.
3+
#
4+
# Note! Dependencies are done automagically by 'make dep', which also
5+
# removes any old dependencies. DON'T put your own dependencies here
6+
# unless it's something special (ie not a .c file).
7+
#
8+
9+
AR =ar
10+
AS =as --32
11+
LD =ld
12+
LDFLAGS = -x -m elf_i386
13+
CC =gcc -m32
14+
CFLAGS = -g -Wall -O -fstrength-reduce -fomit-frame-pointer -fno-stack-protector \
15+
-finline-functions -nostdinc -I../include
16+
CPP =gcc -E -nostdinc -I../include
17+
18+
.c.s:
19+
$(CC) $(CFLAGS) \
20+
-S -o $*.s $<
21+
.s.o:
22+
$(AS) -o $*.o $<
23+
.c.o:
24+
$(CC) $(CFLAGS) \
25+
-c -o $*.o $<
26+
27+
OBJS = sched.o system_call.o traps.o asm.o fork.o \
28+
panic.o printk.o vsprintf.o sys.o exit.o \
29+
signal.o mktime.o
30+
31+
kernel.o: $(OBJS)
32+
$(LD) $(LDFLAGS) -r -o kernel.o $(OBJS)
33+
sync
34+
35+
clean:
36+
rm -f core *.o *.a tmp_make keyboard.s
37+
for i in *.c;do rm -f `basename $$i .c`.s;done
38+
(cd chr_drv; make clean)
39+
(cd blk_drv; make clean)
40+
(cd math; make clean)
41+
42+
dep:
43+
sed '/\#\#\# Dependencies/q' < Makefile > tmp_make
44+
(for i in *.c;do echo -n `echo $$i | sed 's,\.c,\.s,'`" "; \
45+
$(CPP) -M $$i;done) >> tmp_make
46+
cp tmp_make Makefile
47+
(cd chr_drv; make dep)
48+
(cd blk_drv; make dep)
49+
50+
### Dependencies:
51+
exit.s exit.o: exit.c ../include/errno.h ../include/signal.h \
52+
../include/sys/types.h ../include/sys/wait.h ../include/linux/sched.h \
53+
../include/linux/head.h ../include/linux/fs.h ../include/linux/mm.h \
54+
../include/linux/kernel.h ../include/linux/tty.h ../include/termios.h \
55+
../include/asm/segment.h
56+
fork.s fork.o: fork.c ../include/errno.h ../include/linux/sched.h \
57+
../include/linux/head.h ../include/linux/fs.h ../include/sys/types.h \
58+
../include/linux/mm.h ../include/signal.h ../include/linux/kernel.h \
59+
../include/asm/segment.h ../include/asm/system.h
60+
mktime.s mktime.o: mktime.c ../include/time.h
61+
panic.s panic.o: panic.c ../include/linux/kernel.h ../include/linux/sched.h \
62+
../include/linux/head.h ../include/linux/fs.h ../include/sys/types.h \
63+
../include/linux/mm.h ../include/signal.h
64+
printk.s printk.o: printk.c ../include/stdarg.h ../include/stddef.h \
65+
../include/linux/kernel.h
66+
sched.s sched.o: sched.c ../include/linux/sched.h ../include/linux/head.h \
67+
../include/linux/fs.h ../include/sys/types.h ../include/linux/mm.h \
68+
../include/signal.h ../include/linux/kernel.h ../include/linux/sys.h \
69+
../include/linux/fdreg.h ../include/asm/system.h ../include/asm/io.h \
70+
../include/asm/segment.h
71+
signal.s signal.o: signal.c ../include/linux/sched.h ../include/linux/head.h \
72+
../include/linux/fs.h ../include/sys/types.h ../include/linux/mm.h \
73+
../include/signal.h ../include/linux/kernel.h ../include/asm/segment.h
74+
sys.s sys.o: sys.c ../include/errno.h ../include/linux/sched.h \
75+
../include/linux/head.h ../include/linux/fs.h ../include/sys/types.h \
76+
../include/linux/mm.h ../include/signal.h ../include/linux/tty.h \
77+
../include/termios.h ../include/linux/kernel.h ../include/asm/segment.h \
78+
../include/sys/times.h ../include/sys/utsname.h
79+
traps.s traps.o: traps.c ../include/string.h ../include/linux/head.h \
80+
../include/linux/sched.h ../include/linux/fs.h ../include/sys/types.h \
81+
../include/linux/mm.h ../include/signal.h ../include/linux/kernel.h \
82+
../include/asm/system.h ../include/asm/segment.h ../include/asm/io.h
83+
vsprintf.s vsprintf.o: vsprintf.c ../include/stdarg.h ../include/string.h

ascii

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env bash
2+
3+
for i in {0..127}; do
4+
p=$(printf "%3d" $i)
5+
ox=$(printf "%2x" $i)
6+
echo -e "${p:-3} ${ox} \\0$(($i/64*100+$i%64/8*10+$i%8))";
7+
done | cat -t | column -c 80
8+

backupMysql.sh

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/env bash
2+
# backupMysql.sh: backup mysql databases and keep newest 5 days backup.
3+
# restore db(test) use the follow command:
4+
# $ gzip < test.2014-04-09.gz | /home/mysql/mysql/bin/mysqldump -uroot -p test
5+
# -----------------------------
6+
7+
db_user="root";
8+
db_passwd="xxxxx";
9+
db_host="localhost";
10+
11+
# the directory for story your backup file.
12+
backup_dir="/home/xxxx/mysqlbackup";
13+
14+
# date format for backup file (yyyy-mm-dd)
15+
# or time="$(date +"%Y-%m-%d_%H:%M:%S")"
16+
time="$(date +"%Y-%m-%d")";
17+
18+
# mysql, mysqldump and some other bin's path
19+
MYSQL="$(which mysql)";
20+
MYSQL="${MYSQL:-/home/mysql/mysql/bin/mysql}";
21+
MYSQLDUMP="$(which mysqldump)";
22+
MYSQLDUMP="${MYSQLDUMP:-/home/mysql/mysql/bin/mysqldump}";
23+
MKDIR="$(which mkdir)";
24+
RM="$(which rm)";
25+
MV="$(which mv)";
26+
GZIP="$(which gzip)";
27+
28+
# the directory for story the newest backup
29+
test ! -d "$backup_dir" && $MKDIR -p "$backup_dir";
30+
# check the directory for store backup is writeable
31+
test ! -w $backup_dir && echo "Error: $backup_dir is un-writeable." && exit 1;
32+
33+
# get all databases
34+
####for loop, mysqldump backup db for (db1/db2...), backup the data to $backup_dir/$time.$db.gz
35+
for db in highcharts mysql
36+
do
37+
$MYSQLDUMP -u $db_user -h $db_host -p$db_passwd $db | $GZIP -9 > "$backup_dir/$db.$time.gz";
38+
done
39+
40+
#delete the oldest backup 30 days ago
41+
find $backup_dir -name "*.gz" -mtime +30 |xargs rm -rf
42+
43+
exit 0;

bashdebug/bashdb.fns

+237
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,237 @@
1+
2+
# After each line of the test script is executed the shell traps to
3+
# this function.
4+
5+
function _steptrap
6+
{
7+
_curline=$1 # the number of the line that just ran
8+
9+
(( $_trace )) && _msg "$PS4 line $_curline: ${_lines[$_curline]}"
10+
11+
if (( $_steps >= 0 )); then
12+
let _steps="$_steps - 1"
13+
fi
14+
15+
# first check to see if a line number breakpoint was reached,
16+
# if it was then enter the debugger
17+
if _at_linenumbp ; then
18+
_msg "Reached breakpoint at line $_curline"
19+
_cmdloop
20+
21+
# it wasn't, so check whether a break condition exists and is true
22+
# if it is then enter the debugger
23+
elif [ -n "$_brcond" ] && eval $_brcond; then
24+
_msg "Break condition $_brcond true at line $_curline"
25+
_cmdloop
26+
27+
# it wasn't, so check if we are in step mode and the number of steps is up
28+
# if it is then enter the debugger
29+
elif (( $_steps == 0 )); then
30+
_msg "Stopped at line $_curline"
31+
_cmdloop
32+
fi
33+
}
34+
35+
36+
# The Debugger Command Loop
37+
38+
function _cmdloop {
39+
local cmd args
40+
41+
while read -e -p "bashdb> " cmd args; do
42+
case $cmd in
43+
\? | h ) _menu ;; # print command menu
44+
bc ) _setbc $args ;; # set a break condition
45+
bp ) _setbp $args ;; # set a breakpoint at the given line
46+
cb ) _clearbp $args ;; # clear one or all breakpoints
47+
ds ) _displayscript ;; # list the script and show the breakpoints
48+
g ) return ;; # "go": start/resume execution of the script
49+
q ) exit ;; # quit
50+
s ) let _steps=${args:-1} # single step N times (default = 1)
51+
return ;;
52+
x ) _xtrace ;; # toggle execution trace
53+
\!* ) eval ${cmd#!} $args ;; # pass to the shell
54+
* ) _msg "Invalid command: '$cmd'" ;;
55+
esac
56+
done
57+
}
58+
59+
60+
# See if this line number has a breakpoint
61+
function _at_linenumbp
62+
{
63+
local i=0
64+
65+
# Loop through the breakpoints array and check to see if any of
66+
# them match the current line number. If they do return true (0)
67+
# otherwise return false.
68+
69+
if [ "$_linebp" ]; then
70+
while (( $i < ${#_linebp[@]} )); do
71+
if (( ${_linebp[$i]} == $_curline )); then
72+
return 0
73+
fi
74+
let i=$i+1
75+
done
76+
fi
77+
return 1
78+
}
79+
80+
81+
# Set a breakpoint at the given line number or list breakpoints
82+
function _setbp
83+
{
84+
local i
85+
86+
# If there are no arguments call the breakpoint list function.
87+
# Otherwise check to see if the argument was a positive number.
88+
# If it wasn't then print an error message. If it was then check
89+
# to see if the line number contains text. If it doesn't then
90+
# print an error message. If it does then echo the current
91+
# breakpoints and the new addition and pipe them to "sort" and
92+
# assign the result back to the list of breakpoints. This results
93+
# in keeping the breakpoints in numerical sorted order.
94+
95+
# Note that we can remove duplicate breakpoints here by using
96+
# the -u option to sort which uniquifies the list.
97+
98+
if [ -z $1 ]; then
99+
_listbp
100+
elif [ $(echo $1 | grep '^[0-9]*') ]; then
101+
if [ -n "${_lines[$1]}" ]; then
102+
_linebp=($(echo $( (for i in ${_linebp[*]} $1; do
103+
echo $i; done) | sort -n) ))
104+
_msg "Breakpoint set at line $1"
105+
else
106+
_msg "Breakpoints can only be set on non-blank lines"
107+
fi
108+
else
109+
_msg "Please specify a numeric line number"
110+
fi
111+
}
112+
113+
114+
# List breakpoints and break conditions
115+
function _listbp
116+
{
117+
if [ -n "$_linebp" ]; then
118+
_msg "Breakpoints at lines: ${_linebp[*]}"
119+
else
120+
_msg "No breakpoints have been set"
121+
fi
122+
123+
_msg "Break on condition:"
124+
_msg "$_brcond"
125+
}
126+
127+
128+
# Clear individual or all breakpoints
129+
function _clearbp
130+
{
131+
local i
132+
133+
# If there are no arguments then delete all the breakpoints.
134+
# Otherwise check to see if the argument was a positive number.
135+
# If it wasn't then print an error message. If it was then
136+
# echo all of the current breakpoints except the passed one.
137+
# Then destroy the old array and assign the elements of
138+
# the local array so we effectively recreate it, minus the passed
139+
# breakpoint.
140+
141+
if [ -z $1 ]; then
142+
unset _linebp[*]
143+
_msg "All breakpoints have been cleared"
144+
elif [ $(echo $1 | grep '^[0-9]*') ]; then
145+
_linebp=($(echo $(for i in ${_linebp[*]}; do
146+
if (( $1 != $i )); then echo $i; fi; done) ))
147+
_msg "Breakpoint cleared at line $1"
148+
else
149+
_msg "Please specify a numeric line number"
150+
fi
151+
}
152+
153+
154+
# Set or clear a break condition
155+
function _setbc
156+
{
157+
if [ -n "$*" ]; then
158+
_brcond=$args
159+
_msg "Break when true: $_brcond"
160+
else
161+
_brcond=
162+
_msg "Break condition cleared"
163+
fi
164+
}
165+
166+
167+
# Print out the shell script and mark the location of breakpoints
168+
# and the current line
169+
170+
function _displayscript
171+
{
172+
local i=1 j=0 bp cl
173+
174+
( while (( $i < ${#_lines[@]} )); do
175+
if [ ${_linebp[$j]} ] && (( ${_linebp[$j]} == $i )); then
176+
bp='*'
177+
let j=$j+1
178+
else
179+
bp=' '
180+
fi
181+
if (( $_curline == $i )); then
182+
cl=">"
183+
else
184+
cl=" "
185+
fi
186+
echo "$i:$bp $cl ${_lines[$i]}"
187+
let i=$i+1
188+
done
189+
) | more
190+
}
191+
192+
193+
# Toggle execution trace on/off
194+
function _xtrace
195+
{
196+
let _trace="! $_trace"
197+
_msg "Execution trace \c"
198+
if (( $_trace )); then
199+
_msg "on"
200+
else
201+
_msg "off"
202+
fi
203+
}
204+
205+
206+
# Print the passed arguments to Standard Error
207+
function _msg
208+
{
209+
echo -e "$@" >&2
210+
}
211+
212+
213+
# Print command menu
214+
function _menu {
215+
_msg 'bashdb commands:
216+
bp N set breakpoint at line N
217+
bp list breakpoints and break condition
218+
bc string set break condition to string
219+
bc clear break condition
220+
cb N clear breakpoint at line N
221+
cb clear all breakpoints
222+
ds displays the test script and breakpoints
223+
g start/resume execution
224+
s [N] execute N statements (default 1)
225+
x toggle execution trace on/off
226+
h, ? print this menu
227+
! string passes string to a shell
228+
q quit'
229+
}
230+
231+
232+
233+
# Erase the temporary file before exiting
234+
function _cleanup
235+
{
236+
rm $_debugfile 2>/dev/null
237+
}

0 commit comments

Comments
 (0)