Mon 14 Oct 23:09:15 CEST 2024
This commit is contained in:
		
							parent
							
								
									d81c11b00e
								
							
						
					
					
						commit
						54f272ddb4
					
				
							
								
								
									
										42
									
								
								user/test/filedescribetest.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								user/test/filedescribetest.c
									
									
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,42 @@ | ||||||
|  | #include "library/errno.h" | ||||||
|  | #include "library/syscalls.h" | ||||||
|  | #include "library/string.h" | ||||||
|  | #include "library/user-io.h" | ||||||
|  | #include "library/malloc.h" | ||||||
|  | 
 | ||||||
|  | #define TAG_BUFFER_SIZE 256 | ||||||
|  | 
 | ||||||
|  | int main(int argc, char *argv[]) | ||||||
|  | { | ||||||
|  | 	char *tag_value = "A simple tag string"; | ||||||
|  | 
 | ||||||
|  | 	printf("Generating/typing all file descriptors.\n"); | ||||||
|  | 	int type = -2; | ||||||
|  | 	int tag = -3; | ||||||
|  | 
 | ||||||
|  | 	int window_descriptor = syscall_open_window(KNO_STDWIN, 1, 1, 1, 1); | ||||||
|  | 	if(!window_descriptor) { | ||||||
|  | 		return 1; | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	syscall_object_set_tag(window_descriptor, tag_value); | ||||||
|  | 
 | ||||||
|  | 	int last_descriptor = syscall_object_max(); | ||||||
|  | 	printf("Highest allocated FD: %d\nLast Descriptor: %d\n", window_descriptor, last_descriptor); | ||||||
|  | 
 | ||||||
|  | 	char *tag_string = malloc(sizeof(char) * TAG_BUFFER_SIZE); | ||||||
|  | 
 | ||||||
|  | 	for(int descriptor = 0; descriptor <= last_descriptor; descriptor++) { | ||||||
|  | 		type = syscall_object_type(descriptor); | ||||||
|  | 		tag = syscall_object_get_tag(descriptor, tag_string, TAG_BUFFER_SIZE); | ||||||
|  | 		printf("FD: %d is of type: %d, with tag: ", descriptor, type); | ||||||
|  | 		if(tag != 0) { | ||||||
|  | 			printf("\"%s\"\n", tag_string); | ||||||
|  | 		} | ||||||
|  | 		if(tag == 0) { | ||||||
|  | 			printf("%d\n", tag); | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	return 0; | ||||||
|  | } | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user