[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[Git][snapshot-team/snapshot][master] 2 commits: Make fsck-1 build again



Title: GitLab

Peter Palfrader pushed to branch master at snapshot / snapshot

Commits:

  • c05bcc24
    by Peter Palfrader at 2025-04-13T10:01:10+02:00
    Make fsck-1 build again
    
  • 432ac95f
    by Peter Palfrader at 2025-04-13T10:05:46+02:00
    queue 8k files at a time
    

4 changed files:

Changes:

  • fsck/check-1/.gitignore
    1
    -lib
    1
    +build
    
    2
    +usr
    
    3
    +Hasher.egg-info

  • fsck/check-1/Makefile
    1 1
     
    
    2
    -lib/python2.5/site-packages/hasher.so: hasher.c setup.py
    
    3
    -	python setup.py install --record /dev/null --prefix=.
    
    2
    +usr/lib/python3/dist-packages/hasher.cpython-311-x86_64-linux-gnu.so: hasher.c setup.py
    
    3
    +	python3 ./setup.py install --root . --install-layout deb
    
    4 4
     	rm -r build
    
    5 5
     
    
    6 6
     clean:
    
    7
    -	rm -rf lib
    7
    +	rm -rf usr Hasher.egg-info

  • fsck/check-1/hash
    ... ... @@ -28,11 +28,7 @@ import sys
    28 28
     import threading
    
    29 29
     import random
    
    30 30
     import queue
    
    31
    -try:
    
    32
    -    from distutils import sysconfig
    
    33
    -    sys.path.append(sysconfig.get_python_lib(prefix=os.path.abspath(os.path.dirname(sys.argv[0]))))
    
    34
    -except ImportError:
    
    35
    -    sys.path.append(os.path.abspath(os.path.dirname(sys.argv[0]))+'/lib/python2.6/site-packages')
    
    31
    +sys.path.append(os.path.join(os.path.abspath(os.path.dirname(sys.argv[0])), 'usr/lib/python3/dist-packages'))
    
    36 32
     import hasher
    
    37 33
     
    
    38 34
     
    
    ... ... @@ -92,7 +88,7 @@ try:
    92 88
                             if verbose >= 2: print("Invalid name %s"%(filename)); sys.stdout.flush()
    
    93 89
                             continue
    
    94 90
                         inqueue.append((p,filename))
    
    95
    -                if len(inqueue) > 2000: enqueue(inqueue)
    
    91
    +                if len(inqueue) > 8000: enqueue(inqueue)
    
    96 92
         enqueue(inqueue)
    
    97 93
     finally:
    
    98 94
         for x in range ( numthreads ):
    

  • fsck/check-1/hasher.c
    ... ... @@ -29,7 +29,10 @@
    29 29
     #include <string.h>
    
    30 30
     #include <errno.h>
    
    31 31
     #include <openssl/sha.h>
    
    32
    +#include <openssl/evp.h>
    
    32 33
     #include <fcntl.h>
    
    34
    +
    
    35
    +#define PY_SSIZE_T_CLEAN
    
    33 36
     #include <Python.h>
    
    34 37
     
    
    35 38
     #define SHA1SIZE 20
    
    ... ... @@ -60,11 +63,10 @@ static PyObject *hash_file(PyObject *self, PyObject *args)
    60 63
     	int fd, num_read;
    
    61 64
     	unsigned char ibuf[BLOCKSIZE];
    
    62 65
     	unsigned char obuf[SHA1SIZE];
    
    63
    -	SHA_CTX ctx;
    
    64 66
     	PyObject *res = NULL;
    
    65 67
     	PyThreadState *_save;
    
    66 68
     	char res_s[2*SHA1SIZE + 1];
    
    67
    -	int r;
    
    69
    +	unsigned int r;
    
    68 70
     
    
    69 71
     	if (!PyArg_ParseTuple(args, "s", &filename))
    
    70 72
     		goto done;
    
    ... ... @@ -79,8 +81,11 @@ static PyObject *hash_file(PyObject *self, PyObject *args)
    79 81
     	//posix_fadvise(fd, 0, 0, POSIX_FADV_WILLNEED);
    
    80 82
     	posix_fadvise(fd, 0, 0, POSIX_FADV_SEQUENTIAL);
    
    81 83
     
    
    82
    -	if (SHA1_Init(&ctx) != 1)
    
    83
    -		py_err("SHA1_Init()", NULL);
    
    84
    +	EVP_MD_CTX *sha1_ctx = EVP_MD_CTX_new();
    
    85
    +	if (!sha1_ctx)
    
    86
    +		py_err("EVP_MD_CTX_new()", NULL);
    
    87
    +	if (EVP_DigestInit(sha1_ctx, EVP_sha1()) != 1)
    
    88
    +		py_err("EVP_DigestInit()", NULL);
    
    84 89
     	while ((num_read = read(fd, ibuf, BLOCKSIZE))) {
    
    85 90
     		if (num_read < 0) {
    
    86 91
     			if (errno == EINTR)
    
    ... ... @@ -88,10 +93,10 @@ static PyObject *hash_file(PyObject *self, PyObject *args)
    88 93
     			else
    
    89 94
     				py_err("During read", filename);
    
    90 95
     		}
    
    91
    -		if (SHA1_Update(&ctx, ibuf, num_read) != 1)
    
    92
    -			py_err("SHA1_Update", NULL);
    
    96
    +		if (EVP_DigestUpdate(sha1_ctx, ibuf, num_read) != 1)
    
    97
    +			py_err("EVP_DigestUpdate", NULL);
    
    93 98
     	}
    
    94
    -	if (SHA1_Final(obuf, &ctx) != 1)
    
    99
    +	if (EVP_DigestFinal(sha1_ctx, obuf, NULL) != 1)
    
    95 100
     		py_err("SHA1_Final", NULL);
    
    96 101
     	posix_fadvise(fd, 0, 0, POSIX_FADV_DONTNEED);
    
    97 102
     	if (close(fd) < 0)
    
    ... ... @@ -110,6 +115,7 @@ static PyObject *hash_file(PyObject *self, PyObject *args)
    110 115
     		printf("%d vs %ld\n", r, sizeof(res_s));
    
    111 116
     		py_err("snprintf failure", filename);
    
    112 117
     	}
    
    118
    +	EVP_MD_CTX_free(sha1_ctx);
    
    113 119
     
    
    114 120
     	/** reacquire GIL **/
    
    115 121
     	Py_BLOCK_THREADS
    


  • Reply to: