Changes in uspace/app/sysinst/futil.c [8d2dd7f2:f77c1c9] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/sysinst/futil.c
r8d2dd7f2 rf77c1c9 57 57 { 58 58 int sf, df; 59 s size_t nr, nw;59 size_t nr, nw; 60 60 int rc; 61 61 aoff64_t posr = 0, posw = 0; … … 63 63 printf("Copy '%s' to '%s'.\n", srcp, destp); 64 64 65 sf = vfs_lookup_open(srcp, WALK_REGULAR, MODE_READ);66 if ( sf < 0)67 return EIO; 68 69 df = vfs_lookup_open(destp, WALK_REGULAR | WALK_MAY_CREATE, MODE_WRITE);70 if ( df < 0)65 rc = vfs_lookup_open(srcp, WALK_REGULAR, MODE_READ, &sf); 66 if (rc != EOK) 67 return EIO; 68 69 rc = vfs_lookup_open(destp, WALK_REGULAR | WALK_MAY_CREATE, MODE_WRITE, &df); 70 if (rc != EOK) 71 71 return EIO; 72 72 73 73 do { 74 nr = vfs_read(sf, &posr, buf, BUF_SIZE); 74 rc = vfs_read(sf, &posr, buf, BUF_SIZE, &nr); 75 if (rc != EOK) 76 goto error; 75 77 if (nr == 0) 76 78 break; 77 if (nr < 0) 78 return EIO; 79 80 nw = vfs_write(df, &posw, buf, nr); 81 if (nw <= 0) 82 return EIO; 83 } while (true); 79 80 rc= vfs_write(df, &posw, buf, nr, &nw); 81 if (rc != EOK) 82 goto error; 83 84 } while (nr == BUF_SIZE); 84 85 85 86 (void) vfs_put(sf); 86 87 87 88 rc = vfs_put(df); 88 if (rc < 0)89 if (rc != EOK) 89 90 return EIO; 90 91 91 92 return EOK; 93 error: 94 vfs_put(sf); 95 vfs_put(df); 96 return rc; 92 97 } 93 98 … … 156 161 { 157 162 int sf; 158 ssize_t nr; 163 size_t nr; 164 int rc; 159 165 size_t fsize; 160 166 char *data; 161 167 struct stat st; 162 168 163 sf = vfs_lookup_open(srcp, WALK_REGULAR, MODE_READ);164 if ( sf < 0)169 rc = vfs_lookup_open(srcp, WALK_REGULAR, MODE_READ, &sf); 170 if (rc != EOK) 165 171 return ENOENT; 166 172 … … 168 174 vfs_put(sf); 169 175 return EIO; 170 } 176 } 171 177 172 178 fsize = st.size; … … 178 184 } 179 185 180 nr = vfs_read(sf, (aoff64_t []) { 0 }, data, fsize);181 if ( nr != (ssize_t)fsize) {186 rc = vfs_read(sf, (aoff64_t []) { 0 }, data, fsize, &nr); 187 if (rc != EOK || nr != fsize) { 182 188 vfs_put(sf); 183 189 free(data);
Note:
See TracChangeset
for help on using the changeset viewer.