Product: NAS ( Network Attached Storage )
Solution: Marvell 88F6180 BSP
Patch
patch_rootfs.sh
#!/bin/sh
. ./scripts/build_subr.sh
#cd ${TOPDIR}/rootfs/dev
#mknod /dev/nfs b 0 255
touch ${TOPDIR}/rootfs/etc/resolv.conf
chmod 644 ${TOPDIR}/rootfs/etc/resolv.conf
cp ${TOPDIR}/patch/sysconf/services ${TOPDIR}/rootfs/etc
cp ${TOPDIR}/patch/sysconf/smb.conf ${TOPDIR}/rootfs/etc
cp ${TOPDIR}/patch/sysconf/issue ${TOPDIR}/rootfs/etc
cp ${TOPDIR}/patch/sysconf/group ${TOPDIR}/rootfs/etc
cp ${TOPDIR}/patch/sysconf/passwd ${TOPDIR}/rootfs/etc
cp ${TOPDIR}/patch/sysconf/fstab ${TOPDIR}/rootfs/etc
cp ${TOPDIR}/patch/sysconf/inittab.patch ${TOPDIR}/rootfs/etc
cd ${TOPDIR}/rootfs/etc
patch -p0 < inittab.patch
rm -f inittab.patch
chmod 644 ${TOPDIR}/rootfs/etc/inittab ${TOPDIR}/rootfs/etc/fstab
cp -f ${TOPDIR}/patch/sysconf/rcS ${TOPDIR}/rootfs/etc/init.d
mkdir ${TOPDIR}/rootfs/tmp ${TOPDIR}/rootfs/mnt ${TOPDIR}/rootfs/sys
chmod 1777 ${TOPDIR}/rootfs/tmp
mkdir ${TOPDIR}/rootfs/var/lib ${TOPDIR}/rootfs/var/log ${TOPDIR}/rootfs/var/run ${TOPDIR}/rootfs/var/tmp
chmod 1777 ${TOPDIR}/rootfs/var/tmp
mkdir ${TOPDIR}/rootfs/syrmnt ${TOPDIR}/rootfs/smbmnt
mknod ${TOPDIR}/rootfs/dev/FLK_gpio c 254 0
echo "Done"
patch_server.sh
#!/bin/sh
. ./scripts/build_subr.sh
echo "===start server==="
echo "**此script必須在pwd=/home/surveyor/rootfs下執行 ./scripts/patch_server.sh**"
echo "1. roofs放在/home/surveyor下"
echo "2. uImage放在/home/surveyor/kernel/linux-2.6.22.18-bin下"
echo "3. 請先安裝dhcp-3.0.6-12.fc8"
echo "4. 請先安裝tftp-0.42-5-fc8"
echo "5. 請先安裝nfs-utils-1.1.0-6.fc8"
echo "6. 請先安裝squashfs-tools"
echo "7. 更改uboot env,請參照.../patch/fedora8/uboot_env.conf"
echo "Setting IP"
ifdown eth0
ifconfig eth0 192.168.1.100
ifup eth0
echo "Satrting DHCP"
cp -f ${TOPDIR}/patch/fedora8/dhcpd.conf /etc
/etc/init.d/dhcpd restart
echo "Satrting TFTP"
cp -f ${TOPDIR}/patch/fedora8/tftp /etc/xinetd.d
service xinetd restart
echo "Satrting NFS"
cp -f ${TOPDIR}/patch/fedora8/exports /etc/
/etc/init.d/rpcbind restart
/etc/init.d/nfs restart
echo "Install squashfs"
modprobe squashfs
echo "===Down==="
build_squashfs.sh
#! /bin/sh . ./scripts/build_subr.sh today=`date +%Y%m%d` mksquashfs ./rootfs ./rootfs.image/rootfs.$today.sqfs chmod +r ./rootfs.image/rootfs.$today.sqfs cp -f ./rootfs.image/rootfs.$today.sqfs /home/surveyor/kernel/linux-2.6.22.18-bin
Host Env
dhcpd.conf
#
# DHCP Server Configuration file.
# see /usr/share/doc/dhcp*/dhcpd.conf.sample
#
ddns-update-style interim;
ignore client-updates;
allow bootp;
subnet 192.168.1.0 netmask 255.255.255.0 {
range dynamic-bootp 192.168.1.50 192.168.1.60;
default-lease-time 21600;
max-lease-time 43200;
host surveyor {
hardware ethernet 00:50:43:52:02:29;
fixed-address 192.168.1.99;
next-server 192.168.1.3;
filename "uImage";
option root-path "/home/surveyor/rootfs/rootfs";
}
}
exports
/home/surveyor/rootfs/rootfs *(rw,no_root_squash)tftp
# default: off
# description: The tftp server serves files using the trivial file transfer \
# protocol. The tftp protocol is often used to boot diskless \
# workstations, download configuration files to network-aware printers, \
# and to start the installation process for some operating systems.
service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -c -s /home/surveyor/kernel/linux-2.6.22.18-bin
# disable = yes
per_source = 11
cps = 100 2
flags = IPv4
}
Uboot Envnfs_boot: setenv console 'console=ttyS0,115200' setenv bootargs '$(console) $(bootargs_root) ip=dhcp nfsroot=192.168.1.100:/home/surveyor/rootfs/rootfs' setenv bootcmd 'nand read 0x2000000 0x300000 0x300000;setenv bootargs $(console) $(mtdparts) $(bootargs_root) ip=dhcp nfsroot=192.168.1.100:/home/surveyor/rootfs/rootfs; bootm 0x2000000;' setenv ipaddr '192.168.1.99' setenv serverip '192.168.1.100' mtd_boot: setenv mtdid 'nand0=nand_mtd' setenv mtdparts 'mtdparts=nand_mtd:0x100000@0(uboot)ro,0x100000@0x100000(system1),0x100000@0x200000(system2),0x300000@0x300000(kernel)ro,0x700000@0x600000(RootFS)ro' setenv bootcmd 'nand read 0x2000000 0x300000 0x300000 ;setenv bootargs $(console) ip=dhcp $(mtdparts) rootfstype=squashfs root=/dev/mtdblock5;bootm 0x2000000;' setenv console 'console=ttyS0,115200' setenv ipaddr '192.168.1.99' setenv serverip '192.168.1.100' burn to flash: tftpboot 0x1000000 uImage.20090514 nand erase 0x300000 0x300000 nand write 0x1000000 0x300000 0x300000 tftpboot 0x1000000 rootfs.20090514.sqsh nand erase 0x600000 0x700000 nand write 0x1000000 0x600000 0x700000Intergrate BSP
fstab
#/dev/nfs / nfs defaults 0 0 proc /proc proc defaults 0 0 devpts /dev/pts devpts gid=4,mode=620 0 0 sysfs /sys sysfs defaults 0 0group
root:x:0:root nobody:x:500:inittab.patch
--- inittab 2005-12-18 18:52:42.000000000 +0800 +++ inittab.new 2009-05-09 10:41:44.000000000 +0800 @@ -1,6 +1,38 @@ +#/**+=========================================================================== +#File: inittab +# +#Description: be parsed for /sbin/init +# +#Revision: V1.0 +# +#History: +#+------------------+-------------+--------------------------------------------+ +#| date | author | comments | +#+------------------+-------------+--------------------------------------------+ +#| 2009/05/06 | Wade Chiu | Initial build | +#+------------------+-------------+--------------------------------------------+ +# +#------------------------------------------------------------------------------- +#** Cheng Uei Precision Industry CONFIDENTIAL +#** Copyright(C) 2009 Uei Precision Industry Co., Ltd. All Rights Reserved. +#** +#** The source code contained or described herein and all documents related +#** to the source code (Material) are owned by Cheng Uei. +#** The Material is protected by worldwide copyright and trade secret laws and +#** treaty provisions. No part of the Material may be used, copied, reproduced, +#** modified, published, uploaded, posted, transmitted, distributed, or disclosed +#** in any way without Cheng Uei prior express written permission. +#============================================================================+*/ + +#========================================== +# sysinit script +#========================================== ::sysinit:/etc/init.d/rcS -::respawn:-/bin/sh -#::respawn:-/bin/sh -#tty2::askfirst:-/bin/sh -#::ctrlaltdel:/bin/umount -a -r + +#========================================== +# respawn +#========================================== +# Put a getty on the serial port +ttyS0::respawn:/sbin/getty -L ttyS0 115200 vt100 +issue
Foxlink NAS release 1 (Serveyor)passwd
root:$1$$oCLuEVgI1iAqOA8pwkzAg1:0:0:root:/root:/bin/sh nobody:x:500:500:Linux User,,,:/home/nobody:/bin/shrcS
#!/bin/bash
echo "Mounting file system"
/bin/mount -a
ifconfig | head -n 1 | awk '{print $5}' | awk '{FS=":"} {print "RPL"$4$5$6}' | xargs hostname
#execute flk_main_program
echo "Mounting shares"
ntfs-3g -o rw,noatime,nodirtime,remove_hiberfile,streams_interface=windows /dev/sda1 /tmp > /dev/null 2>&1
echo "allow_restart"
echo 1 > /sys/block/sda/device/scsi_disk*/allow_restart
echo "Starting telnet"
/usr/sbin/telnetd -f /etc/issue
echo "Starting samba"
/sbin/nmbd -D -s/etc/smb.conf
/sbin/smbd -D -s/etc/smb.conf
services
# /etc/services: # $Id: services,v 1.1 2004/10/09 02:49:18 andersen Exp $ # # Network services, Internet style # # Note that it is presently the policy of IANA to assign a single well-known # port number for both TCP and UDP; hence, most entries here have two entries # even if the protocol doesn't support UDP operations. # Updated from RFC 1700, ``Assigned Numbers'' (October 1994). Not all ports # are included, only the more common ones. tcpmux 1/tcp # TCP port service multiplexer echo 7/tcp echo 7/udp discard 9/tcp sink null discard 9/udp sink null systat 11/tcp users daytime 13/tcp daytime 13/udp netstat 15/tcp qotd 17/tcp quote msp 18/tcp # message send protocol msp 18/udp # message send protocol chargen 19/tcp ttytst source chargen 19/udp ttytst source ftp-data 20/tcp ftp 21/tcp ssh 22/tcp # SSH Remote Login Protocol ssh 22/udp # SSH Remote Login Protocol telnet 23/tcp # 24 - private smtp 25/tcp mail # 26 - unassigned time 37/tcp timserver time 37/udp timserver rlp 39/udp resource # resource location nameserver 42/tcp name # IEN 116 whois 43/tcp nicname re-mail-ck 50/tcp # Remote Mail Checking Protocol re-mail-ck 50/udp # Remote Mail Checking Protocol domain 53/tcp nameserver # name-domain server domain 53/udp nameserver mtp 57/tcp # deprecated bootps 67/tcp # BOOTP server bootps 67/udp bootpc 68/tcp # BOOTP client bootpc 68/udp tftp 69/udp gopher 70/tcp # Internet Gopher gopher 70/udp rje 77/tcp netrjs finger 79/tcp www 80/tcp http # WorldWideWeb HTTP www 80/udp # HyperText Transfer Protocol link 87/tcp ttylink kerberos 88/tcp kerberos5 krb5 # Kerberos v5 kerberos 88/udp kerberos5 krb5 # Kerberos v5 supdup 95/tcp # 100 - reserved hostnames 101/tcp hostname # usually from sri-nic iso-tsap 102/tcp tsap # part of ISODE. csnet-ns 105/tcp cso-ns # also used by CSO name server csnet-ns 105/udp cso-ns # unfortunately the poppassd (Eudora) uses a port which has already # been assigned to a different service. We list the poppassd as an # alias here. This should work for programs asking for this service. # (due to a bug in inetd the 3com-tsmux line is disabled) #3com-tsmux 106/tcp poppassd #3com-tsmux 106/udp poppassd rtelnet 107/tcp # Remote Telnet rtelnet 107/udp pop-2 109/tcp postoffice # POP version 2 pop-2 109/udp pop-3 110/tcp # POP version 3 pop-3 110/udp sunrpc 111/tcp portmapper # RPC 4.0 portmapper TCP sunrpc 111/udp portmapper # RPC 4.0 portmapper UDP auth 113/tcp authentication tap ident sftp 115/tcp uucp-path 117/tcp nntp 119/tcp readnews untp # USENET News Transfer Protocol ntp 123/tcp ntp 123/udp # Network Time Protocol netbios-ns 137/tcp # NETBIOS Name Service netbios-ns 137/udp netbios-dgm 138/tcp # NETBIOS Datagram Service netbios-dgm 138/udp netbios-ssn 139/tcp # NETBIOS session service netbios-ssn 139/udp swat 901/tcp imap2 143/tcp # Interim Mail Access Proto v2 imap2 143/udp snmp 161/udp # Simple Net Mgmt Proto snmp-trap 162/udp snmptrap # Traps for SNMP cmip-man 163/tcp # ISO mgmt over IP (CMOT) cmip-man 163/udp cmip-agent 164/tcp cmip-agent 164/udp xdmcp 177/tcp # X Display Mgr. Control Proto xdmcp 177/udp nextstep 178/tcp NeXTStep NextStep # NeXTStep window nextstep 178/udp NeXTStep NextStep # server bgp 179/tcp # Border Gateway Proto. bgp 179/udp prospero 191/tcp # Cliff Neuman's Prospero prospero 191/udp irc 194/tcp # Internet Relay Chat irc 194/udp smux 199/tcp # SNMP Unix Multiplexer smux 199/udp at-rtmp 201/tcp # AppleTalk routing at-rtmp 201/udp at-nbp 202/tcp # AppleTalk name binding at-nbp 202/udp at-echo 204/tcp # AppleTalk echo at-echo 204/udp at-zis 206/tcp # AppleTalk zone information at-zis 206/udp qmtp 209/tcp # The Quick Mail Transfer Protocol qmtp 209/udp # The Quick Mail Transfer Protocol z3950 210/tcp wais # NISO Z39.50 database z3950 210/udp wais ipx 213/tcp # IPX ipx 213/udp imap3 220/tcp # Interactive Mail Access imap3 220/udp # Protocol v3 ulistserv 372/tcp # UNIX Listserv ulistserv 372/udp https 443/tcp # MCom https 443/udp # MCom snpp 444/tcp # Simple Network Paging Protocol snpp 444/udp # Simple Network Paging Protocol saft 487/tcp # Simple Asynchronous File Transfer saft 487/udp # Simple Asynchronous File Transfer npmp-local 610/tcp dqs313_qmaster # npmp-local / DQS npmp-local 610/udp dqs313_qmaster # npmp-local / DQS npmp-gui 611/tcp dqs313_execd # npmp-gui / DQS npmp-gui 611/udp dqs313_execd # npmp-gui / DQS hmmp-ind 612/tcp dqs313_intercell# HMMP Indication / DQS hmmp-ind 612/udp dqs313_intercell# HMMP Indication / DQS # # UNIX specific services # exec 512/tcp biff 512/udp comsat login 513/tcp who 513/udp whod shell 514/tcp cmd # no passwords used syslog 514/udp printer 515/tcp spooler # line printer spooler talk 517/udp ntalk 518/udp route 520/udp router routed # RIP timed 525/udp timeserver tempo 526/tcp newdate courier 530/tcp rpc conference 531/tcp chat netnews 532/tcp readnews netwall 533/udp # -for emergency broadcasts uucp 540/tcp uucpd # uucp daemon afpovertcp 548/tcp # AFP over TCP afpovertcp 548/udp # AFP over TCP remotefs 556/tcp rfs_server rfs # Brunhoff remote filesystem klogin 543/tcp # Kerberized `rlogin' (v5) kshell 544/tcp krcmd # Kerberized `rsh' (v5) kerberos-adm 749/tcp # Kerberos `kadmin' (v5) # webster 765/tcp # Network dictionary webster 765/udp # # From ``Assigned Numbers'': # #> The Registered Ports are not controlled by the IANA and on most systems #> can be used by ordinary user processes or programs executed by ordinary #> users. # #> Ports are used in the TCP [45,106] to name the ends of logical #> connections which carry long term conversations. For the purpose of #> providing services to unknown callers, a service contact port is #> defined. This list specifies the port used by the server process as its #> contact port. While the IANA can not control uses of these ports it #> does register or list uses of these ports as a convienence to the #> community. # nfsdstatus 1110/tcp nfsd-keepalive 1110/udp ingreslock 1524/tcp ingreslock 1524/udp prospero-np 1525/tcp # Prospero non-privileged prospero-np 1525/udp datametrics 1645/tcp old-radius # datametrics / old radius entry datametrics 1645/udp old-radius # datametrics / old radius entry sa-msg-port 1646/tcp old-radacct # sa-msg-port / old radacct entry sa-msg-port 1646/udp old-radacct # sa-msg-port / old radacct entry radius 1812/tcp # Radius radius 1812/udp # Radius radacct 1813/tcp # Radius Accounting radacct 1813/udp # Radius Accounting nfsd 2049/tcp nfs nfsd 2049/udp nfs cvspserver 2401/tcp # CVS client/server operations cvspserver 2401/udp # CVS client/server operations mysql 3306/tcp # MySQL mysql 3306/udp # MySQL rfe 5002/tcp # Radio Free Ethernet rfe 5002/udp # Actually uses UDP only cfengine 5308/tcp # CFengine cfengine 5308/udp # CFengine bbs 7000/tcp # BBS service # # # Kerberos (Project Athena/MIT) services # Note that these are for Kerberos v4, and are unofficial. Sites running # v4 should uncomment these and comment out the v5 entries above. # kerberos4 750/udp kerberos-iv kdc # Kerberos (server) udp kerberos4 750/tcp kerberos-iv kdc # Kerberos (server) tcp kerberos_master 751/udp # Kerberos authentication kerberos_master 751/tcp # Kerberos authentication passwd_server 752/udp # Kerberos passwd server krb_prop 754/tcp # Kerberos slave propagation krbupdate 760/tcp kreg # Kerberos registration kpasswd 761/tcp kpwd # Kerberos "passwd" kpop 1109/tcp # Pop with Kerberos knetd 2053/tcp # Kerberos de-multiplexor zephyr-srv 2102/udp # Zephyr server zephyr-clt 2103/udp # Zephyr serv-hm connection zephyr-hm 2104/udp # Zephyr hostmanager eklogin 2105/tcp # Kerberos encrypted rlogin # # Unofficial but necessary (for NetBSD) services # supfilesrv 871/tcp # SUP server supfiledbg 1127/tcp # SUP debugging # # Datagram Delivery Protocol services # rtmp 1/ddp # Routing Table Maintenance Protocol nbp 2/ddp # Name Binding Protocol echo 4/ddp # AppleTalk Echo Protocol zip 6/ddp # Zone Information Protocol # # Services added for the Debian GNU/Linux distribution poppassd 106/tcp # Eudora poppassd 106/udp # Eudora mailq 174/tcp # Mailer transport queue for Zmailer mailq 174/tcp # Mailer transport queue for Zmailer omirr 808/tcp omirrd # online mirror omirr 808/udp omirrd # online mirror rmtcfg 1236/tcp # Gracilis Packeten remote config server xtel 1313/tcp # french minitel coda_opcons 1355/udp # Coda opcons (Coda fs) coda_venus 1363/udp # Coda venus (Coda fs) coda_auth 1357/udp # Coda auth (Coda fs) coda_udpsrv 1359/udp # Coda udpsrv (Coda fs) coda_filesrv 1361/udp # Coda filesrv (Coda fs) codacon 1423/tcp venus.cmu # Coda Console (Coda fs) coda_aux1 1431/tcp # coda auxiliary service (Coda fs) coda_aux1 1431/udp # coda auxiliary service (Coda fs) coda_aux2 1433/tcp # coda auxiliary service (Coda fs) coda_aux2 1433/udp # coda auxiliary service (Coda fs) coda_aux3 1435/tcp # coda auxiliary service (Coda fs) coda_aux3 1435/udp # coda auxiliary service (Coda fs) cfinger 2003/tcp # GNU Finger afbackup 2988/tcp # Afbackup system afbackup 2988/udp # Afbackup system icp 3130/tcp # Internet Cache Protocol (Squid) icp 3130/udp # Internet Cache Protocol (Squid) postgres 5432/tcp # POSTGRES postgres 5432/udp # POSTGRES fax 4557/tcp # FAX transmission service (old) hylafax 4559/tcp # HylaFAX client-server protocol (new) noclog 5354/tcp # noclogd with TCP (nocol) noclog 5354/udp # noclogd with UDP (nocol) hostmon 5355/tcp # hostmon uses TCP (nocol) hostmon 5355/udp # hostmon uses TCP (nocol) ircd 6667/tcp # Internet Relay Chat ircd 6667/udp # Internet Relay Chat webcache 8080/tcp # WWW caching service webcache 8080/udp # WWW caching service tproxy 8081/tcp # Transparent Proxy tproxy 8081/udp # Transparent Proxy mandelspawn 9359/udp mandelbrot # network mandelbrot amanda 10080/udp # amanda backup services amandaidx 10082/tcp # amanda backup services amidxtape 10083/tcp # amanda backup services isdnlog 20011/tcp # isdn logging system isdnlog 20011/udp # isdn logging system vboxd 20012/tcp # voice box system vboxd 20012/udp # voice box system binkp 24554/tcp # Binkley binkp 24554/udp # Binkley asp 27374/tcp # Address Search Protocol asp 27374/udp # Address Search Protocol tfido 60177/tcp # Ifmail tfido 60177/udp # Ifmail fido 60179/tcp # Ifmail fido 60179/udp # Ifmail # Local servicessmb.conf
[global] server string = FLKNAS workgroup = SEAGATEGROUP log file = /private/%L.log max log size = 1024 security = share smb passwd file = /private/smbpasswd private dir = /private dns proxy = No lock directory = /private/locks pid directory = /private/locks client lanman auth = yes use sendfile = yes vfs objects = streams_xattr [tmp] path=/tmp read only=no public=yesPorting Server
#!/bin/sh
. ./scripts/build_subr.sh
rm -rf ${INSTALLDIR}
mkdir -p ${INSTALLDIR}
unpack "ntfs-3g-2009.4.4"
SRC="build/ntfs-3g-2009.4.4"
cd ${TOPDIR}/${SRC}
export LD_LIBARY_PATH=${CROSS_COMPILE}/lib
export CPPFLAGS=-I${CROSS_COMPILE}/include
export LDFLAGS=-L${CROSS_COMPILE}/lib
export CC=${CROSS_COMPILE}-gcc
export PATH=${PATH}:${TOPDIR}/tools/gcc/bin
./configure --host=arm-linux --prefix=${INSTALLDIR} --exec-prefix=${INSTALLDIR}
make
check_errno
make install
check_errno
cd ${INSTALLDIR}/..
tar -jc -f ${TOPDIR}/pkg/softfp/ntfs-3g-2009.4.4.full-bin.tar.bz2 ${ROOTFS}
check_errno
mv ${INSTALLDIR}/share ${INSTALLDIR}/share.qq
rm -rf ${INSTALLDIR}/share.qq
#rm -f ${INSTALLDIR}/bin/ntfs-3g.probe
mv ${INSTALLDIR}/lib/pkgconfig ${INSTALLDIR}/lib/pkgconfig.qq
rm -rf ${INSTALLDIR}/lib/pkgconfig.qq
mv ${INSTALLDIR}/include ${INSTALLDIR}/include.qq
rm -rf ${INSTALLDIR}/include.qq
mv ${INSTALLDIR}/sbin ${INSTALLDIR}/sbin.qq
rm -rf ${INSTALLDIR}/sbin.qq
tar -jc -f ${TOPDIR}/pkg/softfp/ntfs-3g-2009.4.4-bin.tar.bz2 ${ROOTFS}
check_errno
mv ${TOPDIR}/build ${TOPDIR}/build.qq
mkdir -p ${TOPDIR}/build
rm -rf ${TOPDIR}/build.qq &
mv ${TOPDIR}/tmp ${TOPDIR}/tmp.qq
mkdir -p ${TOPDIR}/tmp
rm -rf ${TOPDIR}/tmp.qq &
cd ${TOPDIR}
build_samba.sh
#!/bin/sh
. ./scripts/build_subr.sh
rm -rf ${INSTALLDIR}
mkdir -p ${INSTALLDIR}
unpack "samba-3.3.4"
SRC="build/samba-3.3.4/source"
cp -f ${TOPDIR}/patch/samba-3.3.4/configure.patch ${TOPDIR}/${SRC}
cp -f ${TOPDIR}/patch/samba-3.3.4/mtab.c.patch ${TOPDIR}/${SRC}/client
cd ${TOPDIR}/${SRC}
patch -p0 < configure.patch
cd ${TOPDIR}/${SRC}/client
patch -p0 < mtab.c.patch
cd ..
export LD_LIBARY_PATH=${CROSS_COMPILE}/lib
export CPPFLAGS=-I${CROSS_COMPILE}/include
export LDFLAGS=-L${CROSS_COMPILE}/lib
export CC=${CROSS_COMPILE}-gcc
export PATH=${PATH}:${TOPDIR}/tools/gcc/bin
export samba_cv_CC_NEGATIVE_ENUM_VALUES=yes
export libreplace_cv_READDIR_GETDIRENTRIES=no
export libreplace_cv_READDIR_GETDENTS=no
export linux_getgrouplist_ok=no
export samba_cv_HAVE_WRFILE_KEYTAB=yes
export samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=yes
export samba_cv_HAVE_IFACE_IFCONF=yes
./configure --build=i686-linux --host=arm-linux --target=arm-linux --prefix=${INSTALLDIR} --disable-shared --disable-cups --disable-iprint --disable-pie --disable-fam --without-ldap
cp -f ${TOPDIR}/patch/samba-3.3.4/config.h ${TOPDIR}/${SRC}/include
make
check_errno
make install
check_errno
cd ${INSTALLDIR}/..
tar -jc -f ${TOPDIR}/pkg/softfp/samba-3.3.4.full-bin.tar.bz2 ${ROOTFS}
check_errno
mv ${INSTALLDIR}/swat ${INSTALLDIR}/swat.qq
rm -rf ${INSTALLDIR}/swat.qq
mv ${INSTALLDIR}/share ${INSTALLDIR}/share.qq
rm -rf ${INSTALLDIR}/share.qq
rm -f ${INSTALLDIR}/sbin/mount.cifs
rm -f ${INSTALLDIR}/sbin/swat
rm -f ${INSTALLDIR}/sbin/umount.cifs
rm -f ${INSTALLDIR}/sbin/winbindd
mv ${INSTALLDIR}/lib ${INSTALLDIR}/lib.qq
rm -rf ${INSTALLDIR}/lib.qq
mv ${INSTALLDIR}/include ${INSTALLDIR}/include.qq
rm -rf ${INSTALLDIR}/include.qq
mv ${INSTALLDIR}/bin ${INSTALLDIR}/bin.qq
rm -rf ${INSTALLDIR}/bin.qq
tar -jc -f ${TOPDIR}/pkg/softfp/samba-3.3.4-bin.tar.bz2 ${ROOTFS}
check_errno
mv ${TOPDIR}/build ${TOPDIR}/build.qq
mkdir -p ${TOPDIR}/build
rm -rf ${TOPDIR}/build.qq &
mv ${TOPDIR}/tmp ${TOPDIR}/tmp.qq
mkdir -p ${TOPDIR}/tmp
rm -rf ${TOPDIR}/tmp.qq &
cd ${TOPDIR}
configure.patch
--- configure 2009-04-29 02:53:51.000000000 +0800
+++ configure.new 2009-05-05 16:23:23.000000000 +0800
@@ -13066,13 +13066,17 @@
else
if test "$cross_compiling" = yes; then
- { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-{ { $as_echo "$as_me:$LINENO: error: cannot run test program while cross compiling
-See \`config.log' for more details." >&5
-$as_echo "$as_me: error: cannot run test program while cross compiling
-See \`config.log' for more details." >&2;}
- { (exit 1); exit 1; }; }; }
+# { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
+#$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+#{ { $as_echo "$as_me:$LINENO: error: cannot run test program while cross compiling
+#See \`config.log' for more details." >&5
+#$as_echo "$as_me: error: cannot run test program while cross compiling
+#See \`config.log' for more details." >&2;}
+# { (exit 1); exit 1; }; }; }
+{
+echo "$as_me:$LINENO: uclibc <= samba 3.3.4 check skipped" >&5
+echo "$as_me: uclibc <= samba 3.3.4 check skipped" >&2;
+}
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
@@ -23586,12 +23590,12 @@
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
- builtin and then its argument prototype would still apply. */
+ builtin and then its argument prototype would st cannot run test program while cross compilingill apply. */
#ifdef __cplusplus
extern "C"
#endif
char $ac_func ();
-/* The GNU C library defines this for functions which it implements
+/* The GNU C library defines this for functions whi cannot run test program while cross compilingch it implements
to always fail with ENOSYS. Some functions are actually named
something starting with __ and the normal name is an alias. */
#if defined __stub_$ac_func || defined __stub___$ac_func
@@ -23801,13 +23805,17 @@
else
if test "$cross_compiling" = yes; then
- { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-{ { $as_echo "$as_me:$LINENO: error: cannot run test program while cross compiling
-See \`config.log' for more details." >&5
-$as_echo "$as_me: error: cannot run test program while cross compiling
-See \`config.log' for more details." >&2;}
- { (exit 1); exit 1; }; }; }
+# { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
+#$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+#{ { $as_echo "$as_me:$LINENO: error: cannot run test program while cross compiling
+#See \`config.log' for more details." >&5
+#$as_echo "$as_me: error: cannot run test program while cross compiling
+#See \`config.log' for more details." >&2;}
+# { (exit 1); exit 1; }; }; }
+{
+echo "$as_me:$LINENO: glibc <= samba 3.3.4 check skipped" >&5
+echo "$as_me: glibc <= samba 3.3.4 check skipped" >&2;
+}
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
@@ -23989,13 +23997,17 @@
else
if test "$cross_compiling" = yes; then
- { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-{ { $as_echo "$as_me:$LINENO: error: cannot run test program while cross compiling
-See \`config.log' for more details." >&5
-$as_echo "$as_me: error: cannot run test program while cross compiling
-See \`config.log' for more details." >&2;}
- { (exit 1); exit 1; }; }; }
+# { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
+#$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+#{ { $as_echo "$as_me:$LINENO: error: cannot run test program while cross compiling
+#See \`config.log' for more details." >&5
+#$as_echo "$as_me: error: cannot run test program while cross compiling
+#See \`config.log' for more details." >&2;}
+# { (exit 1); exit 1; }; }; }
+{
+echo "$as_me:$LINENO: glibc <= samba 3.3.4 check skipped" >&5
+echo "$as_me: glibc <= samba 3.3.4 check skipped" >&2;
+}
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
@@ -44068,13 +44080,17 @@
*linux*)
# glibc <= 2.3.2 has a broken getgrouplist
if test "$cross_compiling" = yes; then
- { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-{ { $as_echo "$as_me:$LINENO: error: cannot run test program while cross compiling
-See \`config.log' for more details." >&5
-$as_echo "$as_me: error: cannot run test program while cross compiling
-See \`config.log' for more details." >&2;}
- { (exit 1); exit 1; }; }; }
+# { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
+#$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+#{ { $as_echo "$as_me:$LINENO: error: cannot run test program while cross compiling
+#See \`config.log' for more details." >&5
+#$as_echo "$as_me: error: cannot run test program while cross compiling
+#See \`config.log' for more details." >&2;}
+# { (exit 1); exit 1; }; }; }
+{
+echo "$as_me:$LINENO: glibc <= samba 3.3.4 check skipped" >&5
+echo "$as_me: glibc <= samba 3.3.4 check skipped" >&2;
+}
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
@@ -67118,13 +67134,17 @@
else
if test "$cross_compiling" = yes; then
- { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-{ { $as_echo "$as_me:$LINENO: error: cannot run test program while cross compiling
-See \`config.log' for more details." >&5
-$as_echo "$as_me: error: cannot run test program while cross compiling
-See \`config.log' for more details." >&2;}
- { (exit 1); exit 1; }; }; }
+# { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
+#$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+#{ { $as_echo "$as_me:$LINENO: error: cannot run test program while cross compiling
+#See \`config.log' for more details." >&5
+#$as_echo "$as_me: error: cannot run test program while cross compiling
+#See \`config.log' for more details." >&2;}
+# { (exit 1); exit 1; }; }; }
+{
+echo "$as_me:$LINENO: glibc <= samba 3.3.4 check skipped" >&5
+echo "$as_me: glibc <= samba 3.3.4 check skipped" >&2;
+}
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
@@ -67393,13 +67413,17 @@
LDFLAGS="$LDFLAGS";
export LDFLAGS;
if test "$cross_compiling" = yes; then
- { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-{ { $as_echo "$as_me:$LINENO: error: cannot run test program while cross compiling
-See \`config.log' for more details." >&5
-$as_echo "$as_me: error: cannot run test program while cross compiling
-See \`config.log' for more details." >&2;}
- { (exit 1); exit 1; }; }; }
+# { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
+#$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+#{ { $as_echo "$as_me:$LINENO: error: cannot run test program while cross compiling
+#See \`config.log' for more details." >&5
+#$as_echo "$as_me: error: cannot run test program while cross compiling
+#See \`config.log' for more details." >&2;}
+# { (exit 1); exit 1; }; }; }
+{
+echo "$as_me:$LINENO: glibc <= samba 3.3.4 check skipped" >&5
+echo "$as_me: glibc <= samba 3.3.4 check skipped" >&2;
+}
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
@@ -67494,13 +67518,17 @@
LDFLAGS="$LDFLAGS";
export LDFLAGS;
if test "$cross_compiling" = yes; then
- { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-{ { $as_echo "$as_me:$LINENO: error: cannot run test program while cross compiling
-See \`config.log' for more details." >&5
-$as_echo "$as_me: error: cannot run test program while cross compiling
-See \`config.log' for more details." >&2;}
- { (exit 1); exit 1; }; }; }
+# { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
+#$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+#{ { $as_echo "$as_me:$LINENO: error: cannot run test program while cross compiling
+#See \`config.log' for more details." >&5
+#$as_echo "$as_me: error: cannot run test program while cross compiling
+#See \`config.log' for more details." >&2;}
+# { (exit 1); exit 1; }; }; }
+{
+echo "$as_me:$LINENO: glibc <= samba 3.3.4 check skipped" >&5
+echo "$as_me: glibc <= samba 3.3.4 check skipped" >&2;
+}
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
mtab.c.patch
--- mtab.c 2009-04-28 14:46:16.000000000 +0800 +++ mtab.c.new 2009-05-05 16:25:33.000000000 +0800 @@ -34,6 +34,8 @@ #include <sys/time.h> #include <time.h> #include <fcntl.h> +#include <sys/types.h> +#include <sys/stat.h> #include <mntent.h> #include <stdlib.h> #include <signal.h>
Application
netlink_udev.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <sys/un.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <linux/types.h>
#include <linux/netlink.h>
#include <errno.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#define UEVENT_BUFFER_SIZE 2048
static int init_hotplug_sock()
{
const int buffersize = 1024;
int ret;
struct sockaddr_nl snl;
bzero(&snl, sizeof(struct sockaddr_nl));
snl.nl_family = AF_NETLINK;
snl.nl_pid = getpid();
snl.nl_groups = 1;
int s = socket(PF_NETLINK, SOCK_DGRAM, NETLINK_KOBJECT_UEVENT);
if (s == -1)
{
perror("socket");
return -1;
}
setsockopt(s, SOL_SOCKET, SO_RCVBUF, &buffersize, sizeof(buffersize));
ret = bind(s, (struct sockaddr *)&snl, sizeof(struct sockaddr_nl));
if (ret < 0)
{
perror("bind");
close(s);
return -1;
}
return s;
}
int main(int argc, char* argv[])
{
int hotplug_sock = init_hotplug_sock();
while(1)
{
/* Netlink message buffer */
char buf[UEVENT_BUFFER_SIZE * 2] = {0};
recv(hotplug_sock, &buf, sizeof(buf), 0);
printf("%s\n", buf);
}
return 0;
}
scsi_serial.c
#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <scsi/sg.h>
#define SCSI_TIMEOUT 5000 /* ms */
static char *device = "/dev/sdd";
int scsi_io(int fd, unsigned char *cdb, unsigned char cdb_size, int xfer_dir,
unsigned char *data, unsigned int *data_size,
unsigned char *sense, unsigned int *sense_len)
{
sg_io_hdr_t io_hdr;
memset(&io_hdr, 0, sizeof(sg_io_hdr_t));
io_hdr.interface_id = 'S';
/* CDB */
io_hdr.cmdp = cdb;
io_hdr.cmd_len = cdb_size;
/* Where to store the sense_data, if there was an error */
io_hdr.sbp = sense;
io_hdr.mx_sb_len = *sense_len;
*sense_len=0;
/* Transfer direction, either in or out. Linux does not yet
support bidirectional SCSI transfers ?
*/
io_hdr.dxfer_direction = xfer_dir;
/* Where to store the DATA IN/OUT from the device and how big the
buffer is
*/
io_hdr.dxferp = data;
io_hdr.dxfer_len = *data_size;
/* SCSI timeout in ms */
io_hdr.timeout = SCSI_TIMEOUT;
if(ioctl(fd, SG_IO, &io_hdr) < 0){
perror("SG_IO ioctl failed");
return -1;
}
/* now for the error processing */
if((io_hdr.info & SG_INFO_OK_MASK) != SG_INFO_OK){
if(io_hdr.sb_len_wr > 0){
*sense_len=io_hdr.sb_len_wr;
return 0;
}
}
if(io_hdr.masked_status){
printf("status=0x%x\n", io_hdr.status);
printf("masked_status=0x%x\n", io_hdr.masked_status);
return -2;
}
if(io_hdr.host_status){
printf("host_status=0x%x\n", io_hdr.host_status);
return -3;
}
if(io_hdr.driver_status){
printf("driver_status=0x%x\n", io_hdr.driver_status);
return -4;
}
return 0;
}
int scsi_inquiry_unit_serial_number(int fd)
{
unsigned char cdb[]={0x12,0x01,0x80,0,0,0};
unsigned int data_size=0x00ff;
unsigned char data[data_size];
unsigned int sense_len=32;
unsigned char sense[sense_len];
int res, pl, i;
cdb[3]=(data_size>>8)&0xff;
cdb[4]=data_size&0xff;
printf("INQUIRY Unit Serial Number:\n");
res=scsi_io(fd, cdb, sizeof(cdb), SG_DXFER_FROM_DEV, data, &data_size, sense, &sense_len);
if(res){
printf("SCSI_IO failed\n");
return -1;
}
if(sense_len){
return -1;
}
/* Page Length */
pl=data[3];
/* Unit Serial Number */
printf("Unit Serial Number:");
for(i=4;i<(pl+4);i++)printf("%c",data[i]&0xff);printf("\n");
return 0;
}
int open_scsi_device(const char *dev)
{
int fd, vers;
if((fd=open(dev, O_RDWR))<0){
printf("ERROR could not open device %s\n", dev);
return -1;
}
if ((ioctl(fd, SG_GET_VERSION_NUM, &vers) < 0) || (vers < 30000)) {
printf("/dev is not an sg device, or old sg driver\n");
close(fd);
return -1;
}
return fd;
}
int main(int argc, const char *argv[])
{
int fd;
fd=open_scsi_device(device);
if(fd<0){
printf("Could not open SCSI device %s\n",device);
_exit(10);
}
scsi_inquiry_unit_serial_number(fd);
return 0;
}
FSinotify.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/select.h>
#include <sys/file.h>
#include <sys/sysinfo.h>
#include <sys/epoll.h>
#include <signal.h>
#include <linux/inotify.h>
#include <net/if.h>
#include <netinet/in.h>
struct queue_struct
{
int capacity;
int front;
int rear;
int size;
void **array;
};
struct queue_struct;
typedef struct queue_struct *queue_t;
int queue_empty (queue_t q)
{
return q->size == 0;
}
int queue_full (queue_t q)
{
return q->size == q->capacity;
}
void queue_make_empty (queue_t q)
{
q->size = 0;
q->front = 1;
q->rear = 0;
}
queue_t queue_create (int num_elements)
{
queue_t q;
q = malloc (sizeof (struct queue_struct));
if (q == NULL)
exit (-1);
q->array = malloc(sizeof (void *) * num_elements);
if (q->array == NULL)
exit (-1);
q->capacity = num_elements;
queue_make_empty (q);
return q;
}
void queue_destroy (queue_t q)
{
if (q != NULL)
{
if (q->array)
free (q->array);
free (q);
}
}
static int next_position (int v, queue_t q)
{
if (++v == q->capacity) {
v = 0;
}
return v;
}
void queue_enqueue (void *d, queue_t q)
{
if (queue_full (q))
{
return;
}
q->size++;
q->rear = next_position (q->rear, q);
q->array[q->rear] = d;
}
void *queue_front (queue_t q)
{
if (!queue_empty(q))
return q->array [q->front];
return NULL;
}
void queue_dequeue (queue_t q)
{
if (!queue_empty (q))
{
q->size--;
q->front = next_position (q->front, q);
}
}
/* This method does the dirty work of determining what happened,
then allows us to act appropriately
*/
void handle_event (struct inotify_event *event)
{
/* If the event was associated with a filename, we will store it here */
char * cur_event_filename = NULL;
/* This is the watch descriptor the event occurred on */
int cur_event_wd = event->wd;
if (event->len)
{
cur_event_filename = event->name;
}
printf("FILENAME=%s\n", cur_event_filename);
printf("watch descriptor=%d\n",cur_event_wd);
printf("\n");
/* Perform event dependent handler routines */
/* The mask is the magic that tells us what file operation occurred */
switch (event->mask)
{
/* File was accessed */
case IN_ACCESS:
printf("ACCESS EVENT OCCURRED: File \"%s\" on WD #%i\n",
cur_event_filename, cur_event_wd);
break;
/* File was modified */
case IN_MODIFY:
printf("MODIFY EVENT OCCURRED: File \"%s\" on WD #%i\n",
cur_event_filename, cur_event_wd);
break;
/* File changed attributes */
case IN_ATTRIB:
printf("ATTRIB EVENT OCCURRED: File \"%s\" on WD #%i\n",
cur_event_filename, cur_event_wd);
break;
/* File was closed */
case IN_CLOSE:
printf("CLOSE EVENT OCCURRED: File \"%s\" on WD #%i\n",
cur_event_filename, cur_event_wd);
break;
/* File was opened */
case IN_OPEN:
printf("OPEN EVENT OCCURRED: File \"%s\" on WD #%i\n",
cur_event_filename, cur_event_wd);
break;
/* File was moved from X */
case IN_MOVED_FROM:
printf("MOVE_FROM EVENT OCCURRED: File \"%s\" on WD #%i\n",
cur_event_filename, cur_event_wd);
break;
/* File was moved to X */
case IN_MOVED_TO:
printf("MOVE_TO EVENT OCCURRED: File \"%s\" on WD #%i\n",
cur_event_filename, cur_event_wd);
break;
/* Watched entry was deleted */
case IN_DELETE_SELF:
printf("DELETE_SELF EVENT OCCURRED: File \"%s\" on WD #%i\n",
cur_event_filename, cur_event_wd);
break;
/* Backing FS was unmounted */
case IN_UNMOUNT:
printf("UNMOUNT EVENT OCCURRED: File \"%s\" on WD #%i\n",
cur_event_filename, cur_event_wd);
break;
/* Too many FS events were received without reading them
some event notifications were potentially lost. */
case IN_Q_OVERFLOW:
printf("Warning: AN OVERFLOW EVENT OCCURRED: \n");
break;
case IN_IGNORED:
printf("IGNORED EVENT OCCURRED: \n");
break;
/* Some unknown message received */
default:
printf ("UNKNOWN EVENT OCCURRED for file \"%s\" on WD #%i\n",
cur_event_filename, cur_event_wd);
break;
}
}
void handle_events (queue_t q)
{
struct inotify_event *event;
while (!queue_empty (q))
{
event = queue_front (q);
queue_dequeue (q);
handle_event (event);
free (event);
}
}
int event_check (int fd)
{
struct timeval timeout;
int r;
fd_set rfds;
timeout.tv_sec = 4;
timeout.tv_usec = 0;
FD_ZERO(&rfds);
FD_SET(fd, &rfds);
r = select (fd+1, &rfds, NULL, NULL, &timeout);
return r;
}
int read_events (queue_t q, int fd)
{
char buffer[16384];
size_t buffer_i;
struct inotify_event *pevent, *event;
ssize_t r;
size_t event_size;
int count = 0;
r = read (fd, buffer, 16384);
if (r <= 0)
return r;
buffer_i = 0;
while (buffer_i < r)
{
/* Parse events and queue them ! */
pevent = (struct inotify_event *)&buffer[buffer_i];
event_size = sizeof(struct inotify_event) + pevent->len;
event = malloc(event_size);
memmove(event, pevent, event_size);
queue_enqueue(event, q);
buffer_i += event_size;
count++;
}
return count;
}
int process_inotify_events (queue_t q, int iid)
{
while (1)
{
if( !queue_empty(q) )
{
handle_events(q);
}
if (event_check(iid) > 0)
{
int r;
r = read_events(q, iid);
if (r < 0)
break;
}
}
return 0;
}
int main()
{
queue_t q;
int iid;
int wd;
q = queue_create(128);
iid = inotify_init();
wd = inotify_add_watch(iid,"/home/test/", IN_CLOSE_WRITE );
process_inotify_events(q,iid);
queue_destroy(q);
close(iid);
return 0;
}
主要工作小結
1. 架設版本控制平台 SVN
2. 專案版本控制管理
3. 專案開發環境架設 fedora8及其BSP環境
4. 管理與整合BSP
5. build image與release版本
6. 應用程式開發
心得
1. 更熟析embedded linux
2. 熟西建構root file system
3. 對linux system programming有一定的了解
沒有留言:
張貼留言