Changeset 768
- Timestamp:
- 07/09/08 18:45:59 (2 months ago)
- Files:
-
- 1 modified
-
Whitix/branches/fs/user/system/moduleadd.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
Whitix/branches/fs/user/system/moduleadd.c
r551 r768 17 17 FILE* file=fopen(name, "r"); 18 18 unsigned int size; 19 char* buf;20 19 int ret; 20 DWORD address; 21 21 22 22 if (!file) 23 { 24 printf("moduleadd: Could not open %s\n", name); 23 25 return 1; 26 } 24 27 25 28 fseek(file, 0, SEEK_END); 26 27 29 size=ftell(file); 28 29 30 fseek(file, 0, SEEK_SET); 30 31 31 buf=(char*)malloc(size); 32 if (!buf) 32 address=SysMemoryMap(0, size, 5, file->fd, 0, _SYS_MMAP_PRIVATE); 33 34 if (!address) 33 35 { 34 printf("Could not allocate memory. Exiting.\n");35 return 2;36 printf("Could not read %s\n", name); 37 return 1; 36 38 } 37 39 38 fread(buf, size, 1, file);40 ret=SysModuleAdd(address, size); 39 41 40 ret=SysModuleAdd(buf, size); 41 42 free(buf); 42 SysMemoryUnmap(address, size); 43 43 44 44 /* Check ret. */ 45 45 if (ret) 46 46 printf("moduleadd: Error adding module %s to kernel: %s\n", name, strerror(ret)); 47 48 fclose(file); 47 49 48 50 return ret;
