void-packages/srcpkgs/nocache/patches/musl.patch
Đoàn Trần Công Danh 65749575ab srcpkgs/n*: convert patches to -Np1
```sh
git grep -l '^patch_args=-Np0' "srcpkgs/$1*/template" |
while read template; do
	for p in ${template%/template}/patches/*; do
		sed -i '
			\,^[+-][+-][+-] /dev/null,b
			/^[*-]\+ [0-9]\+\(,[0-9]\+\)\? [*-]\+$/b
			s,^[*][*][*] ,&a/,
			/^--- /{
				s,\(^--- \)\(./\)*,\1a/,
				s,[.-][Oo][Rr][Ii][Gg]\([	/]\),\1,
				s/[.-][Oo][Rr][Ii][Gg]$//
				s/[.]patched[.]\([^.]\)/.\1/
				h
			}
			/^+++ -/{
				g
				s/^--- a/+++ b/
				b
			}
			s,\(^+++ \)\(./\)*,\1b/,
		' "$p"
	done
	sed -i '/^patch_args=/d' $template
done
```
2021-06-20 13:17:29 +07:00

142 lines
4.5 KiB
Diff

diff --git nocache.c nocache.c
index 6f8c60d..fa4abff 100644
--- a/nocache.c
+++ b/nocache.c
@@ -25,31 +25,47 @@ static void store_pageinfo(int fd);
static void free_unclaimed_pages(int fd);
int open(const char *pathname, int flags, mode_t mode);
+#if defined(__GLIBC__)
int open64(const char *pathname, int flags, mode_t mode);
+#endif
int creat(const char *pathname, int flags, mode_t mode);
+#if defined(__GLIBC__)
int creat64(const char *pathname, int flags, mode_t mode);
+#endif
int openat(int dirfd, const char *pathname, int flags, mode_t mode);
+#if defined(__GLIBC__)
int openat64(int dirfd, const char *pathname, int flags, mode_t mode);
+#endif
int __openat_2(int dirfd, const char *pathname, int flags, mode_t mode)
__attribute__ ((alias ("openat")));
int dup(int oldfd);
int dup2(int oldfd, int newfd);
int close(int fd);
FILE *fopen(const char *path, const char *mode);
+#if defined(__GLIBC__)
FILE *fopen64(const char *path, const char *mode);
+#endif
int fclose(FILE *fp);
int (*_original_open)(const char *pathname, int flags, mode_t mode);
+#if defined(__GLIBC__)
int (*_original_open64)(const char *pathname, int flags, mode_t mode);
+#endif
int (*_original_creat)(const char *pathname, int flags, mode_t mode);
+#if defined(__GLIBC__)
int (*_original_creat64)(const char *pathname, int flags, mode_t mode);
+#endif
int (*_original_openat)(int dirfd, const char *pathname, int flags, mode_t mode);
+#if defined(__GLIBC__)
int (*_original_openat64)(int dirfd, const char *pathname, int flags, mode_t mode);
+#endif
int (*_original_dup)(int fd);
int (*_original_dup2)(int newfd, int oldfd);
int (*_original_close)(int fd);
FILE *(*_original_fopen)(const char *path, const char *mode);
+#if defined(__GLIBC__)
FILE *(*_original_fopen64)(const char *path, const char *mode);
+#endif
int (*_original_fclose)(FILE *fp);
@@ -82,16 +98,24 @@ static void init(void)
assert(fds != NULL);
_original_open = (int (*)(const char *, int, mode_t)) dlsym(RTLD_NEXT, "open");
+#if defined(__GLIBC__)
_original_open64 = (int (*)(const char *, int, mode_t)) dlsym(RTLD_NEXT, "open64");
+#endif
_original_creat = (int (*)(const char *, int, mode_t)) dlsym(RTLD_NEXT, "creat");
+#if defined(__GLIBC__)
_original_creat64 = (int (*)(const char *, int, mode_t)) dlsym(RTLD_NEXT, "creat64");
+#endif
_original_openat = (int (*)(int, const char *, int, mode_t)) dlsym(RTLD_NEXT, "openat");
+#if defined(__GLIBC__)
_original_openat64 = (int (*)(int, const char *, int, mode_t)) dlsym(RTLD_NEXT, "openat64");
+#endif
_original_dup = (int (*)(int)) dlsym(RTLD_NEXT, "dup");
_original_dup2 = (int (*)(int, int)) dlsym(RTLD_NEXT, "dup2");
_original_close = (int (*)(int)) dlsym(RTLD_NEXT, "close");
_original_fopen = (FILE *(*)(const char *, const char *)) dlsym(RTLD_NEXT, "fopen");
+#if defined(__GLIBC__)
_original_fopen64 = (FILE *(*)(const char *, const char *)) dlsym(RTLD_NEXT, "fopen64");
+#endif
_original_fclose = (int (*)(FILE *)) dlsym(RTLD_NEXT, "fclose");
if ((error = dlerror()) != NULL) {
@@ -165,6 +189,7 @@ int open(const char *pathname, int flags, mode_t mode)
return fd;
}
+#if defined(__GLIBC__)
int open64(const char *pathname, int flags, mode_t mode)
{
int fd;
@@ -177,6 +202,7 @@ int open64(const char *pathname, int flags, mode_t mode)
store_pageinfo(fd);
return fd;
}
+#endif
int creat(const char *pathname, int flags, mode_t mode)
{
@@ -191,6 +217,7 @@ int creat(const char *pathname, int flags, mode_t mode)
return fd;
}
+#if defined(__GLIBC__)
int creat64(const char *pathname, int flags, mode_t mode)
{
int fd;
@@ -203,6 +230,7 @@ int creat64(const char *pathname, int flags, mode_t mode)
store_pageinfo(fd);
return fd;
}
+#endif
int openat(int dirfd, const char *pathname, int flags, mode_t mode)
{
@@ -217,6 +245,7 @@ int openat(int dirfd, const char *pathname, int flags, mode_t mode)
return fd;
}
+#if defined(__GLIBC__)
int openat64(int dirfd, const char *pathname, int flags, mode_t mode)
{
int fd;
@@ -229,6 +258,7 @@ int openat64(int dirfd, const char *pathname, int flags, mode_t mode)
store_pageinfo(fd);
return fd;
}
+#endif
int dup(int oldfd)
{
@@ -288,6 +318,7 @@ FILE *fopen(const char *path, const char *mode)
return fp;
}
+#if defined(__GLIBC__)
FILE *fopen64(const char *path, const char *mode)
{
int fd;
@@ -304,6 +335,7 @@ FILE *fopen64(const char *path, const char *mode)
return fp;
}
+#endif
int fclose(FILE *fp)
{