Changes in uspace/app/bdsh/cmds/modules/cmp/cmp.c [582a0b8:f77c1c9] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bdsh/cmds/modules/cmp/cmp.c
r582a0b8 rf77c1c9 72 72 static int cmp_files(const char *fn0, const char *fn1) 73 73 { 74 int rc = 0;74 int rc = EOK; 75 75 const char *fn[2] = {fn0, fn1}; 76 76 int fd[2] = {-1, -1}; 77 77 char buffer[2][CMP_BUFLEN]; 78 s size_t offset[2];78 size_t offset[2]; 79 79 aoff64_t pos[2] = {}; 80 80 81 81 for (int i = 0; i < 2; i++) { 82 fd[i] = vfs_lookup_open(fn[i], WALK_REGULAR, MODE_READ); 83 if (fd[i] < 0) { 84 rc = fd[i]; 82 rc = vfs_lookup_open(fn[i], WALK_REGULAR, MODE_READ, &(fd[i])); 83 if (rc != EOK) { 85 84 printf("Unable to open %s\n", fn[i]); 86 85 goto end; … … 90 89 do { 91 90 for (int i = 0; i < 2; i++) { 92 offset[i] = 0; 93 ssize_t size; 94 do { 95 size = vfs_read(fd[i], &pos[i], 96 buffer[i] + offset[i], 97 CMP_BUFLEN - offset[i]); 98 if (size < 0) { 99 rc = size; 100 printf("Error reading from %s\n", 101 fn[i]); 102 goto end; 103 } 104 offset[i] += size; 105 } while (size && offset[i] < CMP_BUFLEN); 91 rc = vfs_read(fd[i], &pos[i], buffer[i], CMP_BUFLEN, 92 &offset[i]); 93 if (rc != EOK) { 94 printf("Error reading from %s\n", 95 fn[i]); 96 goto end; 97 } 106 98 } 107 99 108 100 if (offset[0] != offset[1] || 109 101 memcmp(buffer[0], buffer[1], offset[0]) != 0) { 102 printf("Return 1\n"); 110 103 rc = 1; 111 104 goto end; … … 149 142 150 143 rc = cmp_files(argv[optind], argv[optind + 1]); 151 if (rc )144 if (rc != EOK) 152 145 return CMD_FAILURE; 153 146 else
Note:
See TracChangeset
for help on using the changeset viewer.