Skip to content

Commit

Permalink
sparse file detection test
Browse files Browse the repository at this point in the history
  • Loading branch information
jmroot committed Oct 7, 2024
1 parent c826f3f commit 68054a2
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 4 deletions.
21 changes: 17 additions & 4 deletions math/pari/Portfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,23 @@ checksums rmd160 3381ba95fdc5b807b82516253dca029a4cf9c45f \

# System's tar on at least macOS Ventura is broken
# See: https://trac.macports.org/ticket/67336
pre-install {
if {[getuid] == 0 && [file exists /usr/sbin/purge]} {
system "/usr/sbin/purge"
}
#pre-install {
# if {[getuid] == 0 && [file exists /usr/sbin/purge]} {
# system "/usr/sbin/purge"
# }
#}

pre-build {
system -W $workpath "${configure.cc} ${configure.optflags} -o findholes ${filespath}/findholes.c"
}

post-destroot {
system -W $workpath "./findholes ${destroot}${prefix}/lib/libpari-gmp.dylib"
ui_msg "destroot libpari-gmp.dylib is binary? [fileIsBinary ${destroot}${prefix}/lib/libpari-gmp.dylib]"
}

post-activate {
ui_msg "activated libpari-gmp.dylib is binary? [fileIsBinary ${prefix}/lib/libpari-gmp.dylib]"
}

depends_lib port:gmp \
Expand Down
28 changes: 28 additions & 0 deletions math/pari/files/findholes.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>

int main(int argc, char *argv[])
{
off_t seekpos = 0;

if (argc < 2) {
printf("usage: %s file\n", argv[0]);
return 1;
}

int fd = open(argv[1], O_RDONLY);
if (fd < 0) {
perror("open");
return 1;
}

seekpos = lseek(fd, 0, SEEK_SET);
seekpos = lseek(fd, 0, SEEK_HOLE);
printf("SEEK_HOLE: seekpos = %lld\n", seekpos);
seekpos = lseek(fd, 0, SEEK_DATA);
printf("SEEK_DATA: seekpos = %lld\n", seekpos);

close(fd);
return 0;
}

0 comments on commit 68054a2

Please sign in to comment.