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