注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

西安数据恢复

西安数据恢复,西安数据恢复中心,咨询热线:18091827513

 
 
 

日志

 
 

西安数据恢复之硬盘格式化其实跟固件关系  

2017-01-07 13:20:47|  分类: 西安数据恢复 |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

硬盘格式化其实跟固件紧密相联

说到低级格式化,大家可能不陌生,很多SCSI卡的BIOS里都带了个小工具可以做到,但是如果我问你格式化进行到多少了,你就不能回答上来了,能不能象校验磁盘一样可以看到进度呢,答案是肯定的。不过是让硬盘的FIRMWARE一个一个BLOCK的执行格式化,发现坏道就把他仍到P——LIST里,格完了还不需要校验,更省时间,剩下的咱们不过是作个状态监视就可以了。

既然是硬盘FIRMWARE来执行格式化,不需要占用系统的资源那样就可以几个硬盘一起来格式化,一个状态监视他们所有设备的进度,更省了大家的时间。

这个功能其实是厂家的内部功能,你让它开始格式化了,你还可以用计算机干其他的活儿,只要不断电,硬盘会一直到任务完成为止,在这期间内,即使你拔掉信号线也终止不了任务。

下面三部分讲的就是怎样实现我上面说的,自己慢慢理解吧。

更多案例:http://www.data-029.com 


void multi_drive_format_list(LISTPTR *ptr) //
选择多个需要格式化的设备
{
int w, done= 0, line, n, key, page= 0, fw, lines, drives_busy;
int purge_glist= 0, choice= 0, drive_ok;
unsigned int blocksize;
SCSI *sp;
LIST *l, *disp_start;
struct bg_struct *bg;
struct tm *t;
time_t update_t, tt;

list_select("Data on all selected disks will be destroyed! Continue?",
&choice, fortune(overwrite_no), fortune(overwrite_yes), NULL);
if (choice!= 1) return;

if (format_parameters_ask(&blocksize, &purge_glist)== -1) return;

log_printf(1, "Multiple drive format started\n");
drive_ok= 0;
l= ptr->head;
while(l)
{
sp= l->otherinfo;
bg= (struct bg_struct *)memalloc(sizeof(struct bg_struct));
bg->s= sp;
l->otherinfo= bg;

format_command_set(sp, blocksize, purge_glist);

sp->s.data_buffer[1]|= 0x02;
sp->s.scsi_command[1]|= 0x10;
scsi_execute_bg(sp);

tt= time(0)+ 5;
while (sp->s.status== 0 && time(0) < tt);
if (sp->s.status!= 1)
{

format_command_set(sp, blocksize, purge_glist);
scsi_execute_bg(sp);
log_printf(0, "Formating %s\n", l->text);
}
else
{
drive_ok++;
log_printf(0, "Formating (immediate) %s\n", l->text);
}

time(&bg->start_t);
l= l->next;
}

fw= foot_window(1, CYAN<<4|BLUE);
cputs(" Esc=Exit Tab=Sense info");
w= window_create(0, 4, 0, 24, BLUE<<4|LIGHTGRAY, BORDER_SINGLE,
_NOCURSOR, BLUE<<4|YELLOW, "Format multiple drives at once");
lines= warr[w].winyy- warr[w].winy-2;

gotoxy(1,1);
cprintf("Drives selected to format : %u", list_count(ptr));
log_printf(0, "%u drive(s) total\n", list_count(ptr));
gotoxy(40,1);
cprintf("Drives busy :");
gotoxy(1,2);
cprintf("%-30.30s %-10.10s %-8.8s", "ID Drive", "Status", "Elapsed");

if (drive_ok)
{
message("There are %u drive(s) that support the Format Immediate\r\n"
"bit see the \"format progress indicator\" option to see when\r\n"
"the drive(s) are finished formating", drive_ok);
}
update_t= time(0);
disp_start= ptr->head;

while(!done)
{
drives_busy= 0;
l= ptr->head;
while(l)
{
bg= l->otherinfo;
sp= bg->s;

if (sp->s.status)
{
if (!bg->done)
{
bg->done= 1;
bg->start_t= time(0)- bg->start_t+86400;
t= gmtime(&bg->start_t);
log_printf(1, "Format done on device %30.30s\n"
"status=%s, time elapsed %02u:%02u:%02u\n", l->text,
aspi_status_name(sp->s.status), t->tm_hour, t->tm_min, t->tm_sec);
if (sp->s.status!= 1)
{
log_printf(0, "Error: %s - %s\n", sense_key_short(sp),
sense_code_des cription(sp));
}
}
}
else
drives_busy++;
l= l->next;
}

while(kbhit())
{
key= readkey();
switch(key)
{
case KEY_ESC:
if (drives_busy== 0)
done= 1;
else
{
message("You cannot exit now (there's %u drive(s) still busy)\r\n"
"\r\n"
"%s", drives_busy, fortune(fun_message));
}
break;
case KEY_PGDN:
l= disp_start;
for (n= 0; n<= lines && l; n++)
l=l->next;
if (l)
disp_start= l;
else
disp_start= ptr->tail;
gotoxy(1,3);
clrscr_rest();
break;
case KEY_HOME:
disp_start= ptr->head;
break;
case KEY_TAB:
page= !page;
break;
}
update_t= time(0);
}

if (update_t <= time(0) )
{
gotoxy(54,1);
cprintf("%u", drives_busy);

l= disp_start;
line= 0;
while(l)
{
bg= l->otherinfo;
sp= bg->s;

gotoxy(1,line+3);
if (!page)
{
cprintf("%30.30s ", l->text);
cprintf("%-10.10s ", aspi_status_name(sp->s.status));
if (!bg->done)
t= time_elapsed(bg->start_t);
else
t= gmtime(&bg->start_t);
cprintf("%02u:%02u:%02u", t->tm_hour, t->tm_min, t->tm_sec);
clreol();
}
else
{
print_sense_info_short(sp);
clreol();
}

if (line < lines)
{
line++;
l= l->next;
}
else
l= NULL;
}
update_t= time(0)+config->screen_update;

}
}


l= ptr->head;
while(l)
{
bg= l->otherinfo;
sp= bg->s;
free(bg);
l->otherinfo= sp;
l= l->next;
}

window_destroy(w);
window_destroy(fw);

}

void format_progress() //这是看状态执行进度的
{
int w, done= 0, line, n, key, page= 0, fw, lines, drives_busy;
int rv;
unsigned int progress;
SCSI *sp, *s;
LIST *l, *disp_start, *ll;
LISTPTR *ptr;
time_t update_t;

ptr= list_init();
l= driveptr->head;
sp= scsi_init(32);
while(l)
{
if (l->marked!= 0xff)
{
idcpy(sp, (SCSI *)l->otherinfo);
clear_cdb(sp);
clear_data_buffer(sp);
rv= scsi_execute(sp, 0);
if (rv!= 1)
{
if (get_sense_code_and_qual(sp)== 0x0404)
{
ll= list_add(ptr, l->text);
s= scsi_init(32);
idcpy(s, sp);
ll->otherinfo= s;
}
}
}
l= l->next;
}
scsi_destroy(sp);

if (ptr->head)
{
fw= foot_window(1, CYAN<<4|BLUE);
cputs(" Esc=Exit Tab=Sense info");
w= window_create(0, 4, 0, 24, BLUE<<4|LIGHTGRAY, BORDER_SINGLE,
_NOCURSOR, BLUE<<4|YELLOW, "Format progress indicators");
lines= warr[w].winyy- warr[w].winy-2;

gotoxy(1,1);
cprintf("Drives busy formating : %u", list_count(ptr));
gotoxy(40,1);
cprintf("Drives busy :");
gotoxy(1,2);
cprintf("%-30.30s %-10.10s %-8.8s", "ID Drive", "Status", "%Done");

update_t= time(0);
disp_start= ptr->head;

while(!done)
{
while(kbhit())
{
key= readkey();
switch(key)
{
case KEY_ESC:
done= 1;
break;
case KEY_PGDN:
l= disp_start;
for (n= 0; n<= lines && l; n++)
l=l->next;
if (l)
disp_start= l;
else
disp_start= ptr->tail;
gotoxy(1,3);
clrscr_rest();
break;
case KEY_HOME:
disp_start= ptr->head;
break;
case KEY_TAB:
page= !page;
break;
}
update_t= time(0);
}

if (update_t <= time(0) )
{
l= disp_start;
line= 0;
drives_busy= 0;
while(l)
{
sp= l->otherinfo;
clear_cdb(sp);
clear_data_buffer(sp);
rv= scsi_execute(sp, 0);
if (rv!= 1)
{
if (get_sense_code_and_qual(sp)== 0x0404)
{
drives_busy++;
}
}

gotoxy(1,line+3);
if (!page)
{
cprintf("%30.30s ", l->text);
cprintf("%-10.10s ", sense_key_short(sp));
if (sp->s.scsi_command[sp->s.scsi_command_length+15] & 0x80)
{
progress= swapint(*(unsigned int *)
&sp->s.scsi_command[sp->s.scsi_command_length+16]);
cprintf("%4.1lf ",
((float)progress / (float)65536) * 100);

}
else
{
cprintf("%8s", "N/A ");
}

clreol();
}
else
{
print_sense_info_short(sp);
clreol();
}

if (line < lines)
{
line++;
l= l->next;
}
else
l= NULL;
}
gotoxy(54,1);
cprintf("%u", drives_busy);

update_t= time(0)+config->screen_update;
}
}

window_destroy(w);
window_destroy(fw);
}
else
{
message("No drives are currently formatting");
}
scsi_list_destroy(ptr);
list_destroy(ptr);
}

void mdrive_format() //按照上面选择的设备,让他们执行定义的格式化动作
{
LISTPTR *ptr, *ptr2;
LIST *l;
SCSI *sp;
int fw;

ptr= list_init();
ptr2= list_init();

l= NULL;
fw= foot_window(1, CYAN<<4|BLUE);
cputs(" Esc=Exit Space=Mark drive Enter=Start");

scsi_list_make(ptr, driveptr, md_dad);
l= list(ptr, "Select drive(s) to format", l, 16, LIST_MARK);
window_destroy(fw);

if (l)
{
scsi_list_make(ptr2, ptr, md_marked);
if (ptr2->head)
{
mdrive_format_list(ptr2);
update_header();
}
else
message("No device selected.");

scsi_list_destroy(ptr);
scsi_list_destroy(ptr2);
}

list_destroy(ptr);
list_destroy(ptr2);
}

 

  评论这张
 
阅读(10)| 评论(0)
推荐 转载

历史上的今天

在LOFTER的更多文章

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017