Esempio n. 1
0
int main(int argc, char *argv[]){
	disk_info_t *disk_info, *disk_list;
	partition_info_t *partition_info;
	char buf[PATH_MAX];

	usb_dbg("%d: Using myself to get information:\n", VERSION);

	if(argc == 3){
		get_mount_path("sdb1", buf, PATH_MAX);
		printf("buf=%s.\n", buf);
	}
	else if(argc == 2){
		if(is_disk_name(argv[1])){ // Disk
			usb_dbg("%d: Get disk(%s)'s information:\n", VERSION, argv[1]);

			create_disk(argv[1], &disk_info);

			print_disk(disk_info);

			free_disk_data(&disk_info);
		}
		else{
			usb_dbg("%d: Get partition(%s)'s information:\n", VERSION, argv[1]);

			create_partition(argv[1], &partition_info);

			print_partition(partition_info);

			free_partition_data(&partition_info);
		}
	}
	else{
		usb_dbg("%d: Get all Disk information:\n", VERSION);

		disk_list = read_disk_data();

		print_disks(disk_list);

		free_disk_data(&disk_list);
	}

	return 0;
}
Esempio n. 2
0
void cmd_parser(char *content)
{
    //printf("\n path is %s\n",path);

    //pathlist.number++;    //add by alan

    int type;
    char path[256];
    char temp[512];
    int len;
    int path_wd;
    //int i;
    //int num = pathlist.number;
    const char *split = "@";
    char *p;
    //int status = 0;
    char *m_path = NULL;

    memset(path,0,sizeof(path));
    memset(temp,0,sizeof(temp));

    p=strtok(content,split);
    int j=0;
    while(p!=NULL)
    {
        switch (j)
        {
        case 0 :
            type = atoi(p);
            break;
        case 1:
            strcpy(path,p);
            break;
        default:
            break;
        }

        j++;
        p=strtok(NULL,split);
    }

    //printf("inotify type is %d,path is %s\n",type,path);

    len = strlen(path);
    if(path[len - 1] == '/')
        strncpy(temp,path, len - 1 );
    else
        strcpy(temp,path);


    //status = check_path_exist(type,temp);     //del by alan

    if(type == ASUSWEBSTORAGE && strlen(mount_path) == 0)
    {
        m_path = get_mount_path(temp,4);

        if(NULL == m_path)
        {
            printf("get mount path fail from %s\n",temp);
        }
        else
        {
            memset(mount_path,0,sizeof(mount_path));
            strcpy(mount_path,m_path);
            free(m_path);
        }
    }



    /*switch (status)
    {
    case 0:*/ // path is new add


    //pthread_mutex_lock(&mutex_inotify_fd);
    path_wd = add_all_folders(temp,type);
    //pthread_mutex_unlock(&mutex_inotify_fd);
    pthread_mutex_lock(&mutex_pathlist);
    pathlist_tmp = (Folder *)malloc(sizeof(Folder));
    pathlist_tmp->type = type;
    pathlist_tmp->wd = path_wd;
    pathlist_tmp->name = (char *)malloc(sizeof(char)*(strlen(temp)+1));
    strcpy(pathlist_tmp->name,temp);
    pathlist_tmp->next = NULL;

    pathlist_tail->next = pathlist_tmp;
    pathlist_tail = pathlist_tmp;
    pthread_mutex_unlock(&mutex_pathlist);




#if 0
    Folder **folderlist_tmp;
    folderlist_tmp = (Folder **)malloc(sizeof(Folder *)*(num));
    folderlist_tmp[num-1]->type = type;



    for(i = 0;i < num;i++)
    {
        pathlist.folderlist[i] = (Folder *)malloc(sizeof(Folder));

    }


    memset(pathlist.folderlist[num].name,0,sizeof(pathlist.folderlist[num].name));
    strcpy(pathlist.folderlist[num].name,temp);
    //pathlist.folderlist[num].type = type;
    pathlist.number++;
    //add_new_watch_item = 1;
    pthread_mutex_lock(&mutex);
    if(pathlist.number == 1)
        keep_running = 1;
    else
        keep_running = 0;
    pthread_mutex_unlock(&mutex);
    break;
   case 1:    // path has exist;
       break;
   case 2:     //update exist path;
       //add_new_watch_item = 1;
   default:
       break;
   }
Esempio n. 3
0
void cmd_parser(char *content)
{
   //printf("\n path is %s\n",path);

   int type;
   char path[256];
   char temp[512];
   int len;
   int i;
   int num = pathlist.number;
   const char *split = "@";
   char *p;
   int status;
   char *m_path = NULL;

   memset(path,0,sizeof(path));
   memset(temp,0,sizeof(temp));

   p=strtok(content,split);
   int j=0;
   while(p!=NULL)
   {
       switch (j)
       {
       case 0 :
           type = atoi(p);
           break;
       case 1:
            strcpy(path,p);
            break;
       default:
           break;
       }

       j++;
       p=strtok(NULL,split);
   }

   //printf("inotify type is %d,path is %s\n",type,path);

   len = strlen(path);
   if(path[len - 1] == '/')
         strncpy(temp,path, len - 1 );
   else
         strcpy(temp,path);


   status = check_path_exist(type,temp);

   if(type == ASUSWEBSTORAGE && strlen(mount_path) == 0)
   {
       m_path = get_mount_path(temp,4);

      if(NULL == m_path)
      {
          printf("get mount path fail from %s\n",temp);
      }
      else
      {
          memset(mount_path,0,sizeof(mount_path));
          strcpy(mount_path,m_path);
          free(m_path);
      }
   }



   switch (status)
   {
   case 0: // path is new add
       strcpy(pathlist.folderlist[num].name,temp);
       pathlist.folderlist[num].type = type;
       pathlist.number++;
       add_new_watch_item = 1;

       break;
   case 1:    // path has exist;
        break;
   case 2:     //update exist path;
       add_new_watch_item = 1;
   default:
       break;
   }

  /*
  if( check_path_exist(temp) == 0 )
   {
      strcpy(pathlist.folderlist[num].name,temp);
      pathlist.number++;
      add_new_watch_item = 1;
   }
   */

   for( i = 0; i <pathlist.number;i++)
      printf("folder is %s \n",pathlist.folderlist[i].name);
}