summaryrefslogtreecommitdiff
path: root/src/copy.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1997-11-30 10:24:50 +0000
committerJim Meyering <jim@meyering.net>1997-11-30 10:24:50 +0000
commitb8c474191af9b458b0b9a82eaa1e28a44730f544 (patch)
tree2ce8f96f2f2f1c1927ea10472750c217ebea7866 /src/copy.c
parent0f411474da3c368558be98b06daafc7c8a4f50be (diff)
downloadcoreutils-b8c474191af9b458b0b9a82eaa1e28a44730f544.tar.xz
(copy_reg): Store file size as off_t, not long.
Do not assume st_size has been normalized to 512 byte blocks, or that it fits in size_t after dividing by the blocksize.
Diffstat (limited to 'src/copy.c')
-rw-r--r--src/copy.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/copy.c b/src/copy.c
index 24f5756cb..31d05a6e8 100644
--- a/src/copy.c
+++ b/src/copy.c
@@ -77,7 +77,7 @@ copy_dir (const char *src_path_in, const char *dst_path_in, int new_dst,
int ret = 0;
errno = 0;
- name_space = savedir (src_path_in, src_sb->st_size);
+ name_space = savedir (src_path_in, (unsigned int) src_sb->st_size);
if (name_space == 0)
{
if (errno)
@@ -132,7 +132,7 @@ copy_reg (const char *src_path, const char *dst_path,
char *cp;
int *ip;
int return_val = 0;
- long n_read_total = 0;
+ off_t n_read_total = 0;
int last_write_made_hole = 0;
int make_holes = (sparse_mode == SPARSE_ALWAYS);
@@ -182,7 +182,7 @@ copy_reg (const char *src_path, const char *dst_path,
be needed for a file of its size, then
at least one of the blocks in the file is a hole. */
if (S_ISREG (sb.st_mode)
- && (size_t) (sb.st_size / 512) > (size_t) ST_NBLOCKS (sb))
+ && sb.st_size / ST_NBLOCKSIZE > ST_NBLOCKS (sb))
make_holes = 1;
}
#endif