@@ -510,7 +510,6 @@ static int open_packed_git_1(struct packed_git *p)
510
510
struct pack_header hdr ;
511
511
unsigned char hash [GIT_MAX_RAWSZ ];
512
512
unsigned char * idx_hash ;
513
- long fd_flag ;
514
513
ssize_t read_result ;
515
514
const unsigned hashsz = the_hash_algo -> rawsz ;
516
515
@@ -554,16 +553,6 @@ static int open_packed_git_1(struct packed_git *p)
554
553
} else if (p -> pack_size != st .st_size )
555
554
return error ("packfile %s size changed" , p -> pack_name );
556
555
557
- /* We leave these file descriptors open with sliding mmap;
558
- * there is no point keeping them open across exec(), though.
559
- */
560
- fd_flag = fcntl (p -> pack_fd , F_GETFD , 0 );
561
- if (fd_flag < 0 )
562
- return error ("cannot determine file descriptor flags" );
563
- fd_flag |= FD_CLOEXEC ;
564
- if (fcntl (p -> pack_fd , F_SETFD , fd_flag ) == -1 )
565
- return error ("cannot set FD_CLOEXEC" );
566
-
567
556
/* Verify we recognize this pack file format. */
568
557
read_result = read_in_full (p -> pack_fd , & hdr , sizeof (hdr ));
569
558
if (read_result < 0 )
@@ -587,9 +576,8 @@ static int open_packed_git_1(struct packed_git *p)
587
576
" while index indicates %" PRIu32 " objects" ,
588
577
p -> pack_name , ntohl (hdr .hdr_entries ),
589
578
p -> num_objects );
590
- if (lseek (p -> pack_fd , p -> pack_size - hashsz , SEEK_SET ) == -1 )
591
- return error ("end of packfile %s is unavailable" , p -> pack_name );
592
- read_result = read_in_full (p -> pack_fd , hash , hashsz );
579
+ read_result = pread_in_full (p -> pack_fd , hash , hashsz ,
580
+ p -> pack_size - hashsz );
593
581
if (read_result < 0 )
594
582
return error_errno ("error reading from %s" , p -> pack_name );
595
583
if (read_result != hashsz )
0 commit comments