Code :
/** Change the permission bits of a file */ static int hello_chmod (const char * path, mode_t mode) { Inode *current; unsigned int num_ino = 0; unsigned char * ptr_deb = NULL, * ptr_fin = NULL, name_search[32]; time_t time_buf[2]; if(path == NULL){ fprintf(stderr,"path == NULL, %d %s\n", __LINE__, __FILE__); return FALSE; } current = root; ptr_deb = (unsigned char *)(path) + 1; printf("klmp_chmod path : %s", path); if (strcmp(path, "/" ) == 0) { Set_Inode_Mode (root, S_IFDIR | mode); time_buf[0] = time_buf[1] = time(NULL); Set_Inode_Time (root, time_buf); Clean_Fuse(); return TRUE; } while( (ptr_fin = (unsigned char *)strchr((const char *)ptr_deb, '/')) != NULL ){ memset(name_search,0,32); strncpy((char *)name_search, (char *)ptr_deb, ptr_fin - ptr_deb - 1); if( FALSE == Search_Element(current, name_search, &num_ino) ){ fprintf(stderr,"%s non trouvee\n", name_search); return FALSE; } current = root + num_ino; ptr_deb = ptr_fin + 1; } memset(name_search,0,32); strcpy((char *)name_search, (char *)ptr_deb); if( FALSE == Search_Element(current, name_search, &num_ino) ){ fprintf(stderr,"%s non trouvee\n", name_search); return FALSE; } current = root + num_ino; time_buf[0] = time_buf[1] = time(NULL); Set_Inode_Time (current, time_buf); Set_Inode_Mode (current, mode); return TRUE; }
|