Compare commits

...

4 commits

Author SHA1 Message Date
Andrea Mazzoleni
9fc16eb4da Update gitignore
Some checks are pending
Build / build-mac (push) Waiting to run
Build / build-linux (push) Waiting to run
Build / build-win (push) Waiting to run
CodeQL Advanced / Analyze (c-cpp) (push) Waiting to run
CodeQL Advanced / Analyze (actions) (push) Waiting to run
2026-03-18 14:27:05 +01:00
Andrea Mazzoleni
064ee1dc50 Rework makecheck and makedist 2026-03-18 14:27:05 +01:00
Andrea Mazzoleni
781dd25025 Move the FLAG_IS_RELOCATED to dedicated shared flags to avoid data races 2026-03-18 12:02:05 +01:00
Andrea Mazzoleni
3f9b877183 Missing of fadvise is not a fatal error 2026-03-18 11:31:44 +01:00
6 changed files with 73 additions and 35 deletions

2
.gitignore vendored
View file

@ -5,6 +5,7 @@
*.txz
*.deb
*.rpm
*.zst
# backups
*~
@ -63,6 +64,7 @@ pkg/.SRCINFO
*.dst
*.epr
*.geany
session.conf
# AFL
makeafl.sh

View file

@ -392,6 +392,7 @@ struct snapraid_file* file_alloc(unsigned block_size, const char* sub, data_off_
file->inode = inode;
file->physical = physical;
file->flag = 0;
file->shared_flag = 0;
file->blockvec = malloc_nofail(file->blockmax * block_sizeof());
for (i = 0; i < file->blockmax; ++i) {

View file

@ -265,6 +265,18 @@ struct snapraid_block {
*/
#define FILE_IS_MISSING 0x800
#define FILE_IS_HARDLINK 0x1000 /**< If it's an hardlink. */
#define FILE_IS_SYMLINK 0x2000 /**< If it's a file symlink. */
#define FILE_IS_SYMDIR 0x4000 /**< If it's a dir symlink for Windows. Not yet supported. */
#define FILE_IS_JUNCTION 0x8000 /**< If it's a junction for Windows. Not yet supported. */
#define FILE_IS_LINK_MASK 0xF000 /**< Mask for link type. */
/**
* Flags from this bit are shared between multiple threads
* and goes in the shared_flags instead of flags
*/
#define FILE_FLAGS_SHARED_BIT 16
/**
* During scan if the file is found missing and relocated to another place
*
@ -273,13 +285,7 @@ struct snapraid_block {
* This specific bit is written using protection from the stamp_mutex during
* the multithread scan.
*/
#define FILE_IS_RELOCATED 0x1000
#define FILE_IS_HARDLINK 0x10000 /**< If it's an hardlink. */
#define FILE_IS_SYMLINK 0x20000 /**< If it's a file symlink. */
#define FILE_IS_SYMDIR 0x40000 /**< If it's a dir symlink for Windows. Not yet supported. */
#define FILE_IS_JUNCTION 0x80000 /**< If it's a junction for Windows. Not yet supported. */
#define FILE_IS_LINK_MASK 0xF0000 /**< Mask for link type. */
#define FILE_IS_RELOCATED 0x10000
/**
* File.
@ -292,7 +298,8 @@ struct snapraid_file {
struct snapraid_block* blockvec; /**< All the blocks of the file. */
int mtime_nsec; /**< Modification time nanoseconds. In the range 0 <= x < 1,000,000,000, or STAT_NSEC_INVALID if not present. */
block_off_t blockmax; /**< Number of blocks. */
unsigned flag; /**< FILE_IS_* flags. */
uint16_t flag; /**< FILE_IS_* flags. */
uint16_t shared_flag; /**< FILE_IS_RELOCATED flag. Keep it separated as it's accessed by multiple threads */
char* sub; /**< Sub path of the file. Without the disk dir. The disk is implicit. */
/* nodes for data structures */
@ -786,17 +793,32 @@ static inline int block_has_file_and_valid_parity(const struct snapraid_block* b
static inline int file_flag_has(const struct snapraid_file* file, unsigned mask)
{
return (file->flag & mask) == mask;
if (mask >= (1 << FILE_FLAGS_SHARED_BIT)) {
mask >>= FILE_FLAGS_SHARED_BIT;
return (file->shared_flag & mask) == mask;
} else {
return (file->flag & mask) == mask;
}
}
static inline void file_flag_set(struct snapraid_file* file, unsigned mask)
{
file->flag |= mask;
if (mask >= (1 << FILE_FLAGS_SHARED_BIT)) {
mask >>= FILE_FLAGS_SHARED_BIT;
file->shared_flag |= mask;
} else {
file->flag |= mask;
}
}
static inline void file_flag_clear(struct snapraid_file* file, unsigned mask)
{
file->flag &= ~mask;
if (mask >= (1 << FILE_FLAGS_SHARED_BIT)) {
mask >>= FILE_FLAGS_SHARED_BIT;
file->shared_flag &= ~mask;
} else {
file->flag &= ~mask;
}
}
/**

View file

@ -65,7 +65,7 @@ STREAM* sopen_read(const char* file, int flags)
/* advise sequential access */
ret = posix_fadvise(s->handle[0].f, 0, 0, POSIX_FADV_SEQUENTIAL);
if (ret == ENOSYS) {
log_fatal(errno, "WARNING! fadvise() is not supported in this platform. Performance may not be optimal!\n");
log_error(errno, "WARNING! fadvise() is not supported in this platform. Performance may not be optimal!\n");
/* call is not supported, like in armhf, see posix_fadvise manpage */
ret = 0;
}

View file

@ -17,6 +17,30 @@ if ! $SOURCE/configure; then
exit 1
fi
if ! time make check; then
if ! make -j4; then
exit 1
fi
if ! make check; then
exit 1
fi
if ! make distclean; then
exit 1
fi
if ! $SOURCE/configure --host=x86_64-w64-mingw32.static --build=`$SOURCE/config.guess`; then
exit 1
fi
if ! make -j4; then
exit 1
fi
if ! make check; then
exit 1
fi
if ! make distclean; then
exit 1
fi

View file

@ -1,17 +1,6 @@
#!/bin/sh
#
CHECK=check
DEBUG=
if test "x$1" = "x-f"; then
CHECK=all
fi
if test "x$1" = "x-d"; then
DEBUG=--enable-debug
fi
# Ask root permissions at the start
sudo echo We are root
@ -20,7 +9,15 @@ make distclean
# Reconfigure (with force) to get the latest revision from git
autoreconf -f
if ! ./configure.windows-x86 $DEBUG; then
if ! ./configure ; then
exit 1
fi
if ! make dist; then
exit 1
fi
if ! ./configure.windows-x86; then
exit 1
fi
@ -32,11 +29,11 @@ if ! make distwindows-x86 distclean; then
exit 1
fi
if ! ./configure.windows-x64 $DEBUG; then
if ! ./configure.windows-x64; then
exit 1
fi
if ! make -j4 $CHECK; then
if ! make -j4; then
exit 1
fi
@ -44,14 +41,6 @@ if ! make distwindows-x64 distclean; then
exit 1
fi
if ! ./configure ; then
exit 1
fi
if ! make dist; then
exit 1
fi
sh makeslackdist.sh
sh makearchdist.sh
sudo sh makeslackware.sh