Changeset 712

Show
Ignore:
Timestamp:
12/19/06 10:32:42 (2 years ago)
Author:
chengyu
Message:

deal with unstable FAT32 fs

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/mwfetcher/CHANGELOG

    r708 r712  
    11v0.1.0 
     2* Added aborting mechanism if 'fsck.vfat -y' failed when scans FAT32 file system. 
    23* Added filtrate_sample function to ease filter adding. 
    34* Added "-t vfat" option since the vfat file system mount option is not compatible 
  • trunk/mwfetcher/install

    r704 r712  
    2222fi 
    2323 
    24 /bin/cp -u ./src/config $HOME/.mwfetcher/ 
     24if [ ! -e $HOME/.mwfetcher/config ]; then 
     25        /bin/cp -u ./src/config $HOME/.mwfetcher/ 
     26fi 
    2527/bin/cp ./src/mwfetcher /usr/sbin/ 
    2628chmod 755 /usr/sbin/mwfetcher 
  • trunk/mwfetcher/src/mwfetcher

    r708 r712  
    9696        local option="" 
    9797        if [ $fs_type = "vfat" ]; then 
     98                fsck.vfat -y /dev/nb0 > /dev/null 
     99                if [ $? -ne 0 -a $? -ne 1 ]; then 
     100                        echo "$PROGRAM: fsck.vfat failure, abort" 
     101                        umount_vmdisk "$mount_dir" 
     102                        return 1 
     103                fi 
     104                sleep 2 
    98105                option="utf8" 
    99106        else 
     
    101108        fi 
    102109         
    103         mount -o "$option" /dev/nb0 "$mount_dir" 2>&1 > /dev/null 
     110        if ! mount -o "$option" /dev/nb0 "$mount_dir" > /dev/null; then 
     111                echo "$PROGRAM: mount failure, abort" 
     112                umount_vmdisk "$mount_dir" 
     113                return 1 
     114        fi 
     115        #mount /dev/nb0 "$mount_dir" 2>&1 > /dev/null 
    104116 
    105117        #echo "Finished" 
     
    127139                echo "$PROGRAM: good list type(MD5) does not match bad list type(normal)" 
    128140                umount_vmdisk "$mount_dir" 
    129                 exit
     141                return
    130142        elif [ $check = "Normal" ] && [ $md5 == 1 ]; then 
    131143                echo "$PROGRAM: good list type(Normal) does not match bad list type(MD5)" 
    132144                umount_vmdisk "$mount_dir" 
    133                 exit
     145                return
    134146        fi 
    135147 
     
    191203        local sample_path="$1" 
    192204 
    193         if [ -n "$(file "$sample_path" | grep executable | grep MS)" ]; then 
     205        if [ ! -s "$sample_path" ]; then 
     206                return 1 
     207        elif [ -n "$(echo ${sample_path##*/} | grep ^fsck)" ]; then 
     208                return 1 
     209        elif [ $(ls -l "$sample_path" | awk '{print $5}') == 57856 ]; then 
     210                return 1 
     211        elif [ -n "$(file "$sample_path" | grep executable | grep MS)" ]; then 
    194212                return 0 
    195213        else 
     
    333351 
    334352process (){ 
    335         mount_vmdisk "$vm_dir" "$mount_dir" 
     353        if ! mount_vmdisk "$vm_dir" "$mount_dir"; then 
     354                return 1 
     355        fi 
     356         
    336357        if [ $fetch == 1 ]; then 
    337         fetch_samples "$mount_dir" "$submit_dir" 
    338         fi 
     358                fetch_samples "$mount_dir" "$submit_dir" 
     359        fi 
     360         
    339361        if [ $save_log == 1 ]; then 
    340362                save_logs "$mount_dir" "$log_dir" 
    341363        fi 
    342         scan_disk "$mount_dir" "$scan_dir" "$good_list" "$vm_file".bad 
     364         
     365        if ! scan_disk "$mount_dir" "$scan_dir" "$good_list" "$vm_file".bad; then 
     366                return 1 
     367        fi 
     368 
    343369        submit_diff "$mount_dir" "$submit_dir" 
    344370        umount_vmdisk "$mount_dir" 
     
    420446cfg_file=${cfg_file:-"$home_dir/config"} 
    421447batch=${batch:-0} 
    422 fs_type=${fs_type:-""} 
     448fs_type=${fs_type:-"other"} 
    423449 
    424450echo "MwFetcher v$version" 
     
    435461        save_log=1 
    436462    while read vmxfile; do 
    437                if [ -n "$(echo $vmxfile | grep ^#)" ]; then 
    438                        continue 
    439                fi 
     463        if [ -n "$(echo $vmxfile | grep ^#)" ]; then 
     464                continue 
     465        fi 
    440466        vm_file=${vmxfile##*/} 
    441467        vm_file=${vm_file/.vmx/} 
     
    445471                log_dir="$home_dir/logs/$vm_file" 
    446472        process 
     473        sleep 5 
    447474    done < $cfg_file 
    448475    exit 0