Пример #1
0
void g_free_all_handles(int task_id) /* Should only be called in tasker */
{
	mem_entry *cur_entry = &mem_array[mem_handles];
	file_entry *cur_file_entry = &file_array[file_handles];

	int not_lock_dos = !islocked(DOS_SEM);
	int current = mem_handles;

	if (not_lock_dos) lock_dos(440);

	while (current > 0)
	 {
	   cur_entry--;
	   current--;
	   if ((cur_entry->task_id == task_id) && (!cur_entry->kept_open) &&
		   (!(cur_entry->empty)))
		{
		  free_some_memory(cur_entry->memory_pointer);
		};
	 };

	current=file_handles;
	while (current > 0)
	 {
	   current--;
	   cur_file_entry--;
	   if ((cur_file_entry->task_id == task_id) && (!cur_file_entry->kept_open))
		{
		  fclose(cur_file_entry->file_pointer);
		  delete_file_entry(current);
		};
	 };
	if (not_lock_dos) unlock_dos();
};
Пример #2
0
int g_fclose(FILE *file_pointer)
{
	int not_lock_dos = !islocked(DOS_SEM);
	int file_point;
	int result=0;

	if (not_lock_dos) lock_dos(443);
	file_point = find_file_pointer(file_pointer);
	if (file_point != -1)
	 {
	  result=fclose(file_pointer);
	  delete_file_entry(file_point);
	 };
	if (not_lock_dos) unlock_dos();
	return (result);
};
Пример #3
0
int hdbm_delete(hdbm db, datum key)
/*
  Delete the entry associated with key
  
  return
  
  1 if key was matched and delete successful
  0 otherwise
  */
{
    int index;
    entry *cur, *prev;
    
    call_stats.deletes++;
    
    if (!hdbm_check(db)) {
	fprintf(stderr, "hdbm_delete: invalid database handle %d\n", db);
	return 0;
    }
    
    search(hash_tables[db].table, key, &index, &cur, &prev);
    
    if (cur) {
	if (prev)
	    prev->next = cur->next;
	else
	    hash_tables[db].table[index] = cur->next;
	datum_free(cur->value);
	
	if (hash_tables[db].file)
	    delete_file_entry(db, cur);
	
	datum_free(cur->key);	/* Free up memory for key/value/entry */
	datum_free(cur->value);
	hdbm_free((void *) cur, sizeof(*cur));
	
	hash_tables[db].nentry[index]--;
	return 1;
    }
    else
	return 0;
}
Пример #4
0
static int msfs_rm (file_entry_t * entry, int recursive) {
	if(entry == NULL) return -ENOENT;
	if(msfs_error != 0) return msfs_error;

	inode_t inode = read_inode(entry->address);

	addr_t cur_addr = 0;
	int ret;

	if(recursive && is_directory(&inode)) {
		file_entry_t * file_entry;
		for(file_entry = next_file_entry(&inode, &cur_addr); file_entry != NULL; file_entry = next_file_entry(&inode, &cur_addr)) {
			if(strcmp(file_entry->name, ".") != 0 && strcmp(file_entry->name, "..") != 0) {
				ret = msfs_rm(file_entry, 1);
				if(ret != 0) return ret;
			}
			free_file_entry(file_entry);
		}
	}

	delete_file_entry(entry);
	free_file_entry(entry);
	return msfs_error;
}