www.pudn.com > LFYOS.zip > attribute.c


 
#include"../include/os.h" 
 
#define WRONG_FILE_NUMBER	-1 
#define WRONG_FILE_STATE	-3 
#define WRONG_CAPABILITY	-4 
#define WRONG_SEMAPHORE		-5 
#define NO_FREE_BLOCK		-6 
 
int query_file_window_attribute(union memory_call_parameter *par) 
{ 
	int fd; 
	struct file_window *f; 
 
	fd=par->file_attribute.file_window_id; 
	if((fd<0)||(fd>=(*(memory_body->file_number)))) 
		return WRONG_FILE_NUMBER; 
	f=memory_body->file_window+fd; 
	if(f->state!=FILE_OPEN) 
		return WRONG_FILE_STATE; 
	if(!KERNEL_COMPARE_CAPABILITY((f->file.capability), 
		(par->file_attribute.capability))) 
			return WRONG_CAPABILITY; 
	COPY_FILE((f->file),(par->file_attribute.file)); 
	return 0; 
} 
 
int set_file_window_attribute(union memory_call_parameter *par) 
{ 
	int fd; 
	struct file_window *f; 
 
	fd=par->file_attribute.file_window_id; 
	if((fd<0)||(fd>=(*(memory_body->file_number)))) 
		return WRONG_FILE_NUMBER; 
	f=memory_body->file_window+fd; 
	if(f->state!=FILE_OPEN) 
		return WRONG_FILE_STATE; 
	if(!KERNEL_COMPARE_CAPABILITY((f->file.capability), 
		(par->file_attribute.capability))) 
			return WRONG_CAPABILITY; 
	COPY_FILE((par->file_attribute.file),(f->file)); 
	return 0; 
}