Changeset 832
- Timestamp:
- 08/06/08 14:47:12 (4 years ago)
- Files:
-
- 1 modified
-
Whitix/trunk/user/system/moduleadd.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
Whitix/trunk/user/system/moduleadd.c
r551 r832 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 28 /* Get the file size. */ 25 29 fseek(file, 0, SEEK_END); 26 27 30 size=ftell(file); 28 29 31 fseek(file, 0, SEEK_SET); 30 32 31 buf=(char*)malloc(size); 32 if (!buf) 33 address=SysMemoryMap(0, size, 5, file->fd, 0, _SYS_MMAP_PRIVATE); 34 35 if (!address) 33 36 { 34 printf("Could not allocate memory. Exiting.\n");35 return 2;37 printf("Could not read %s\n", name); 38 return 1; 36 39 } 37 40 38 fread(buf, size, 1, file);41 ret=SysModuleAdd(address, size); 39 42 40 ret=SysModuleAdd(buf, size); 41 42 free(buf); 43 SysMemoryUnmap(address, size); 43 44 44 45 /* Check ret. */ 45 46 if (ret) 46 47 printf("moduleadd: Error adding module %s to kernel: %s\n", name, strerror(ret)); 48 49 fclose(file); 47 50 48 51 return ret;
