static void win_hddfmt_draw_total_disk_infor() { UINT32 total_size; UINT32 free_size; char str[32]; struct statvfs stfs; char volume_name[48]; UINT8 index = 0; if(hddfmt_cur_volume<0) return; storage_index2volume((UINT8)hddfmt_cur_volume,volume_name); storage_add_parent_dir(volume_name); fs_statvfs(volume_name, &stfs); if(stfs.f_frsize >=1024) { total_size = stfs.f_frsize / 1024 * stfs.f_blocks; free_size = stfs.f_frsize / 1024 * stfs.f_bfree; } else { total_size = ( stfs.f_frsize*2) / 1024 * stfs.f_blocks /2; free_size = (stfs.f_frsize*2) / 1024 * stfs.f_bfree /2; } win_hddfmt_draw_one_infor(index++,"Volume", stfs.f_volume_name); cal_size(total_size/1024, str); win_hddfmt_draw_one_infor(index++,"Total Size", str); cal_size(free_size/1024, str); win_hddfmt_draw_one_infor(index++,"Free Size", str); cal_size((total_size-free_size)/1024, str); win_hddfmt_draw_one_infor(index++,"Used size", str); win_hddfmt_draw_one_infor(index++,"File System", stfs.f_fsh_name); }
void ide_fs_unmount(UINT32 param) { int i; char mount_name[16]; int result; struct statvfs sfs; int fd; char dirbuf[sizeof(struct dirent) + 32]; struct dirent *dire = (struct dirent *)dirbuf; unlink_device("/c", MNT_TYPE_IDE); unlink_device("/r", MNT_TYPE_IDE); fd = fs_opendir("/mnt"); while (fs_readdir(fd, dire) > 0) { fs_get_mount_name(MNT_TYPE_IDE, 0, 0, mount_name); if(!MEMCMP(&dire->d_name, &mount_name[5], 3)) { STRCPY(mount_name, "/mnt/"); strcat(mount_name, dire->d_name); FS_PRINTF("unmount: %s ...\n", mount_name); result = fs_statvfs(mount_name, &sfs); if (result < 0) { FS_PRINTF("%s is not mounted! err = %d\n", mount_name, result); FS_NOTICE_MESSAGE(MP_FS_UNMOUNT, MNT_MSG_PARAM(UNMNT_FAILED, MNT_TYPE_IDE, 0)); // IDE_MESSAGE(MP_FS_UNMOUNT, UNMNT_FAILED); continue; } result = fs_unmount(mount_name, 1); if (result < 0) { FS_PRINTF("%s unmounted failed! err = %d\n", mount_name, result); FS_NOTICE_MESSAGE(MP_FS_UNMOUNT, MNT_MSG_PARAM(UNMNT_FAILED, MNT_TYPE_IDE, 0)); // IDE_MESSAGE(MP_FS_UNMOUNT, UNMNT_FAILED); } else { FS_PRINTF("%s unmounted successed!\n", mount_name); } result = fs_rmdir(mount_name); if (result < 0) { FS_PRINTF("remove dir %s failed! err = %d\n", mount_name, result); } } } fs_closedir(fd); ide_hdd_cleanup(0); FS_NOTICE_MESSAGE(MP_FS_UNMOUNT, MNT_MSG_PARAM(UNMNT_UNMOUNT_OK, MNT_TYPE_IDE, 0)); // IDE_MESSAGE(MP_FS_UNMOUNT, UNMNT_UNMOUNT_OK); }
/* check if the disk @disk_path is exist */ static BOOL dm_is_disk_exist(const char *disk_path) { struct statvfs buf; if (strncmp(disk_path, "/dev/", 5) != 0) return FALSE; if (fs_statvfs(disk_path, &buf) < 0) return FALSE; else return TRUE; }
/* df command */ LOCAL void cmd_df(INT ac, B *av[]) { ER er; struct statvfs buf; if (ac < 2) return; er = fs_statvfs(av[1], &buf); if (er < E_OK) { P("fs_statvfs(%s) ERR [%#x]\n", av[1], er); return; } P("Blocks: total = %d free = %d blksz = %d used = %d %%\n", (W)buf.f_blocks, (W)buf.f_bfree, buf.f_frsize, ((buf.f_blocks - buf.f_bfree) * 100 + buf.f_blocks - 1) / buf.f_blocks); }
BOOL check_usb_item_is_active() { struct statvfs usb_info; BOOL ret = TRUE; if(!storage_usb_menu_item_ready()) ret = FALSE; if (fs_statvfs(MP3_ROOT_DIR, &usb_info) < 0) ret = FALSE; else if(usb_info.f_blocks == 0)//usb device do not exist or mount failure ret = FALSE; #ifdef DVR_PVR_SUPPORT else if(api_pvr_is_record_active()) { ret = FALSE; } #endif return ret; }
static PedFileSystemType dm_get_fs_type(const char *vol_path) { struct statvfs buf; if (fs_statvfs(vol_path, &buf) < 0) { DM_DEBUG("Get %s file system type failed!\n", vol_path); return PED_FS_TYPE_NONE; } else { if (STRCMP(buf.f_fsh_name, "FAT12") == 0) return PED_FS_TYPE_FAT12; else if (STRCMP(buf.f_fsh_name, "FAT16") == 0) return PED_FS_TYPE_FAT16; else if (STRCMP(buf.f_fsh_name, "FAT32") == 0) return PED_FS_TYPE_FAT32; else if (STRCMP(buf.f_fsh_name, "NTFS") == 0) return PED_FS_TYPE_NTFS; else return PED_FS_TYPE_NONE; } }
void sd_fs_unmount(UINT32 param) { int i; char mount_name[16]; int result; struct statvfs sfs; int fd; struct stat st; char dirbuf[sizeof(struct dirent) + 32]; struct dirent *dire = (struct dirent *)dirbuf; #ifdef USB_SUPPORT_HUB UINT32 msg_code = 0; struct fs_sto_param fs_param; fs_param.type = MNT_TYPE_SD; fs_param.id = 0; fs_param.partition_id = 0; #endif #if (SYS_CHIP_MODULE != ALI_S3602) unlink_device("/c", MNT_TYPE_SD); unlink_device("/r", MNT_TYPE_SD); #endif fd = fs_opendir("/mnt"); while(fs_readdir(fd, dire) > 0) { fs_get_mount_name(MNT_TYPE_SD, 0, 0, mount_name); if(!MEMCMP(&dire->d_name, &mount_name[5], 3)) { STRCPY(mount_name, "/mnt/"); strcat(mount_name, dire->d_name); FS_PRINTF("unmount: %s ...", mount_name); result = fs_statvfs(mount_name, &sfs); if(result < 0) { FS_PRINTF("the %s is not mounted!\n", mount_name); #if (SYS_CHIP_MODULE == ALI_S3602) FS_NOTICE_MESSAGE(MP_FS_UNMOUNT, MNT_MSG_PARAM(UNMNT_FAILED, MNT_TYPE_SD, 0)); // SD_MESSAGE(MP_FS_UNMOUNT, UNMNT_FAILED); #else #ifdef USB_SUPPORT_HUB fs_param.msg_code = UNMNT_FAILED; msg_code = fs_param.type<<24 | fs_param.id<<16 | fs_param.partition_id<<8 | fs_param.msg_code; #else msg_code = 1; #endif FS_NOTICE_MESSAGE(MP_FS_UNMOUNT, msg_code); #endif continue; } result = fs_unmount(mount_name, 1); if(result < 0) { FS_PRINTF("the %s is unmounted failed!\n", mount_name); #if (SYS_CHIP_MODULE == ALI_S3602) FS_NOTICE_MESSAGE(MP_FS_UNMOUNT, MNT_MSG_PARAM(UNMNT_FAILED, MNT_TYPE_SD, 0)); // SD_MESSAGE(MP_FS_UNMOUNT, UNMNT_FAILED); #else #ifdef USB_SUPPORT_HUB fs_param.msg_code = UNMNT_FAILED; msg_code = fs_param.type<<24 | fs_param.id<<16 | fs_param.partition_id<<8 | fs_param.msg_code; #else msg_code = 1; #endif FS_NOTICE_MESSAGE(MP_FS_UNMOUNT, msg_code); #endif FS_PRINTF("failed! err = %d\n", result); } else { FS_PRINTF("successed!\n"); } result = fs_rmdir(mount_name); if (result < 0) { FS_PRINTF("remove dir %s failed! err = %d\n", mount_name, result); } } } #if (SYS_CHIP_MODULE != ALI_S3602) #ifdef USB_SUPPORT_HUB fs_param.msg_code = UNMNT_PLUGOUT; msg_code = fs_param.type<<24 | fs_param.id<<16 | fs_param.partition_id<<8 | fs_param.msg_code; #else msg_code = 0; #endif FS_NOTICE_MESSAGE(MP_FS_UNMOUNT, msg_code); #ifdef USB_SUPPORT_HUB fs_param.msg_code = 102; msg_code = fs_param.type<<24 | fs_param.id<<16 | fs_param.partition_id<<8 | fs_param.msg_code; #else msg_code = 102; #endif FS_NOTICE_MESSAGE(MP_FS_UNMOUNT, msg_code); #endif fs_closedir(fd); sdio_hdd_cleanup(0); #if (SYS_CHIP_MODULE == ALI_S3602) FS_NOTICE_MESSAGE(MP_FS_UNMOUNT, MNT_MSG_PARAM(UNMNT_UNMOUNT_OK, MNT_TYPE_SD, 0)); // SD_MESSAGE(MP_FS_UNMOUNT, UNMNT_UNMOUNT_OK); #endif }
void sata_fs_unmount(UINT32 param) { int i; char mount_name[16]; int result; struct statvfs sfs; int fd; char dirbuf[sizeof(struct dirent) + 32]; struct dirent *dire = (struct dirent *)dirbuf; struct fs_sto_param fs_param; fs_param.type = MNT_TYPE_SATA; fs_param.id = 0; fs_param.partition_id = 0; fd = fs_opendir("/mnt"); while (fs_readdir(fd, dire) > 0) { fs_get_mount_name(MNT_TYPE_SATA, 0, 0, mount_name); if(!MEMCMP(&dire->d_name, &mount_name[5], 3)) { STRCPY(mount_name, "/mnt/"); strcat(mount_name, dire->d_name); FS_PRINTF("unmount: %s ...\n", mount_name); result = fs_statvfs(mount_name, &sfs); if (result < 0) { FS_PRINTF("%s is not mounted! err = %d\n", mount_name, result); fs_param.msg_code = UNMNT_FAILED; PUT_MESSAGE(MP_FS_UNMOUNT, fs_param); continue; } result = fs_unmount(mount_name, 1); if (result < 0) { FS_PRINTF("%s unmounted failed! err = %d\n", mount_name, result); fs_param.msg_code = UNMNT_FAILED; PUT_MESSAGE(MP_FS_UNMOUNT, fs_param); } else { FS_PRINTF("%s unmounted successed!\n", mount_name); } result = fs_rmdir(mount_name); if (result < 0) { FS_PRINTF("remove dir %s failed! err = %d\n", mount_name, result); } } } fs_closedir(fd); sata_hdd_cleanup(0); fs_param.msg_code = UNMNT_UNMOUNT_OK; PUT_MESSAGE(MP_FS_UNMOUNT, fs_param); return; }
void usb_fs_unmount(UINT32 nodeid) { int i; char mount_name[16]; int result; int devid; struct statvfs sfs; char dirbuf[sizeof(struct dirent) + 32]; struct dirent *dire = (struct dirent *)dirbuf; int fd; struct stat st; UINT32 msg_code = 0; int lunlist[16]; INT32 lun_num = usb_hdd_get_lunlist(nodeid, lunlist, 16); #ifdef USB_SUPPORT_HUB struct fs_sto_param fs_param; fs_param.type = MNT_TYPE_USB; fs_param.id = 0; fs_param.partition_id = 0; #endif unlink_device("/c", MNT_TYPE_USB); #if (SYS_CHIP_MODULE != ALI_S3602) unlink_device("/r", MNT_TYPE_USB); #endif for( i = 0; i<lun_num; ++i) { devid = usb_hdd_get_dev(nodeid, lunlist[i]); if(devid < 0) continue; #ifdef USB_SUPPORT_HUB fs_param.id = devid; #endif fd = fs_opendir("/mnt"); while(fs_readdir(fd, dire) > 0) { fs_get_mount_name(MNT_TYPE_USB, devid, 0, mount_name); if(!MEMCMP(&dire->d_name, &mount_name[5], 3)) { STRCPY(mount_name, "/mnt/"); strcat(mount_name, dire->d_name); FS_PRINTF("unmount: %s ...", mount_name); result = fs_statvfs(mount_name, &sfs); if(result < 0) { FS_PRINTF("the %s is not mounted!\n", mount_name); #if (SYS_CHIP_MODULE == ALI_S3602) #ifdef USB_SUPPORT_HUB FS_NOTICE_MESSAGE(MP_FS_UNMOUNT, MNT_MSG_PARAM(UNMNT_FAILED, fs_param.type, fs_param.id)); #else FS_NOTICE_MESSAGE(MP_FS_UNMOUNT, MNT_MSG_PARAM(UNMNT_FAILED, MNT_TYPE_USB, 0)); // USB_MESSAGE(MP_FS_UNMOUNT, UNMNT_FAILED); #endif #else #ifdef USB_SUPPORT_HUB fs_param.msg_code = UNMNT_FAILED; msg_code = fs_param.type<<24 | fs_param.id<<16 | fs_param.partition_id<<8 | fs_param.msg_code; #else msg_code = 1; #endif FS_NOTICE_MESSAGE(MP_FS_UNMOUNT, msg_code); #endif continue; } result = fs_unmount(mount_name, 1); if(result < 0) { FS_PRINTF("the %s is unmounted failed!\n", mount_name); #if (SYS_CHIP_MODULE == ALI_S3602) #ifdef USB_SUPPORT_HUB FS_NOTICE_MESSAGE(MP_FS_UNMOUNT, MNT_MSG_PARAM(UNMNT_FAILED, fs_param.type, fs_param.id)); #else FS_NOTICE_MESSAGE(MP_FS_UNMOUNT, MNT_MSG_PARAM(UNMNT_FAILED, MNT_TYPE_USB, 0)); // USB_MESSAGE(MP_FS_UNMOUNT, UNMNT_FAILED); #endif #else #ifdef USB_SUPPORT_HUB fs_param.msg_code = UNMNT_FAILED; msg_code = fs_param.type<<24 | fs_param.id<<16 | fs_param.partition_id<<8 | fs_param.msg_code; #else msg_code = 1; #endif FS_NOTICE_MESSAGE(MP_FS_UNMOUNT, msg_code); #endif FS_PRINTF("failed! err = %d\n", result); } else { FS_PRINTF("successed!\n"); } fs_rmdir(mount_name); } } //FS_PRINTF("fs_unmount ok!\n"); #ifdef USB_SUPPORT_HUB //fix for usb with multi-device, every device should notify APP #if (SYS_CHIP_MODULE != ALI_S3602) fs_param.msg_code = UNMNT_PLUGOUT; msg_code = fs_param.type<<24 | fs_param.id<<16 | fs_param.partition_id<<8 | fs_param.msg_code; FS_NOTICE_MESSAGE(MP_FS_UNMOUNT, msg_code); fs_param.msg_code = UNMNT_UNMOUNT; msg_code = fs_param.type<<24 | fs_param.id<<16 | fs_param.partition_id<<8 | fs_param.msg_code; FS_NOTICE_MESSAGE(MP_FS_UNMOUNT, msg_code); #endif #endif fs_closedir(fd); usb_hdd_cleanup(nodeid, lunlist[i]); #if (SYS_CHIP_MODULE == ALI_S3602) #ifdef USB_SUPPORT_HUB FS_NOTICE_MESSAGE(MP_FS_UNMOUNT, MNT_MSG_PARAM(UNMNT_UNMOUNT_OK, fs_param.type, fs_param.id)); #else FS_NOTICE_MESSAGE(MP_FS_UNMOUNT, MNT_MSG_PARAM(UNMNT_UNMOUNT_OK, MNT_TYPE_USB, 0)); #endif #endif } #ifndef USB_SUPPORT_HUB #if (SYS_CHIP_MODULE != ALI_S3602) #ifdef USB_SUPPORT_HUB fs_param.msg_code = UNMNT_PLUGOUT; msg_code = fs_param.type<<24 | fs_param.id<<16 | fs_param.partition_id<<8 | fs_param.msg_code; #else msg_code = 0; #endif FS_NOTICE_MESSAGE(MP_FS_UNMOUNT, msg_code); #ifdef USB_SUPPORT_HUB fs_param.msg_code = UNMNT_UNMOUNT; msg_code = fs_param.type<<24 | fs_param.id<<16 | fs_param.partition_id<<8 | fs_param.msg_code; #else msg_code = 2; #endif FS_NOTICE_MESSAGE(MP_FS_UNMOUNT, msg_code); #endif #endif }
/* Register volume for PVR record or timeshift. * 1. it should be call when volume mounted * @b_force: force to select volumes for pvr, don't wait other devices */ static int pvr_disk_attach_proc(BOOL b_force) { SYSTEM_DATA *sys_data = sys_data_get();; enum PVR_DISKMODE pvr_mode; char rec_vol[16], tms_vol[16]; struct statvfs buf; struct pvr_register_info pvr_reg_info; BOOL b_wait = TRUE; if (pvr_part_init_task_id != OSAL_INVALID_ID) { DM_DEBUG("pvr partition %s is initializing to %d\n", l_pvr_reg_info.mount_name, l_pvr_reg_info.disk_usage); return 0; } DM_DEBUG("Enter %s(%d) ...\n", __FUNCTION__, b_force); pvr_mode = pvr_get_cur_mode(rec_vol, tms_vol); switch (pvr_mode) { case PVR_DISK_REC_AND_TMS: case PVR_DISK_REC_WITH_TMS: DM_DEBUG("pvr partition already init (%s, %s)\n", rec_vol, tms_vol); return 0; case PVR_DISK_ONLY_REC: /* check if tms volume valid */ DM_DEBUG("pvr rec partition already init (%s, %s)\n", rec_vol, tms_vol); if ((tms_vol[0] == 0) && (STRLEN(sys_data->tms_disk) > 0) && (fs_statvfs(sys_data->tms_disk, &buf) >= 0)) { MEMSET(&pvr_reg_info, 0, sizeof(struct pvr_register_info)); STRCPY(pvr_reg_info.mount_name, sys_data->tms_disk); pvr_reg_info.disk_usage = PVR_TMS_ONLY_DISK; pvr_reg_info.sync = 1; pvr_reg_info.init_list = 0; #ifndef PVR_SPEED_PRETEST_DISABLE /* --doy, 2011-3-21*/ pvr_reg_info.check_speed = 1; #endif pvr_part_init_task_create(&pvr_reg_info); } return 0; case PVR_DISK_ONLY_TMS: /* check if rec volume valid */ DM_DEBUG("pvr tms partition already init (%s, %s)\n", rec_vol, tms_vol); if ((rec_vol[0] == 0) && (STRLEN(sys_data->rec_disk) > 0) && (fs_statvfs(sys_data->rec_disk, &buf) >= 0)) { MEMSET(&pvr_reg_info, 0, sizeof(struct pvr_register_info)); STRCPY(pvr_reg_info.mount_name, sys_data->rec_disk); pvr_reg_info.disk_usage = PVR_REC_ONLY_DISK; pvr_reg_info.sync = 1; pvr_reg_info.init_list = 1; #ifndef PVR_SPEED_PRETEST_DISABLE /* --doy, 2011-3-21*/ pvr_reg_info.check_speed = 1; #endif pvr_part_init_task_create(&pvr_reg_info); } return 0; default: DM_DEBUG("pvr partition not init\n"); break; } STRCPY(rec_vol, sys_data->rec_disk); STRCPY(tms_vol, sys_data->tms_disk); rec_vol[1] = tms_vol[1] = 'd'; rec_vol[2] = tms_vol[2] = 'e'; rec_vol[3] = tms_vol[3] = 'v'; rec_vol[8] = tms_vol[8] = '\0'; // temp for disk path, eg. "/dev/uda" if ((rec_vol[0] == 0 && tms_vol[0] == 0) || (tms_vol[0] == 0 && fs_statvfs(rec_vol, &buf) >= 0) || (rec_vol[0] == 0 && fs_statvfs(tms_vol, &buf) >= 0) || (fs_statvfs(rec_vol, &buf) >= 0 && fs_statvfs(tms_vol, &buf) >= 0)) { b_wait = FALSE; } if (b_force || !b_wait) { // register rec and tms partition dm_pvr_timer_stop(); DM_DEBUG("To register volume for PVR ...\n"); pvr_select_part(rec_vol, tms_vol); if (STRLEN(tms_vol) > 0 && STRCMP(rec_vol, tms_vol) != 0) { MEMSET(&pvr_reg_info, 0, sizeof(struct pvr_register_info)); STRCPY(pvr_reg_info.mount_name, tms_vol); pvr_reg_info.disk_usage = PVR_TMS_ONLY_DISK; pvr_reg_info.init_list = 0; #ifndef PVR_SPEED_PRETEST_DISABLE /* --doy, 2011-3-21*/ pvr_reg_info.check_speed = 1; #endif if (STRLEN(rec_vol) > 0) { // init partition takes no time when (sync == 0), call pvr_register() directly pvr_reg_info.sync = 0; pvr_register((UINT32)&pvr_reg_info, 0); } else { pvr_reg_info.sync = 1; pvr_part_init_task_create(&pvr_reg_info); } } if (STRLEN(rec_vol) > 0) { MEMSET(&pvr_reg_info, 0, sizeof(struct pvr_register_info)); STRCPY(pvr_reg_info.mount_name, rec_vol); pvr_reg_info.disk_usage = (!STRCMP(rec_vol, tms_vol)) ? PVR_REC_AND_TMS_DISK : PVR_REC_ONLY_DISK; pvr_reg_info.sync = 1; pvr_reg_info.init_list = 1; #ifndef PVR_SPEED_PRETEST_DISABLE /* --doy, 2011-3-21*/ pvr_reg_info.check_speed = 1; #endif pvr_part_init_task_create(&pvr_reg_info); } if (rec_vol) STRCPY(sys_data->rec_disk, rec_vol); if (tms_vol) STRCPY(sys_data->tms_disk, tms_vol); sys_data_save(0); } else /* we need to wait default disk ready */ { dm_pvr_timer_start(5000); } return 0; }
/* select partitions for pvr to record or timeshift automatically */ int pvr_select_part(char *rec_vol, char *tms_vol) { int i, j; char vol_path[16]; struct statvfs buf; SYSTEM_DATA *sys_data = sys_data_get(); DiskInfo *p_disk; if (rec_vol) { if ((sys_data->rec_disk[0] != 0) && (fs_statvfs(sys_data->rec_disk, &buf) >= 0)) STRCPY(rec_vol, sys_data->rec_disk); else rec_vol[0] = 0; } if (tms_vol) { if ((sys_data->tms_disk[0] != 0) && (fs_statvfs(sys_data->tms_disk, &buf) >= 0)) STRCPY(tms_vol, sys_data->tms_disk); else tms_vol[0] = 0; } MEMSET(vol_path, 0, 16); if ((rec_vol && rec_vol[0] == 0) || (tms_vol && tms_vol[0] == 0)) { /* select the first volume for pvr */ for (i = 0; i < MAX_USB_DISK_NUM; ++i) { if (vol_path[0] != 0) break; if ((p_disk = g_dm.UsbDisks[i]) == NULL) continue; for (j = 0; j < MAX_PARTS_IN_DISK; ++j) { if ((p_disk->parts[j].PartExist == 1) && (p_disk->parts[j].FileSystemType != PED_FS_TYPE_NONE)) { sprintf(vol_path, "/mnt/ud%c%c", i+'a', j+'1'); break; } } } for (i = 0; i < MAX_IDE_DISK_NUM; ++i) { if (vol_path[0] != 0) break; if ((p_disk = g_dm.IdeDisks[i]) == NULL) continue; for (j = 0; j < MAX_PARTS_IN_DISK; ++j) { if ((p_disk->parts[j].PartExist == 1) && (p_disk->parts[j].FileSystemType != PED_FS_TYPE_NONE)) { sprintf(vol_path, "/mnt/hd%c%c", i+'a', j+'1'); break; } } } } if (vol_path[0] != 0) { if (rec_vol && rec_vol[0] == 0) STRCPY(rec_vol, vol_path); if (tms_vol && tms_vol[0] == 0) STRCPY(tms_vol, vol_path); } if (rec_vol && rec_vol[0] != 0) DM_DEBUG("%s() select REC vol: %s\n", __FUNCTION__, rec_vol); if (tms_vol && tms_vol[0] != 0) DM_DEBUG("%s() select TMS vol: %s\n", __FUNCTION__, tms_vol); return 0; }
/* Un-register pvr volume if necessary * 1. it should be call when disk detach */ static int pvr_disk_detach_proc() { struct statvfs buf; enum PVR_DISKMODE pvr_mode; char rec_vol[16], tms_vol[16], initing_vol[16]; UINT8 initing_vol_usage = 0; BOOL b_pvr_part_detached = FALSE; DM_DEBUG("Enter %s() ...\n", __FUNCTION__); if (pvr_part_init_task_id != OSAL_INVALID_ID) { DM_DEBUG("pvr partition %s is initializing to %d\n", l_pvr_reg_info.mount_name, l_pvr_reg_info.disk_usage); STRCPY(initing_vol, l_pvr_reg_info.mount_name); initing_vol_usage = l_pvr_reg_info.disk_usage; } else { initing_vol[0] = 0; } pvr_mode = pvr_get_cur_mode(rec_vol, tms_vol); BOOL rec_vol_detach = ((rec_vol[0] != 0) && (fs_statvfs(rec_vol, &buf) < 0)); BOOL tms_vol_detach = ((tms_vol[0] != 0) && (fs_statvfs(tms_vol, &buf) < 0)); if ((initing_vol[0] != 0) && (fs_statvfs(initing_vol, &buf) < 0)) { if (STRCMP(initing_vol, rec_vol) != 0) { DM_DEBUG("pvr detach initializing volume %s\n", initing_vol); pvr_detach_part(initing_vol, initing_vol_usage); b_pvr_part_detached = TRUE; } initing_vol[0] = 0; } if (rec_vol_detach || tms_vol_detach) { /* a disk that used by pvr is detached */ if (STRCMP(rec_vol, tms_vol) == 0) { DM_DEBUG("pvr detach %s\n", rec_vol); pvr_detach_part(rec_vol, PVR_REC_AND_TMS_DISK); b_pvr_part_detached = TRUE; } else { if (rec_vol_detach) { DM_DEBUG("pvr detach %s\n", rec_vol); pvr_detach_part(rec_vol, PVR_REC_ONLY_DISK); b_pvr_part_detached = TRUE; } if (tms_vol_detach) { DM_DEBUG("pvr detach %s\n", tms_vol); pvr_detach_part(tms_vol, PVR_TMS_ONLY_DISK); b_pvr_part_detached = TRUE; } } } if ((pvr_get_cur_mode(rec_vol, tms_vol) == PVR_DISK_INVALID) && (initing_vol[0] == 0)) { DM_DEBUG("pvr detach all volume, do clean up!\n"); api_pvr_clear_up_all(); } if (b_pvr_part_detached) { struct dvr_HDD_info hdd_info; pvr_get_HDD_info(&hdd_info); api_pvr_check_level(&hdd_info); } return 0; }