免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
楼主: upcuiling
打印 上一主题 下一主题

困扰了3个月的usb硬盘写操作问题,求思路 [复制链接]

论坛徽章:
0
21 [报告]
发表于 2006-11-24 18:40 |只看该作者
我通过打印debug信息,发现错误是从/fs/fat/misc.c 打出的
int fat_add_cluster(struct inode *inode)
{
        [。。。。]
       
        /* We must locate the last cluster of the file to add this
           new one (nr) to the end of the link list (the FAT).
          
           Here file_cluster will be the number of the last cluster of the
           file (before we add nr).
          
           last is the corresponding cluster number on the disk. We will
           use last to plug the nr cluster. We will use file_cluster to
           update the cache.
        */
        last = file_cluster = 0;
        if ((curr = MSDOS_I(inode)->i_start) != 0) {
                fat_cache_lookup(inode, INT_MAX, &last, &curr);
                file_cluster = last;
                while (curr && curr != -1){
                        file_cluster++;
                        if (!(curr = fat_access(sb, last = curr,-1))) {
                                fat_fs_panic(sb, "File without EOF");//这里打印出出错信息
                                return res;
                        }
                }
        }
        if (last) {
                fat_access(sb, last, nr);
                fat_cache_add(inode, file_cluster, nr);
        } else {
                MSDOS_I(inode)->i_start = nr;
                MSDOS_I(inode)->i_logstart = nr;
                mark_inode_dirty(inode);
        }
        if (file_cluster
            != inode->i_blocks / cluster_size / (sb->s_blocksize / 512)) {
                printk ("file_cluster badly computed!!! %d <> %ld\n",   //有时候也在这里出错
                        file_cluster,
                        inode->i_blocks / cluster_size / (sb->s_blocksize / 512));
                fat_cache_inval_inode(inode);
        }
        inode->i_blocks += (1 << MSDOS_SB(sb)->cluster_bits) / 512;

        return nr;
}

论坛徽章:
0
22 [报告]
发表于 2006-11-25 15:04 |只看该作者
似乎是在调用fat_access函数的过程中出了问题,这个函数可能是继续往下层调用usb块设备读取FAT相关的信息。
可以这样进一步分析看看:找到fat_access这个函数的定义,在里面进一步确定到底是什么原因导致这个函数的返回值为空,当然,如果顺利的话,还可以进一步往下深入,直到最终找到根本原因。

论坛徽章:
0
23 [报告]
发表于 2006-11-27 10:36 |只看该作者
/* Returns the this'th FAT entry, -1 if it is an end-of-file entry. If
   new_value is != -1, that FAT entry is replaced by it. */

int fat_access(struct super_block *sb,int nr,int new_value)
{
        return MSDOS_SB(sb)->cvf_format->fat_access(sb,nr,new_value);
}

这个函数返回-1说明,已经到了文件目录表的结尾了。
继续郁闷

论坛徽章:
0
24 [报告]
发表于 2006-11-27 23:48 |只看该作者
没遇见过。。。

论坛徽章:
0
25 [报告]
发表于 2006-11-28 11:22 |只看该作者
提示: 作者被禁止或删除 内容自动屏蔽

论坛徽章:
0
26 [报告]
发表于 2006-12-01 23:11 |只看该作者

回复 13楼 upcuiling 的帖子

除了软件的问题,有无考虑下固件的问题!

论坛徽章:
0
27 [报告]
发表于 2006-12-03 12:50 |只看该作者
换新版核心。

或者全用网络,CD-RW,DVD-RW,DVD-RAM,MO。

我很反感使用USB 存储器,因为目前很多厂商的USB设备并不是完全符合USB标准。

论坛徽章:
38
2017金鸡报晓
日期:2017-02-08 10:39:4215-16赛季CBA联赛之深圳
日期:2023-02-16 14:39:0220周年集字徽章-年
日期:2022-08-31 14:25:28黑曼巴
日期:2022-08-17 18:57:0919周年集字徽章-年
日期:2022-04-25 13:02:5920周年集字徽章-20	
日期:2022-03-29 11:10:4620周年集字徽章-年
日期:2022-03-14 22:35:1820周年集字徽章-周	
日期:2022-03-09 12:51:3220周年集字徽章-年
日期:2022-02-10 13:13:4420周年集字徽章-周	
日期:2022-02-03 12:09:4420周年集字徽章-20	
日期:2022-01-25 20:14:2720周年集字徽章-周	
日期:2022-01-13 15:12:33
28 [报告]
发表于 2006-12-04 13:22 |只看该作者
用的是2.4核心吧,换2.6试试。

论坛徽章:
2
2015年辞旧岁徽章
日期:2015-03-03 16:54:152015元宵节徽章
日期:2015-03-06 15:50:39
29 [报告]
发表于 2006-12-06 11:28 |只看该作者

我在使用SD卡的时候也出现过类似的问题
我想是不是和mount的文件系统类型有关系呢

论坛徽章:
0
30 [报告]
发表于 2006-12-06 15:45 |只看该作者
帮DING上去!
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP