Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 907082 | Differences between
and this patch

Collapse All | Expand All

(-)a/Grow.c (-13 / +13 lines)
Lines 4260-4269 static int grow_backup(struct mdinfo *sra, Link Here
4260
		bsb.magic[15] = '2';
4260
		bsb.magic[15] = '2';
4261
	for (i = 0; i < dests; i++)
4261
	for (i = 0; i < dests; i++)
4262
		if (part)
4262
		if (part)
4263
			lseek64(destfd[i], destoffsets[i] +
4263
			lseek(destfd[i], destoffsets[i] +
4264
				__le64_to_cpu(bsb.devstart2)*512, 0);
4264
				__le64_to_cpu(bsb.devstart2)*512, 0);
4265
		else
4265
		else
4266
			lseek64(destfd[i], destoffsets[i], 0);
4266
			lseek(destfd[i], destoffsets[i], 0);
4267
4267
4268
	rv = save_stripes(sources, offsets, disks, chunk, level, layout,
4268
	rv = save_stripes(sources, offsets, disks, chunk, level, layout,
4269
			  dests, destfd, offset * 512 * odata,
4269
			  dests, destfd, offset * 512 * odata,
Lines 4282-4295 static int grow_backup(struct mdinfo *sra, Link Here
4282
						((char*)&bsb.sb_csum2)-((char*)&bsb));
4282
						((char*)&bsb.sb_csum2)-((char*)&bsb));
4283
4283
4284
		rv = -1;
4284
		rv = -1;
4285
		if ((unsigned long long)lseek64(destfd[i],
4285
		if ((unsigned long long)lseek(destfd[i],
4286
						destoffsets[i] - 4096, 0) !=
4286
						destoffsets[i] - 4096, 0) !=
4287
		    destoffsets[i] - 4096)
4287
		    destoffsets[i] - 4096)
4288
			break;
4288
			break;
4289
		if (write(destfd[i], &bsb, 512) != 512)
4289
		if (write(destfd[i], &bsb, 512) != 512)
4290
			break;
4290
			break;
4291
		if (destoffsets[i] > 4096) {
4291
		if (destoffsets[i] > 4096) {
4292
			if ((unsigned long long)lseek64(destfd[i], destoffsets[i]+stripes*chunk*odata, 0) !=
4292
			if ((unsigned long long)lseek(destfd[i], destoffsets[i]+stripes*chunk*odata, 0) !=
4293
			    destoffsets[i]+stripes*chunk*odata)
4293
			    destoffsets[i]+stripes*chunk*odata)
4294
				break;
4294
				break;
4295
			if (write(destfd[i], &bsb, 512) != 512)
4295
			if (write(destfd[i], &bsb, 512) != 512)
Lines 4339-4345 static int forget_backup(int dests, int *destfd, Link Here
4339
		if (memcmp(bsb.magic, "md_backup_data-2", 16) == 0)
4339
		if (memcmp(bsb.magic, "md_backup_data-2", 16) == 0)
4340
			bsb.sb_csum2 = bsb_csum((char*)&bsb,
4340
			bsb.sb_csum2 = bsb_csum((char*)&bsb,
4341
						((char*)&bsb.sb_csum2)-((char*)&bsb));
4341
						((char*)&bsb.sb_csum2)-((char*)&bsb));
4342
		if ((unsigned long long)lseek64(destfd[i], destoffsets[i]-4096, 0) !=
4342
		if ((unsigned long long)lseek(destfd[i], destoffsets[i]-4096, 0) !=
4343
		    destoffsets[i]-4096)
4343
		    destoffsets[i]-4096)
4344
			rv = -1;
4344
			rv = -1;
4345
		if (rv == 0 && write(destfd[i], &bsb, 512) != 512)
4345
		if (rv == 0 && write(destfd[i], &bsb, 512) != 512)
Lines 4367-4373 static void validate(int afd, int bfd, unsigned long long offset) Link Here
4367
	 */
4367
	 */
4368
	if (afd < 0)
4368
	if (afd < 0)
4369
		return;
4369
		return;
4370
	lseek64(bfd, offset - 4096, 0);
4370
	lseek(bfd, offset - 4096, 0);
4371
	if (read(bfd, &bsb2, 512) != 512)
4371
	if (read(bfd, &bsb2, 512) != 512)
4372
		fail("cannot read bsb");
4372
		fail("cannot read bsb");
4373
	if (bsb2.sb_csum != bsb_csum((char*)&bsb2,
4373
	if (bsb2.sb_csum != bsb_csum((char*)&bsb2,
Lines 4398-4409 static void validate(int afd, int bfd, unsigned long long offset) Link Here
4398
			}
4398
			}
4399
		}
4399
		}
4400
4400
4401
		lseek64(bfd, offset, 0);
4401
		lseek(bfd, offset, 0);
4402
		if ((unsigned long long)read(bfd, bbuf, len) != len) {
4402
		if ((unsigned long long)read(bfd, bbuf, len) != len) {
4403
			//printf("len %llu\n", len);
4403
			//printf("len %llu\n", len);
4404
			fail("read first backup failed");
4404
			fail("read first backup failed");
4405
		}
4405
		}
4406
		lseek64(afd, __le64_to_cpu(bsb2.arraystart)*512, 0);
4406
		lseek(afd, __le64_to_cpu(bsb2.arraystart)*512, 0);
4407
		if ((unsigned long long)read(afd, abuf, len) != len)
4407
		if ((unsigned long long)read(afd, abuf, len) != len)
4408
			fail("read first from array failed");
4408
			fail("read first from array failed");
4409
		if (memcmp(bbuf, abuf, len) != 0) {
4409
		if (memcmp(bbuf, abuf, len) != 0) {
Lines 4431-4440 static void validate(int afd, int bfd, unsigned long long offset) Link Here
4431
			bbuf = xmalloc(abuflen);
4431
			bbuf = xmalloc(abuflen);
4432
		}
4432
		}
4433
4433
4434
		lseek64(bfd, offset+__le64_to_cpu(bsb2.devstart2)*512, 0);
4434
		lseek(bfd, offset+__le64_to_cpu(bsb2.devstart2)*512, 0);
4435
		if ((unsigned long long)read(bfd, bbuf, len) != len)
4435
		if ((unsigned long long)read(bfd, bbuf, len) != len)
4436
			fail("read second backup failed");
4436
			fail("read second backup failed");
4437
		lseek64(afd, __le64_to_cpu(bsb2.arraystart2)*512, 0);
4437
		lseek(afd, __le64_to_cpu(bsb2.arraystart2)*512, 0);
4438
		if ((unsigned long long)read(afd, abuf, len) != len)
4438
		if ((unsigned long long)read(afd, abuf, len) != len)
4439
			fail("read second from array failed");
4439
			fail("read second from array failed");
4440
		if (memcmp(bbuf, abuf, len) != 0)
4440
		if (memcmp(bbuf, abuf, len) != 0)
Lines 4711-4717 int Grow_restart(struct supertype *st, struct mdinfo *info, int *fdlist, Link Here
4711
			st->ss->getinfo_super(st, &dinfo, NULL);
4711
			st->ss->getinfo_super(st, &dinfo, NULL);
4712
			st->ss->free_super(st);
4712
			st->ss->free_super(st);
4713
4713
4714
			if (lseek64(fd,
4714
			if (lseek(fd,
4715
				    (dinfo.data_offset + dinfo.component_size - 8) <<9,
4715
				    (dinfo.data_offset + dinfo.component_size - 8) <<9,
4716
				    0) < 0) {
4716
				    0) < 0) {
4717
				pr_err("Cannot seek on device %d\n", i);
4717
				pr_err("Cannot seek on device %d\n", i);
Lines 4811-4817 int Grow_restart(struct supertype *st, struct mdinfo *info, int *fdlist, Link Here
4811
					goto nonew; /* No new data here */
4811
					goto nonew; /* No new data here */
4812
			}
4812
			}
4813
		}
4813
		}
4814
		if (lseek64(fd, __le64_to_cpu(bsb.devstart)*512, 0)< 0) {
4814
		if (lseek(fd, __le64_to_cpu(bsb.devstart)*512, 0)< 0) {
4815
		second_fail:
4815
		second_fail:
4816
			if (verbose)
4816
			if (verbose)
4817
				pr_err("Failed to verify secondary backup-metadata block on %s\n",
4817
				pr_err("Failed to verify secondary backup-metadata block on %s\n",
Lines 4819-4825 int Grow_restart(struct supertype *st, struct mdinfo *info, int *fdlist, Link Here
4819
			continue; /* Cannot seek */
4819
			continue; /* Cannot seek */
4820
		}
4820
		}
4821
		/* There should be a duplicate backup superblock 4k before here */
4821
		/* There should be a duplicate backup superblock 4k before here */
4822
		if (lseek64(fd, -4096, 1) < 0 ||
4822
		if (lseek(fd, -4096, 1) < 0 ||
4823
		    read(fd, &bsb2, sizeof(bsb2)) != sizeof(bsb2))
4823
		    read(fd, &bsb2, sizeof(bsb2)) != sizeof(bsb2))
4824
			goto second_fail; /* Cannot find leading superblock */
4824
			goto second_fail; /* Cannot find leading superblock */
4825
		if (bsb.magic[15] == '1')
4825
		if (bsb.magic[15] == '1')
(-)a/raid6check.c (-5 / +5 lines)
Lines 206-212 int autorepair(int *disk, unsigned long long start, int chunk_size, Link Here
206
		for(j = 0; j < (chunk_size >> CHECK_PAGE_BITS); j++) {
206
		for(j = 0; j < (chunk_size >> CHECK_PAGE_BITS); j++) {
207
			if(page_to_write[j] == 1) {
207
			if(page_to_write[j] == 1) {
208
				int slot = block_index_for_slot[disk[j]];
208
				int slot = block_index_for_slot[disk[j]];
209
				lseek64(source[slot], offsets[slot] + start * chunk_size + j * CHECK_PAGE_SIZE, SEEK_SET);
209
				lseek(source[slot], offsets[slot] + start * chunk_size + j * CHECK_PAGE_SIZE, SEEK_SET);
210
				write_res += write(source[slot],
210
				write_res += write(source[slot],
211
						   blocks[disk[j]] + j * CHECK_PAGE_SIZE,
211
						   blocks[disk[j]] + j * CHECK_PAGE_SIZE,
212
						   CHECK_PAGE_SIZE);
212
						   CHECK_PAGE_SIZE);
Lines 279-287 int manual_repair(int chunk_size, int syndrome_disks, Link Here
279
	}
279
	}
280
280
281
	int write_res1, write_res2;
281
	int write_res1, write_res2;
282
	off64_t seek_res;
282
	off_t seek_res;
283
283
284
	seek_res = lseek64(source[fd1],
284
	seek_res = lseek(source[fd1],
285
			   offsets[fd1] + start * chunk_size, SEEK_SET);
285
			   offsets[fd1] + start * chunk_size, SEEK_SET);
286
	if (seek_res < 0) {
286
	if (seek_res < 0) {
287
		fprintf(stderr, "lseek failed for failed_disk1\n");
287
		fprintf(stderr, "lseek failed for failed_disk1\n");
Lines 289-295 int manual_repair(int chunk_size, int syndrome_disks, Link Here
289
	}
289
	}
290
	write_res1 = write(source[fd1], blocks[failed_slot1], chunk_size);
290
	write_res1 = write(source[fd1], blocks[failed_slot1], chunk_size);
291
291
292
	seek_res = lseek64(source[fd2],
292
	seek_res = lseek(source[fd2],
293
			   offsets[fd2] + start * chunk_size, SEEK_SET);
293
			   offsets[fd2] + start * chunk_size, SEEK_SET);
294
	if (seek_res < 0) {
294
	if (seek_res < 0) {
295
		fprintf(stderr, "lseek failed for failed_disk2\n");
295
		fprintf(stderr, "lseek failed for failed_disk2\n");
Lines 374-380 int check_stripes(struct mdinfo *info, int *source, unsigned long long *offsets, Link Here
374
			goto exitCheck;
374
			goto exitCheck;
375
		}
375
		}
376
		for (i = 0 ; i < raid_disks ; i++) {
376
		for (i = 0 ; i < raid_disks ; i++) {
377
			off64_t seek_res = lseek64(source[i], offsets[i] + start * chunk_size,
377
			off_t seek_res = lseek(source[i], offsets[i] + start * chunk_size,
378
						   SEEK_SET);
378
						   SEEK_SET);
379
			if (seek_res < 0) {
379
			if (seek_res < 0) {
380
				fprintf(stderr, "lseek to source %d failed\n", i);
380
				fprintf(stderr, "lseek to source %d failed\n", i);
(-)a/restripe.c (-5 / +5 lines)
Lines 581-587 int save_stripes(int *source, unsigned long long *offsets, Link Here
581
				       raid_disks, level, layout);
581
				       raid_disks, level, layout);
582
			if (dnum < 0) abort();
582
			if (dnum < 0) abort();
583
			if (source[dnum] < 0 ||
583
			if (source[dnum] < 0 ||
584
			    lseek64(source[dnum],
584
			    lseek(source[dnum],
585
				    offsets[dnum] + offset, 0) < 0 ||
585
				    offsets[dnum] + offset, 0) < 0 ||
586
			    read(source[dnum], buf+disk * chunk_size,
586
			    read(source[dnum], buf+disk * chunk_size,
587
				 chunk_size) != chunk_size) {
587
				 chunk_size) != chunk_size) {
Lines 754-761 int restore_stripes(int *dest, unsigned long long *offsets, Link Here
754
					   raid_disks, level, layout);
754
					   raid_disks, level, layout);
755
			if (src_buf == NULL) {
755
			if (src_buf == NULL) {
756
				/* read from file */
756
				/* read from file */
757
				if (lseek64(source, read_offset, 0) !=
757
				if (lseek(source, read_offset, 0) !=
758
					 (off64_t)read_offset) {
758
					 (off_t)read_offset) {
759
					rv = -1;
759
					rv = -1;
760
					goto abort;
760
					goto abort;
761
				}
761
				}
Lines 816-822 int restore_stripes(int *dest, unsigned long long *offsets, Link Here
816
		}
816
		}
817
		for (i=0; i < raid_disks ; i++)
817
		for (i=0; i < raid_disks ; i++)
818
			if (dest[i] >= 0) {
818
			if (dest[i] >= 0) {
819
				if (lseek64(dest[i],
819
				if (lseek(dest[i],
820
					 offsets[i]+offset, 0) < 0) {
820
					 offsets[i]+offset, 0) < 0) {
821
					rv = -1;
821
					rv = -1;
822
					goto abort;
822
					goto abort;
Lines 866-872 int test_stripes(int *source, unsigned long long *offsets, Link Here
866
		int disk;
866
		int disk;
867
867
868
		for (i = 0 ; i < raid_disks ; i++) {
868
		for (i = 0 ; i < raid_disks ; i++) {
869
			if ((lseek64(source[i], offsets[i]+start, 0) < 0) ||
869
			if ((lseek(source[i], offsets[i]+start, 0) < 0) ||
870
			    (read(source[i], stripes[i], chunk_size) !=
870
			    (read(source[i], stripes[i], chunk_size) !=
871
			     chunk_size)) {
871
			     chunk_size)) {
872
				free(q);
872
				free(q);
(-)a/super-ddf.c (-10 / +10 lines)
Lines 816-822 static int load_ddf_header(int fd, unsigned long long lba, Link Here
816
	if (lba >= size-1)
816
	if (lba >= size-1)
817
		return 0;
817
		return 0;
818
818
819
	if (lseek64(fd, lba<<9, 0) < 0)
819
	if (lseek(fd, lba<<9, 0) < 0)
820
		return 0;
820
		return 0;
821
821
822
	if (read(fd, hdr, 512) != 512)
822
	if (read(fd, hdr, 512) != 512)
Lines 870-876 static void *load_section(int fd, struct ddf_super *super, void *buf, Link Here
870
	else
870
	else
871
		offset += be64_to_cpu(super->active->secondary_lba);
871
		offset += be64_to_cpu(super->active->secondary_lba);
872
872
873
	if ((unsigned long long)lseek64(fd, offset<<9, 0) != (offset<<9)) {
873
	if ((unsigned long long)lseek(fd, offset<<9, 0) != (offset<<9)) {
874
		if (dofree)
874
		if (dofree)
875
			free(buf);
875
			free(buf);
876
		return NULL;
876
		return NULL;
Lines 889-895 static int load_ddf_headers(int fd, struct ddf_super *super, char *devname) Link Here
889
889
890
	get_dev_size(fd, NULL, &dsize);
890
	get_dev_size(fd, NULL, &dsize);
891
891
892
	if (lseek64(fd, dsize-512, 0) < 0) {
892
	if (lseek(fd, dsize-512, 0) < 0) {
893
		if (devname)
893
		if (devname)
894
			pr_err("Cannot seek to anchor block on %s: %s\n",
894
			pr_err("Cannot seek to anchor block on %s: %s\n",
895
			       devname, strerror(errno));
895
			       devname, strerror(errno));
Lines 1691-1697 static int copy_metadata_ddf(struct supertype *st, int from, int to) Link Here
1691
	if (!get_dev_size(from, NULL, &dsize))
1691
	if (!get_dev_size(from, NULL, &dsize))
1692
		goto err;
1692
		goto err;
1693
1693
1694
	if (lseek64(from, dsize-512, 0) < 0)
1694
	if (lseek(from, dsize-512, 0) < 0)
1695
		goto err;
1695
		goto err;
1696
	if (read(from, buf, 512) != 512)
1696
	if (read(from, buf, 512) != 512)
1697
		goto err;
1697
		goto err;
Lines 1710-1717 static int copy_metadata_ddf(struct supertype *st, int from, int to) Link Here
1710
1710
1711
	bytes = dsize - offset;
1711
	bytes = dsize - offset;
1712
1712
1713
	if (lseek64(from, offset, 0) < 0 ||
1713
	if (lseek(from, offset, 0) < 0 ||
1714
	    lseek64(to, offset, 0) < 0)
1714
	    lseek(to, offset, 0) < 0)
1715
		goto err;
1715
		goto err;
1716
	while (written < bytes) {
1716
	while (written < bytes) {
1717
		int n = bytes - written;
1717
		int n = bytes - written;
Lines 3037-3043 static int __write_ddf_structure(struct dl *d, struct ddf_super *ddf, __u8 type) Link Here
3037
	header->openflag = 1;
3037
	header->openflag = 1;
3038
	header->crc = calc_crc(header, 512);
3038
	header->crc = calc_crc(header, 512);
3039
3039
3040
	lseek64(fd, sector<<9, 0);
3040
	lseek(fd, sector<<9, 0);
3041
	if (write(fd, header, 512) < 0)
3041
	if (write(fd, header, 512) < 0)
3042
		goto out;
3042
		goto out;
3043
3043
Lines 3101-3107 out: Link Here
3101
	header->openflag = 0;
3101
	header->openflag = 0;
3102
	header->crc = calc_crc(header, 512);
3102
	header->crc = calc_crc(header, 512);
3103
3103
3104
	lseek64(fd, sector<<9, 0);
3104
	lseek(fd, sector<<9, 0);
3105
	if (write(fd, header, 512) < 0)
3105
	if (write(fd, header, 512) < 0)
3106
		ret = 0;
3106
		ret = 0;
3107
3107
Lines 3154-3160 static int _write_super_to_disk(struct ddf_super *ddf, struct dl *d) Link Here
3154
	if (!__write_ddf_structure(d, ddf, DDF_HEADER_SECONDARY))
3154
	if (!__write_ddf_structure(d, ddf, DDF_HEADER_SECONDARY))
3155
		return 0;
3155
		return 0;
3156
3156
3157
	lseek64(fd, (size-1)*512, SEEK_SET);
3157
	lseek(fd, (size-1)*512, SEEK_SET);
3158
	if (write(fd, &ddf->anchor, 512) < 0)
3158
	if (write(fd, &ddf->anchor, 512) < 0)
3159
		return 0;
3159
		return 0;
3160
3160
Lines 3909-3915 static int store_super_ddf(struct supertype *st, int fd) Link Here
3909
		return 1;
3909
		return 1;
3910
	memset(buf, 0, 512);
3910
	memset(buf, 0, 512);
3911
3911
3912
	lseek64(fd, dsize-512, 0);
3912
	lseek(fd, dsize-512, 0);
3913
	rc = write(fd, buf, 512);
3913
	rc = write(fd, buf, 512);
3914
	free(buf);
3914
	free(buf);
3915
	if (rc < 0)
3915
	if (rc < 0)
(-)a/super-intel.c (-16 / +16 lines)
Lines 3092-3098 static int read_imsm_migr_rec(int fd, struct intel_super *super) Link Here
3092
	unsigned long long dsize;
3092
	unsigned long long dsize;
3093
3093
3094
	get_dev_size(fd, NULL, &dsize);
3094
	get_dev_size(fd, NULL, &dsize);
3095
	if (lseek64(fd, dsize - (sector_size*MIGR_REC_SECTOR_POSITION),
3095
	if (lseek(fd, dsize - (sector_size*MIGR_REC_SECTOR_POSITION),
3096
		   SEEK_SET) < 0) {
3096
		   SEEK_SET) < 0) {
3097
		pr_err("Cannot seek to anchor block: %s\n",
3097
		pr_err("Cannot seek to anchor block: %s\n",
3098
		       strerror(errno));
3098
		       strerror(errno));
Lines 3283-3289 static int write_imsm_migr_rec(struct supertype *st) Link Here
3283
			continue;
3283
			continue;
3284
3284
3285
		get_dev_size(sd->fd, NULL, &dsize);
3285
		get_dev_size(sd->fd, NULL, &dsize);
3286
		if (lseek64(sd->fd, dsize - (MIGR_REC_SECTOR_POSITION *
3286
		if (lseek(sd->fd, dsize - (MIGR_REC_SECTOR_POSITION *
3287
		    sector_size),
3287
		    sector_size),
3288
		    SEEK_SET) < 0) {
3288
		    SEEK_SET) < 0) {
3289
			pr_err("Cannot seek to anchor block: %s\n",
3289
			pr_err("Cannot seek to anchor block: %s\n",
Lines 4404-4410 static int load_imsm_mpb(int fd, struct intel_super *super, char *devname) Link Here
4404
		return 1;
4404
		return 1;
4405
	}
4405
	}
4406
4406
4407
	if (lseek64(fd, dsize - (sector_size * 2), SEEK_SET) < 0) {
4407
	if (lseek(fd, dsize - (sector_size * 2), SEEK_SET) < 0) {
4408
		if (devname)
4408
		if (devname)
4409
			pr_err("Cannot seek to anchor block on %s: %s\n",
4409
			pr_err("Cannot seek to anchor block on %s: %s\n",
4410
			       devname, strerror(errno));
4410
			       devname, strerror(errno));
Lines 4472-4478 static int load_imsm_mpb(int fd, struct intel_super *super, char *devname) Link Here
4472
	}
4472
	}
4473
4473
4474
	/* read the extended mpb */
4474
	/* read the extended mpb */
4475
	if (lseek64(fd, dsize - (sector_size * (2 + sectors)), SEEK_SET) < 0) {
4475
	if (lseek(fd, dsize - (sector_size * (2 + sectors)), SEEK_SET) < 0) {
4476
		if (devname)
4476
		if (devname)
4477
			pr_err("Cannot seek to extended mpb on %s: %s\n",
4477
			pr_err("Cannot seek to extended mpb on %s: %s\n",
4478
			       devname, strerror(errno));
4478
			       devname, strerror(errno));
Lines 5994-6000 static int add_to_super_imsm(struct supertype *st, mdu_disk_info_t *dk, Link Here
5994
5994
5995
	/* clear migr_rec when adding disk to container */
5995
	/* clear migr_rec when adding disk to container */
5996
	memset(super->migr_rec_buf, 0, MIGR_REC_BUF_SECTORS*MAX_SECTOR_SIZE);
5996
	memset(super->migr_rec_buf, 0, MIGR_REC_BUF_SECTORS*MAX_SECTOR_SIZE);
5997
	if (lseek64(fd, size - MIGR_REC_SECTOR_POSITION*member_sector_size,
5997
	if (lseek(fd, size - MIGR_REC_SECTOR_POSITION*member_sector_size,
5998
	    SEEK_SET) >= 0) {
5998
	    SEEK_SET) >= 0) {
5999
		if ((unsigned int)write(fd, super->migr_rec_buf,
5999
		if ((unsigned int)write(fd, super->migr_rec_buf,
6000
		    MIGR_REC_BUF_SECTORS*member_sector_size) !=
6000
		    MIGR_REC_BUF_SECTORS*member_sector_size) !=
Lines 6219-6225 static int write_super_imsm(struct supertype *st, int doclose) Link Here
6219
			unsigned long long dsize;
6219
			unsigned long long dsize;
6220
6220
6221
			get_dev_size(d->fd, NULL, &dsize);
6221
			get_dev_size(d->fd, NULL, &dsize);
6222
			if (lseek64(d->fd, dsize - sector_size,
6222
			if (lseek(d->fd, dsize - sector_size,
6223
			    SEEK_SET) >= 0) {
6223
			    SEEK_SET) >= 0) {
6224
				if ((unsigned int)write(d->fd,
6224
				if ((unsigned int)write(d->fd,
6225
				    super->migr_rec_buf,
6225
				    super->migr_rec_buf,
Lines 6302-6308 static int write_ppl_header(unsigned long long ppl_sector, int fd, void *buf) Link Here
6302
6302
6303
	ppl_hdr->checksum = __cpu_to_le32(~crc32c_le(~0, buf, PPL_HEADER_SIZE));
6303
	ppl_hdr->checksum = __cpu_to_le32(~crc32c_le(~0, buf, PPL_HEADER_SIZE));
6304
6304
6305
	if (lseek64(fd, ppl_sector * 512, SEEK_SET) < 0) {
6305
	if (lseek(fd, ppl_sector * 512, SEEK_SET) < 0) {
6306
		ret = -errno;
6306
		ret = -errno;
6307
		perror("Failed to seek to PPL header location");
6307
		perror("Failed to seek to PPL header location");
6308
		return ret;
6308
		return ret;
Lines 6396-6402 static int validate_ppl_imsm(struct supertype *st, struct mdinfo *info, Link Here
6396
6396
6397
		dprintf("Checking potential PPL at offset: %llu\n", ppl_offset);
6397
		dprintf("Checking potential PPL at offset: %llu\n", ppl_offset);
6398
6398
6399
		if (lseek64(d->fd, info->ppl_sector * 512 + ppl_offset,
6399
		if (lseek(d->fd, info->ppl_sector * 512 + ppl_offset,
6400
			    SEEK_SET) < 0) {
6400
			    SEEK_SET) < 0) {
6401
			perror("Failed to seek to PPL header location");
6401
			perror("Failed to seek to PPL header location");
6402
			ret = -1;
6402
			ret = -1;
Lines 8858-8864 static int store_imsm_mpb(int fd, struct imsm_super *mpb) Link Here
8858
		sectors = mpb_sectors(mpb, sector_size) - 1;
8858
		sectors = mpb_sectors(mpb, sector_size) - 1;
8859
8859
8860
		/* write the extended mpb to the sectors preceeding the anchor */
8860
		/* write the extended mpb to the sectors preceeding the anchor */
8861
		if (lseek64(fd, dsize - (sector_size * (2 + sectors)),
8861
		if (lseek(fd, dsize - (sector_size * (2 + sectors)),
8862
		   SEEK_SET) < 0)
8862
		   SEEK_SET) < 0)
8863
			return 1;
8863
			return 1;
8864
8864
Lines 8868-8874 static int store_imsm_mpb(int fd, struct imsm_super *mpb) Link Here
8868
	}
8868
	}
8869
8869
8870
	/* first block is stored on second to last sector of the disk */
8870
	/* first block is stored on second to last sector of the disk */
8871
	if (lseek64(fd, dsize - (sector_size * 2), SEEK_SET) < 0)
8871
	if (lseek(fd, dsize - (sector_size * 2), SEEK_SET) < 0)
8872
		return 1;
8872
		return 1;
8873
8873
8874
	if ((unsigned int)write(fd, buf, sector_size) != sector_size)
8874
	if ((unsigned int)write(fd, buf, sector_size) != sector_size)
Lines 11058-11064 int recover_backup_imsm(struct supertype *st, struct mdinfo *info) Link Here
11058
			skipped_disks++;
11058
			skipped_disks++;
11059
			continue;
11059
			continue;
11060
		}
11060
		}
11061
		if (lseek64(dl_disk->fd, read_offset, SEEK_SET) < 0) {
11061
		if (lseek(dl_disk->fd, read_offset, SEEK_SET) < 0) {
11062
			pr_err("Cannot seek to block: %s\n",
11062
			pr_err("Cannot seek to block: %s\n",
11063
			       strerror(errno));
11063
			       strerror(errno));
11064
			skipped_disks++;
11064
			skipped_disks++;
Lines 11070-11076 int recover_backup_imsm(struct supertype *st, struct mdinfo *info) Link Here
11070
			skipped_disks++;
11070
			skipped_disks++;
11071
			continue;
11071
			continue;
11072
		}
11072
		}
11073
		if (lseek64(dl_disk->fd, write_offset, SEEK_SET) < 0) {
11073
		if (lseek(dl_disk->fd, write_offset, SEEK_SET) < 0) {
11074
			pr_err("Cannot seek to block: %s\n",
11074
			pr_err("Cannot seek to block: %s\n",
11075
			       strerror(errno));
11075
			       strerror(errno));
11076
			skipped_disks++;
11076
			skipped_disks++;
Lines 12320-12326 static int imsm_manage_reshape( Link Here
12320
		unsigned long long dsize;
12320
		unsigned long long dsize;
12321
12321
12322
		get_dev_size(d->fd, NULL, &dsize);
12322
		get_dev_size(d->fd, NULL, &dsize);
12323
		if (lseek64(d->fd, dsize - MIGR_REC_SECTOR_POSITION*sector_size,
12323
		if (lseek(d->fd, dsize - MIGR_REC_SECTOR_POSITION*sector_size,
12324
			    SEEK_SET) >= 0) {
12324
			    SEEK_SET) >= 0) {
12325
			if ((unsigned int)write(d->fd, super->migr_rec_buf,
12325
			if ((unsigned int)write(d->fd, super->migr_rec_buf,
12326
			    MIGR_REC_BUF_SECTORS*sector_size) !=
12326
			    MIGR_REC_BUF_SECTORS*sector_size) !=
Lines 12476-12482 static int validate_internal_bitmap_for_drive(struct supertype *st, Link Here
12476
		}
12476
		}
12477
	}
12477
	}
12478
12478
12479
	if (lseek64(fd, offset * super->sector_size, SEEK_SET) < 0)
12479
	if (lseek(fd, offset * super->sector_size, SEEK_SET) < 0)
12480
		goto abort;
12480
		goto abort;
12481
	if (read(fd, read_buf, IMSM_BITMAP_HEADER_SIZE) !=
12481
	if (read(fd, read_buf, IMSM_BITMAP_HEADER_SIZE) !=
12482
	    IMSM_BITMAP_HEADER_SIZE)
12482
	    IMSM_BITMAP_HEADER_SIZE)
Lines 12605-12611 static int locate_bitmap_imsm(struct supertype *st, int fd, int node_num) Link Here
12605
	offset = get_bitmap_header_sector(super, super->current_vol);
12605
	offset = get_bitmap_header_sector(super, super->current_vol);
12606
	dprintf("bitmap header offset is %llu\n", offset);
12606
	dprintf("bitmap header offset is %llu\n", offset);
12607
12607
12608
	lseek64(fd, offset << 9, 0);
12608
	lseek(fd, offset << 9, 0);
12609
12609
12610
	return 0;
12610
	return 0;
12611
}
12611
}
Lines 12659-12665 static int write_init_bitmap_imsm(struct supertype *st, int fd, Link Here
12659
		return -1;
12659
		return -1;
12660
	memset(buf, 0xFF, MAX_SECTOR_SIZE);
12660
	memset(buf, 0xFF, MAX_SECTOR_SIZE);
12661
	offset = get_bitmap_sector(super, vol_idx);
12661
	offset = get_bitmap_sector(super, vol_idx);
12662
	lseek64(fd, offset << 9, 0);
12662
	lseek(fd, offset << 9, 0);
12663
	while (written < IMSM_BITMAP_AREA_SIZE) {
12663
	while (written < IMSM_BITMAP_AREA_SIZE) {
12664
		to_write = IMSM_BITMAP_AREA_SIZE - written;
12664
		to_write = IMSM_BITMAP_AREA_SIZE - written;
12665
		if (to_write > MAX_SECTOR_SIZE)
12665
		if (to_write > MAX_SECTOR_SIZE)
(-)a/super0.c (-7 / +7 lines)
Lines 327-338 static int copy_metadata0(struct supertype *st, int from, int to) Link Here
327
327
328
	offset *= 512;
328
	offset *= 512;
329
329
330
	if (lseek64(from, offset, 0) < 0LL)
330
	if (lseek(from, offset, 0) < 0LL)
331
		goto err;
331
		goto err;
332
	if (read(from, buf, bufsize) != bufsize)
332
	if (read(from, buf, bufsize) != bufsize)
333
		goto err;
333
		goto err;
334
334
335
	if (lseek64(to, offset, 0) < 0LL)
335
	if (lseek(to, offset, 0) < 0LL)
336
		goto err;
336
		goto err;
337
	super = buf;
337
	super = buf;
338
	if (super->md_magic != MD_SB_MAGIC ||
338
	if (super->md_magic != MD_SB_MAGIC ||
Lines 862-868 static int store_super0(struct supertype *st, int fd) Link Here
862
		offset = dsize/512 - 8*2;
862
		offset = dsize/512 - 8*2;
863
		offset &= ~(4*2-1);
863
		offset &= ~(4*2-1);
864
		offset *= 512;
864
		offset *= 512;
865
		if (lseek64(fd, offset, 0)< 0LL)
865
		if (lseek(fd, offset, 0)< 0LL)
866
			ret = 3;
866
			ret = 3;
867
		else if (write(fd, st->other, 1024) != 1024)
867
		else if (write(fd, st->other, 1024) != 1024)
868
			ret = 4;
868
			ret = 4;
Lines 877-883 static int store_super0(struct supertype *st, int fd) Link Here
877
877
878
	offset *= 512;
878
	offset *= 512;
879
879
880
	if (lseek64(fd, offset, 0)< 0LL)
880
	if (lseek(fd, offset, 0)< 0LL)
881
		return 3;
881
		return 3;
882
882
883
	if (write(fd, super, sizeof(*super)) != sizeof(*super))
883
	if (write(fd, super, sizeof(*super)) != sizeof(*super))
Lines 1004-1010 static int load_super0(struct supertype *st, int fd, char *devname) Link Here
1004
1004
1005
	offset *= 512;
1005
	offset *= 512;
1006
1006
1007
	if (lseek64(fd, offset, 0)< 0LL) {
1007
	if (lseek(fd, offset, 0)< 0LL) {
1008
		if (devname)
1008
		if (devname)
1009
			pr_err("Cannot seek to superblock on %s: %s\n",
1009
			pr_err("Cannot seek to superblock on %s: %s\n",
1010
				devname, strerror(errno));
1010
				devname, strerror(errno));
Lines 1189-1195 static int locate_bitmap0(struct supertype *st, int fd, int node_num) Link Here
1189
1189
1190
	offset += MD_SB_BYTES;
1190
	offset += MD_SB_BYTES;
1191
1191
1192
	lseek64(fd, offset, 0);
1192
	lseek(fd, offset, 0);
1193
	return 0;
1193
	return 0;
1194
}
1194
}
1195
1195
Lines 1214-1220 static int write_bitmap0(struct supertype *st, int fd, enum bitmap_update update Link Here
1214
1214
1215
	offset *= 512;
1215
	offset *= 512;
1216
1216
1217
	if (lseek64(fd, offset + 4096, 0)< 0LL)
1217
	if (lseek(fd, offset + 4096, 0)< 0LL)
1218
		return 3;
1218
		return 3;
1219
1219
1220
	if (posix_memalign(&buf, 4096, 4096))
1220
	if (posix_memalign(&buf, 4096, 4096))
(-)a/super1.c (-12 / +12 lines)
Lines 761-767 static int copy_metadata1(struct supertype *st, int from, int to) Link Here
761
		goto err;
761
		goto err;
762
	}
762
	}
763
763
764
	if (lseek64(from, sb_offset << 9, 0) < 0LL)
764
	if (lseek(from, sb_offset << 9, 0) < 0LL)
765
		goto err;
765
		goto err;
766
	if (read(from, buf, bufsize) != bufsize)
766
	if (read(from, buf, bufsize) != bufsize)
767
		goto err;
767
		goto err;
Lines 775-781 static int copy_metadata1(struct supertype *st, int from, int to) Link Here
775
	    calc_sb_1_csum(sb) != super.sb_csum)
775
	    calc_sb_1_csum(sb) != super.sb_csum)
776
		goto err;
776
		goto err;
777
777
778
	if (lseek64(to, sb_offset << 9, 0) < 0LL)
778
	if (lseek(to, sb_offset << 9, 0) < 0LL)
779
		goto err;
779
		goto err;
780
	if (write(to, buf, bufsize) != bufsize)
780
	if (write(to, buf, bufsize) != bufsize)
781
		goto err;
781
		goto err;
Lines 791-799 static int copy_metadata1(struct supertype *st, int from, int to) Link Here
791
791
792
		bitmap_offset += (int32_t)__le32_to_cpu(super.bitmap_offset);
792
		bitmap_offset += (int32_t)__le32_to_cpu(super.bitmap_offset);
793
793
794
		if (lseek64(from, bitmap_offset<<9, 0) < 0)
794
		if (lseek(from, bitmap_offset<<9, 0) < 0)
795
			goto err;
795
			goto err;
796
		if (lseek64(to, bitmap_offset<<9, 0) < 0)
796
		if (lseek(to, bitmap_offset<<9, 0) < 0)
797
			goto err;
797
			goto err;
798
798
799
		for (written = 0; written < bytes ; ) {
799
		for (written = 0; written < bytes ; ) {
Lines 832-840 static int copy_metadata1(struct supertype *st, int from, int to) Link Here
832
832
833
		bb_offset += (int32_t)__le32_to_cpu(super.bblog_offset);
833
		bb_offset += (int32_t)__le32_to_cpu(super.bblog_offset);
834
834
835
		if (lseek64(from, bb_offset<<9, 0) < 0)
835
		if (lseek(from, bb_offset<<9, 0) < 0)
836
			goto err;
836
			goto err;
837
		if (lseek64(to, bb_offset<<9, 0) < 0)
837
		if (lseek(to, bb_offset<<9, 0) < 0)
838
			goto err;
838
			goto err;
839
839
840
		for (written = 0; written < bytes ; ) {
840
		for (written = 0; written < bytes ; ) {
Lines 940-946 static int examine_badblocks_super1(struct supertype *st, int fd, char *devname) Link Here
940
	offset = __le64_to_cpu(sb->super_offset) +
940
	offset = __le64_to_cpu(sb->super_offset) +
941
		(int)__le32_to_cpu(sb->bblog_offset);
941
		(int)__le32_to_cpu(sb->bblog_offset);
942
	offset <<= 9;
942
	offset <<= 9;
943
	if (lseek64(fd, offset, 0) < 0) {
943
	if (lseek(fd, offset, 0) < 0) {
944
		pr_err("Cannot seek to bad-blocks list\n");
944
		pr_err("Cannot seek to bad-blocks list\n");
945
		return 1;
945
		return 1;
946
	}
946
	}
Lines 1797-1803 static int store_super1(struct supertype *st, int fd) Link Here
1797
		abort();
1797
		abort();
1798
	}
1798
	}
1799
1799
1800
	if (lseek64(fd, sb_offset << 9, 0)< 0LL)
1800
	if (lseek(fd, sb_offset << 9, 0)< 0LL)
1801
		return 3;
1801
		return 3;
1802
1802
1803
	sbsize = ROUND_UP(sizeof(*sb) + 2 * __le32_to_cpu(sb->max_dev), 512);
1803
	sbsize = ROUND_UP(sizeof(*sb) + 2 * __le32_to_cpu(sb->max_dev), 512);
Lines 1866-1872 static int write_init_ppl1(struct supertype *st, struct mdinfo *info, int fd) Link Here
1866
						      sizeof(sb->set_uuid)));
1866
						      sizeof(sb->set_uuid)));
1867
	ppl_hdr->checksum = __cpu_to_le32(~crc32c_le(~0, buf, PPL_HEADER_SIZE));
1867
	ppl_hdr->checksum = __cpu_to_le32(~crc32c_le(~0, buf, PPL_HEADER_SIZE));
1868
1868
1869
	if (lseek64(fd, info->ppl_sector * 512, SEEK_SET) < 0) {
1869
	if (lseek(fd, info->ppl_sector * 512, SEEK_SET) < 0) {
1870
		ret = errno;
1870
		ret = errno;
1871
		perror("Failed to seek to PPL header location");
1871
		perror("Failed to seek to PPL header location");
1872
	}
1872
	}
Lines 1911-1917 static int write_empty_r5l_meta_block(struct supertype *st, int fd) Link Here
1911
	crc = crc32c_le(crc, (void *)mb, META_BLOCK_SIZE);
1911
	crc = crc32c_le(crc, (void *)mb, META_BLOCK_SIZE);
1912
	mb->checksum = crc;
1912
	mb->checksum = crc;
1913
1913
1914
	if (lseek64(fd, __le64_to_cpu(sb->data_offset) * 512, 0) < 0LL) {
1914
	if (lseek(fd, __le64_to_cpu(sb->data_offset) * 512, 0) < 0LL) {
1915
		pr_err("cannot seek to offset of the meta block\n");
1915
		pr_err("cannot seek to offset of the meta block\n");
1916
		goto fail_to_write;
1916
		goto fail_to_write;
1917
	}
1917
	}
Lines 2268-2274 static int load_super1(struct supertype *st, int fd, char *devname) Link Here
2268
		return -EINVAL;
2268
		return -EINVAL;
2269
	}
2269
	}
2270
2270
2271
	if (lseek64(fd, sb_offset << 9, 0)< 0LL) {
2271
	if (lseek(fd, sb_offset << 9, 0)< 0LL) {
2272
		if (devname)
2272
		if (devname)
2273
			pr_err("Cannot seek to superblock on %s: %s\n",
2273
			pr_err("Cannot seek to superblock on %s: %s\n",
2274
				devname, strerror(errno));
2274
				devname, strerror(errno));
Lines 2639-2645 static int locate_bitmap1(struct supertype *st, int fd, int node_num) Link Here
2639
	}
2639
	}
2640
	if (mustfree)
2640
	if (mustfree)
2641
		free(sb);
2641
		free(sb);
2642
	lseek64(fd, offset<<9, 0);
2642
	lseek(fd, offset<<9, 0);
2643
	return ret;
2643
	return ret;
2644
}
2644
}
2645
2645
(-)a/swap_super.c (-5 / +5 lines)
Lines 16-22 Link Here
16
16
17
#define MD_NEW_SIZE_SECTORS(x)		((x & ~(MD_RESERVED_SECTORS - 1)) - MD_RESERVED_SECTORS)
17
#define MD_NEW_SIZE_SECTORS(x)		((x & ~(MD_RESERVED_SECTORS - 1)) - MD_RESERVED_SECTORS)
18
18
19
extern long long lseek64(int, long long, int);
19
extern long long lseek(int, long long, int);
20
20
21
int main(int argc, char *argv[])
21
int main(int argc, char *argv[])
22
{
22
{
Lines 38-45 int main(int argc, char *argv[]) Link Here
38
		exit(1);
38
		exit(1);
39
	}
39
	}
40
	offset = MD_NEW_SIZE_SECTORS(size) * 512LL;
40
	offset = MD_NEW_SIZE_SECTORS(size) * 512LL;
41
	if (lseek64(fd, offset, 0) < 0LL) {
41
	if (lseek(fd, offset, 0) < 0LL) {
42
		perror("lseek64");
42
		perror("lseek");
43
		exit(1);
43
		exit(1);
44
	}
44
	}
45
	if (read(fd, super, 4096) != 4096) {
45
	if (read(fd, super, 4096) != 4096) {
Lines 68-75 int main(int argc, char *argv[]) Link Here
68
		super[32*4+10*4 +i] = t;
68
		super[32*4+10*4 +i] = t;
69
	}
69
	}
70
70
71
	if (lseek64(fd, offset, 0) < 0LL) {
71
	if (lseek(fd, offset, 0) < 0LL) {
72
		perror("lseek64");
72
		perror("lseek");
73
		exit(1);
73
		exit(1);
74
	}
74
	}
75
	if (write(fd, super, 4096) != 4096) {
75
	if (write(fd, super, 4096) != 4096) {
(-)a/util.c (-1 / +1 lines)
Lines 2344-2350 int zero_disk_range(int fd, unsigned long long sector, size_t count) Link Here
2344
		return -1;
2344
		return -1;
2345
	}
2345
	}
2346
2346
2347
	if (lseek64(fd, sector * 512, SEEK_SET) < 0) {
2347
	if (lseek(fd, sector * 512, SEEK_SET) < 0) {
2348
		ret = -errno;
2348
		ret = -errno;
2349
		pr_err("Failed to seek offset for zeroing\n");
2349
		pr_err("Failed to seek offset for zeroing\n");
2350
		goto out;
2350
		goto out;

Return to bug 907082