You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-06-14 23:44:58 +02:00
Full abstraction of storage driver interface.
The external storage interfaces (Storage, StorageFileRead, etc.) have been stable for a while, but internally they were calling the posix driver functions directly. Create driver interfaces for storage, fileRead, and fileWrite and remove all references to the posix driver outside storage/driver/posix (with the exception of a direct call to pathRemove() in Perl LibC). Posix is still the only available driver so more adjustment may be needed, but this should represent the bulk of the changes.
This commit is contained in:
@ -53,7 +53,7 @@
|
||||
</release-item>
|
||||
|
||||
<release-item>
|
||||
<p>Storage refactoring. Posix file functions now differentiate between open and missing errors. Don't use negations in objects below Storage. Rename posix driver files/functions for consistency.</p>
|
||||
<p>Storage refactoring. Posix file functions now differentiate between open and missing errors. Don't use negations in objects below Storage. Rename posix driver files/functions for consistency. Full abstraction of storage driver interface.</p>
|
||||
</release-item>
|
||||
|
||||
<release-item>
|
||||
|
@ -13,6 +13,6 @@ storageDriverPosixPathRemove(path, errorOnMissing, recurse)
|
||||
CODE:
|
||||
MEM_CONTEXT_XS_TEMP_BEGIN()
|
||||
{
|
||||
storageDriverPosixPathRemove(strNew(path), errorOnMissing, recurse);
|
||||
storageDriverPosixPathRemove(storageDriverPosixNew(strNew("/"), 0640, 750, true, NULL), strNew(path), errorOnMissing, recurse);
|
||||
}
|
||||
MEM_CONTEXT_XS_TEMP_END();
|
||||
|
42
src/Makefile
42
src/Makefile
@ -142,22 +142,22 @@ install: pgbackrest
|
||||
####################################################################################################################################
|
||||
# Compile rules
|
||||
####################################################################################################################################
|
||||
command/archive/common.o: command/archive/common.c command/archive/common.h common/assert.h common/debug.h common/error.auto.h common/error.h common/io/filter/filter.h common/io/filter/group.h common/io/read.h common/io/write.h common/log.h common/logLevel.h common/memContext.h common/regExp.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h common/wait.h postgres/version.h protocol/storage/helper.h storage/driver/posix/fileRead.h storage/driver/posix/fileWrite.h storage/fileRead.h storage/fileWrite.h storage/helper.h storage/info.h storage/storage.h version.h
|
||||
command/archive/common.o: command/archive/common.c command/archive/common.h common/assert.h common/debug.h common/error.auto.h common/error.h common/io/filter/filter.h common/io/filter/group.h common/io/read.h common/io/write.h common/log.h common/logLevel.h common/memContext.h common/regExp.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h common/wait.h postgres/version.h protocol/storage/helper.h storage/fileRead.h storage/fileWrite.h storage/helper.h storage/info.h storage/storage.h
|
||||
$(CC) $(CFLAGS) -c command/archive/common.c -o command/archive/common.o
|
||||
|
||||
command/archive/get/file.o: command/archive/get/file.c command/archive/common.h command/archive/get/file.h command/control/control.h common/debug.h common/error.auto.h common/error.h common/io/filter/filter.h common/io/filter/group.h common/io/read.h common/io/write.h common/lock.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h compress/gzip.h compress/gzipDecompress.h config/config.auto.h config/config.h config/define.auto.h config/define.h info/infoArchive.h info/infoPg.h postgres/info.h protocol/storage/helper.h storage/driver/posix/fileRead.h storage/driver/posix/fileWrite.h storage/fileRead.h storage/fileWrite.h storage/helper.h storage/info.h storage/storage.h version.h
|
||||
command/archive/get/file.o: command/archive/get/file.c command/archive/common.h command/archive/get/file.h command/control/control.h common/debug.h common/error.auto.h common/error.h common/io/filter/filter.h common/io/filter/group.h common/io/read.h common/io/write.h common/lock.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h compress/gzip.h compress/gzipDecompress.h config/config.auto.h config/config.h config/define.auto.h config/define.h info/infoArchive.h info/infoPg.h postgres/info.h protocol/storage/helper.h storage/fileRead.h storage/fileWrite.h storage/helper.h storage/info.h storage/storage.h
|
||||
$(CC) $(CFLAGS) -c command/archive/get/file.c -o command/archive/get/file.o
|
||||
|
||||
command/archive/get/get.o: command/archive/get/get.c command/archive/common.h command/archive/get/file.h command/command.h common/assert.h common/debug.h common/error.auto.h common/error.h common/fork.h common/io/filter/filter.h common/io/filter/group.h common/io/read.h common/io/write.h common/lock.h common/log.h common/logLevel.h common/memContext.h common/regExp.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h common/wait.h config/config.auto.h config/config.h config/define.auto.h config/define.h config/load.h perl/exec.h postgres/info.h protocol/storage/helper.h storage/driver/posix/fileRead.h storage/driver/posix/fileWrite.h storage/fileRead.h storage/fileWrite.h storage/helper.h storage/info.h storage/storage.h version.h
|
||||
command/archive/get/get.o: command/archive/get/get.c command/archive/common.h command/archive/get/file.h command/command.h common/assert.h common/debug.h common/error.auto.h common/error.h common/fork.h common/io/filter/filter.h common/io/filter/group.h common/io/read.h common/io/write.h common/lock.h common/log.h common/logLevel.h common/memContext.h common/regExp.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h common/wait.h config/config.auto.h config/config.h config/define.auto.h config/define.h config/load.h perl/exec.h postgres/info.h protocol/storage/helper.h storage/fileRead.h storage/fileWrite.h storage/helper.h storage/info.h storage/storage.h
|
||||
$(CC) $(CFLAGS) -c command/archive/get/get.c -o command/archive/get/get.o
|
||||
|
||||
command/archive/push/push.o: command/archive/push/push.c command/archive/common.h command/command.h common/debug.h common/error.auto.h common/error.h common/fork.h common/io/filter/filter.h common/io/filter/group.h common/io/read.h common/io/write.h common/lock.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h common/wait.h config/config.auto.h config/config.h config/define.auto.h config/define.h config/load.h perl/exec.h storage/driver/posix/fileRead.h storage/driver/posix/fileWrite.h storage/fileRead.h storage/fileWrite.h storage/helper.h storage/info.h storage/storage.h version.h
|
||||
command/archive/push/push.o: command/archive/push/push.c command/archive/common.h command/command.h common/debug.h common/error.auto.h common/error.h common/fork.h common/io/filter/filter.h common/io/filter/group.h common/io/read.h common/io/write.h common/lock.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h common/wait.h config/config.auto.h config/config.h config/define.auto.h config/define.h config/load.h perl/exec.h storage/fileRead.h storage/fileWrite.h storage/helper.h storage/info.h storage/storage.h
|
||||
$(CC) $(CFLAGS) -c command/archive/push/push.c -o command/archive/push/push.o
|
||||
|
||||
command/command.o: command/command.c common/assert.h common/debug.h common/error.auto.h common/error.h common/lock.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/time.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h config/config.auto.h config/config.h config/define.auto.h config/define.h version.h
|
||||
$(CC) $(CFLAGS) -c command/command.c -o command/command.o
|
||||
|
||||
command/control/control.o: command/control/control.c command/control/control.h common/debug.h common/error.auto.h common/error.h common/io/filter/filter.h common/io/filter/group.h common/io/read.h common/io/write.h common/lock.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h config/config.auto.h config/config.h config/define.auto.h config/define.h storage/driver/posix/fileRead.h storage/driver/posix/fileWrite.h storage/fileRead.h storage/fileWrite.h storage/helper.h storage/info.h storage/storage.h version.h
|
||||
command/control/control.o: command/control/control.c command/control/control.h common/debug.h common/error.auto.h common/error.h common/io/filter/filter.h common/io/filter/group.h common/io/read.h common/io/write.h common/lock.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h config/config.auto.h config/config.h config/define.auto.h config/define.h storage/fileRead.h storage/fileWrite.h storage/helper.h storage/info.h storage/storage.h
|
||||
$(CC) $(CFLAGS) -c command/control/control.c -o command/control/control.o
|
||||
|
||||
command/help/help.o: command/help/help.c common/assert.h common/debug.h common/error.auto.h common/error.h common/io/handle.h common/lock.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h config/config.auto.h config/config.h config/define.auto.h config/define.h version.h
|
||||
@ -181,7 +181,7 @@ common/exit.o: common/exit.c command/command.h common/debug.h common/error.auto.
|
||||
common/fork.o: common/fork.c common/debug.h common/error.auto.h common/error.h common/log.h common/logLevel.h common/stackTrace.h common/type/convert.h
|
||||
$(CC) $(CFLAGS) -c common/fork.c -o common/fork.o
|
||||
|
||||
common/ini.o: common/ini.c common/debug.h common/error.auto.h common/error.h common/ini.h common/io/filter/filter.h common/io/filter/group.h common/io/read.h common/io/write.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h storage/driver/posix/fileRead.h storage/driver/posix/fileWrite.h storage/fileRead.h storage/fileWrite.h storage/helper.h storage/info.h storage/storage.h version.h
|
||||
common/ini.o: common/ini.c common/debug.h common/error.auto.h common/error.h common/ini.h common/io/filter/filter.h common/io/filter/group.h common/io/read.h common/io/write.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h storage/fileRead.h storage/fileWrite.h storage/helper.h storage/info.h storage/storage.h
|
||||
$(CC) $(CFLAGS) -c common/ini.c -o common/ini.o
|
||||
|
||||
common/io/bufferRead.o: common/io/bufferRead.c common/assert.h common/debug.h common/error.auto.h common/error.h common/io/bufferRead.h common/io/filter/filter.h common/io/filter/group.h common/io/read.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/variant.h common/type/variantList.h
|
||||
@ -214,7 +214,7 @@ common/io/read.o: common/io/read.c common/debug.h common/error.auto.h common/err
|
||||
common/io/write.o: common/io/write.c common/debug.h common/error.auto.h common/error.h common/io/filter/filter.h common/io/filter/group.h common/io/io.h common/io/write.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/variant.h common/type/variantList.h
|
||||
$(CC) $(CFLAGS) -c common/io/write.c -o common/io/write.o
|
||||
|
||||
common/lock.o: common/lock.c common/assert.h common/debug.h common/error.auto.h common/error.h common/io/filter/filter.h common/io/filter/group.h common/io/handle.h common/io/read.h common/io/write.h common/lock.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h common/wait.h storage/driver/posix/fileRead.h storage/driver/posix/fileWrite.h storage/fileRead.h storage/fileWrite.h storage/helper.h storage/info.h storage/storage.h version.h
|
||||
common/lock.o: common/lock.c common/assert.h common/debug.h common/error.auto.h common/error.h common/io/filter/filter.h common/io/filter/group.h common/io/handle.h common/io/read.h common/io/write.h common/lock.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h common/wait.h storage/fileRead.h storage/fileWrite.h storage/helper.h storage/info.h storage/storage.h storage/storage.intern.h version.h
|
||||
$(CC) $(CFLAGS) -c common/lock.c -o common/lock.o
|
||||
|
||||
common/log.o: common/log.c common/assert.h common/debug.h common/error.auto.h common/error.h common/log.h common/logLevel.h common/stackTrace.h common/time.h common/type/convert.h
|
||||
@ -280,7 +280,7 @@ config/define.o: config/define.c common/assert.h common/debug.h common/error.aut
|
||||
config/load.o: config/load.c command/command.h common/debug.h common/error.auto.h common/error.h common/io/io.h common/lock.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h config/config.auto.h config/config.h config/define.auto.h config/define.h config/load.h config/parse.h
|
||||
$(CC) $(CFLAGS) -c config/load.c -o config/load.o
|
||||
|
||||
config/parse.o: config/parse.c common/assert.h common/debug.h common/error.auto.h common/error.h common/ini.h common/io/filter/filter.h common/io/filter/group.h common/io/read.h common/io/write.h common/lock.h common/log.h common/logLevel.h common/memContext.h common/regExp.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h config/config.auto.h config/config.h config/define.auto.h config/define.h config/parse.auto.c config/parse.h storage/driver/posix/fileRead.h storage/driver/posix/fileWrite.h storage/fileRead.h storage/fileWrite.h storage/helper.h storage/info.h storage/storage.h version.h
|
||||
config/parse.o: config/parse.c common/assert.h common/debug.h common/error.auto.h common/error.h common/ini.h common/io/filter/filter.h common/io/filter/group.h common/io/read.h common/io/write.h common/lock.h common/log.h common/logLevel.h common/memContext.h common/regExp.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h config/config.auto.h config/config.h config/define.auto.h config/define.h config/parse.auto.c config/parse.h storage/fileRead.h storage/fileWrite.h storage/helper.h storage/info.h storage/storage.h version.h
|
||||
$(CC) $(CFLAGS) -c config/parse.c -o config/parse.o
|
||||
|
||||
crypto/cipherBlock.o: crypto/cipherBlock.c common/debug.h common/error.auto.h common/error.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/convert.h crypto/cipher.h crypto/cipherBlock.h crypto/crypto.h crypto/random.h
|
||||
@ -295,13 +295,13 @@ crypto/hash.o: crypto/hash.c common/debug.h common/error.auto.h common/error.h c
|
||||
crypto/random.o: crypto/random.c common/debug.h common/error.auto.h common/error.h common/log.h common/logLevel.h common/stackTrace.h common/type/convert.h crypto/random.h
|
||||
$(CC) $(CFLAGS) -c crypto/random.c -o crypto/random.o
|
||||
|
||||
info/info.o: info/info.c common/debug.h common/error.auto.h common/error.h common/ini.h common/io/filter/filter.h common/io/filter/group.h common/io/read.h common/io/write.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h crypto/hash.h info/info.h storage/driver/posix/fileRead.h storage/driver/posix/fileWrite.h storage/fileRead.h storage/fileWrite.h storage/helper.h storage/info.h storage/storage.h version.h
|
||||
info/info.o: info/info.c common/debug.h common/error.auto.h common/error.h common/ini.h common/io/filter/filter.h common/io/filter/group.h common/io/read.h common/io/write.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h crypto/hash.h info/info.h storage/fileRead.h storage/fileWrite.h storage/helper.h storage/info.h storage/storage.h version.h
|
||||
$(CC) $(CFLAGS) -c info/info.c -o info/info.o
|
||||
|
||||
info/infoArchive.o: info/infoArchive.c common/debug.h common/error.auto.h common/error.h common/ini.h common/io/filter/filter.h common/io/filter/group.h common/io/read.h common/io/write.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h info/infoArchive.h info/infoPg.h storage/driver/posix/fileRead.h storage/driver/posix/fileWrite.h storage/fileRead.h storage/fileWrite.h storage/helper.h storage/info.h storage/storage.h version.h
|
||||
info/infoArchive.o: info/infoArchive.c common/debug.h common/error.auto.h common/error.h common/ini.h common/io/filter/filter.h common/io/filter/group.h common/io/read.h common/io/write.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h info/infoArchive.h info/infoPg.h storage/fileRead.h storage/fileWrite.h storage/helper.h storage/info.h storage/storage.h
|
||||
$(CC) $(CFLAGS) -c info/infoArchive.c -o info/infoArchive.o
|
||||
|
||||
info/infoPg.o: info/infoPg.c common/assert.h common/debug.h common/error.auto.h common/error.h common/ini.h common/io/filter/filter.h common/io/filter/group.h common/io/read.h common/io/write.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/json.h common/type/keyValue.h common/type/list.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h crypto/hash.h info/info.h info/infoPg.h postgres/info.h postgres/version.h storage/driver/posix/fileRead.h storage/driver/posix/fileWrite.h storage/fileRead.h storage/fileWrite.h storage/helper.h storage/info.h storage/storage.h version.h
|
||||
info/infoPg.o: info/infoPg.c common/assert.h common/debug.h common/error.auto.h common/error.h common/ini.h common/io/filter/filter.h common/io/filter/group.h common/io/read.h common/io/write.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/json.h common/type/keyValue.h common/type/list.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h crypto/hash.h info/info.h info/infoPg.h postgres/info.h postgres/version.h storage/fileRead.h storage/fileWrite.h storage/helper.h storage/info.h storage/storage.h
|
||||
$(CC) $(CFLAGS) -c info/infoPg.c -o info/infoPg.o
|
||||
|
||||
main.o: main.c command/archive/get/get.h command/archive/push/push.h command/command.h command/help/help.h common/debug.h common/error.auto.h common/error.h common/exit.h common/lock.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h config/config.auto.h config/config.h config/define.auto.h config/define.h config/load.h perl/exec.h version.h
|
||||
@ -310,38 +310,38 @@ main.o: main.c command/archive/get/get.h command/archive/push/push.h command/com
|
||||
perl/config.o: perl/config.c common/debug.h common/error.auto.h common/error.h common/lock.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h config/config.auto.h config/config.h config/define.auto.h config/define.h
|
||||
$(CC) $(CFLAGS) -c perl/config.c -o perl/config.o
|
||||
|
||||
perl/exec.o: perl/exec.c ../libc/LibC.h common/debug.h common/encode.h common/error.auto.h common/error.h common/io/filter/filter.h common/lock.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h config/config.auto.h config/config.h config/define.auto.h config/define.h config/load.h config/parse.h crypto/cipher.h crypto/cipherBlock.h crypto/hash.h crypto/random.h perl/config.h perl/embed.auto.c perl/exec.h perl/libc.auto.c postgres/pageChecksum.h storage/driver/posix/fileRead.h storage/driver/posix/fileWrite.h storage/driver/posix/storage.h storage/info.h version.h ../libc/xs/common/encode.xsh ../libc/xs/crypto/cipherBlock.xsh ../libc/xs/crypto/hash.xsh
|
||||
perl/exec.o: perl/exec.c ../libc/LibC.h common/debug.h common/encode.h common/error.auto.h common/error.h common/io/filter/filter.h common/io/filter/group.h common/io/read.h common/io/write.h common/lock.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h config/config.auto.h config/config.h config/define.auto.h config/define.h config/load.h config/parse.h crypto/cipher.h crypto/cipherBlock.h crypto/hash.h crypto/random.h perl/config.h perl/embed.auto.c perl/exec.h perl/libc.auto.c postgres/pageChecksum.h storage/driver/posix/fileRead.h storage/driver/posix/fileWrite.h storage/driver/posix/storage.h storage/fileRead.h storage/fileWrite.h storage/info.h storage/storage.h storage/storage.intern.h version.h ../libc/xs/common/encode.xsh ../libc/xs/crypto/cipherBlock.xsh ../libc/xs/crypto/hash.xsh
|
||||
$(CC) $(CFLAGS) -c perl/exec.c -o perl/exec.o
|
||||
|
||||
postgres/info.o: postgres/info.c common/debug.h common/error.auto.h common/error.h common/io/filter/filter.h common/io/filter/group.h common/io/read.h common/io/write.h common/log.h common/logLevel.h common/memContext.h common/regExp.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h postgres/info.h postgres/type.h postgres/version.h storage/driver/posix/fileRead.h storage/driver/posix/fileWrite.h storage/fileRead.h storage/fileWrite.h storage/helper.h storage/info.h storage/storage.h version.h
|
||||
postgres/info.o: postgres/info.c common/debug.h common/error.auto.h common/error.h common/io/filter/filter.h common/io/filter/group.h common/io/read.h common/io/write.h common/log.h common/logLevel.h common/memContext.h common/regExp.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h postgres/info.h postgres/type.h postgres/version.h storage/fileRead.h storage/fileWrite.h storage/helper.h storage/info.h storage/storage.h
|
||||
$(CC) $(CFLAGS) -c postgres/info.c -o postgres/info.o
|
||||
|
||||
postgres/pageChecksum.o: postgres/pageChecksum.c common/assert.h common/debug.h common/error.auto.h common/error.h common/log.h common/logLevel.h common/stackTrace.h common/type/convert.h postgres/pageChecksum.h postgres/type.h
|
||||
$(CC) $(CFLAGS) -funroll-loops -ftree-vectorize -c postgres/pageChecksum.c -o postgres/pageChecksum.o
|
||||
|
||||
protocol/storage/helper.o: protocol/storage/helper.c common/debug.h common/error.auto.h common/error.h common/io/filter/filter.h common/io/filter/group.h common/io/read.h common/io/write.h common/lock.h common/log.h common/logLevel.h common/memContext.h common/regExp.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h config/config.auto.h config/config.h config/define.auto.h config/define.h protocol/storage/helper.h storage/driver/posix/fileRead.h storage/driver/posix/fileWrite.h storage/fileRead.h storage/fileWrite.h storage/info.h storage/storage.h version.h
|
||||
protocol/storage/helper.o: protocol/storage/helper.c common/debug.h common/error.auto.h common/error.h common/io/filter/filter.h common/io/filter/group.h common/io/read.h common/io/write.h common/lock.h common/log.h common/logLevel.h common/memContext.h common/regExp.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h config/config.auto.h config/config.h config/define.auto.h config/define.h protocol/storage/helper.h storage/driver/posix/fileRead.h storage/driver/posix/fileWrite.h storage/driver/posix/storage.h storage/fileRead.h storage/fileWrite.h storage/info.h storage/storage.h storage/storage.intern.h
|
||||
$(CC) $(CFLAGS) -c protocol/storage/helper.c -o protocol/storage/helper.o
|
||||
|
||||
storage/driver/posix/common.o: storage/driver/posix/common.c common/assert.h common/debug.h common/error.auto.h common/error.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/string.h storage/driver/posix/common.h
|
||||
$(CC) $(CFLAGS) -c storage/driver/posix/common.c -o storage/driver/posix/common.o
|
||||
|
||||
storage/driver/posix/fileRead.o: storage/driver/posix/fileRead.c common/assert.h common/debug.h common/error.auto.h common/error.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/string.h storage/driver/posix/common.h storage/driver/posix/fileRead.h
|
||||
storage/driver/posix/fileRead.o: storage/driver/posix/fileRead.c common/assert.h common/debug.h common/error.auto.h common/error.h common/io/filter/filter.h common/io/filter/group.h common/io/read.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/variant.h common/type/variantList.h storage/driver/posix/common.h storage/driver/posix/fileRead.h storage/driver/posix/storage.h storage/fileRead.h storage/fileRead.intern.h
|
||||
$(CC) $(CFLAGS) -c storage/driver/posix/fileRead.c -o storage/driver/posix/fileRead.o
|
||||
|
||||
storage/driver/posix/fileWrite.o: storage/driver/posix/fileWrite.c common/assert.h common/debug.h common/error.auto.h common/error.h common/io/filter/filter.h common/io/filter/group.h common/io/write.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h storage/driver/posix/common.h storage/driver/posix/fileRead.h storage/driver/posix/fileWrite.h storage/driver/posix/storage.h storage/fileWrite.h storage/info.h version.h
|
||||
storage/driver/posix/fileWrite.o: storage/driver/posix/fileWrite.c common/assert.h common/debug.h common/error.auto.h common/error.h common/io/filter/filter.h common/io/filter/group.h common/io/write.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/variant.h common/type/variantList.h storage/driver/posix/common.h storage/driver/posix/fileWrite.h storage/driver/posix/storage.h storage/fileWrite.h storage/fileWrite.intern.h version.h
|
||||
$(CC) $(CFLAGS) -c storage/driver/posix/fileWrite.c -o storage/driver/posix/fileWrite.o
|
||||
|
||||
storage/driver/posix/storage.o: storage/driver/posix/storage.c common/debug.h common/error.auto.h common/error.h common/io/filter/filter.h common/io/filter/group.h common/io/read.h common/io/write.h common/log.h common/logLevel.h common/memContext.h common/regExp.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h storage/driver/posix/common.h storage/driver/posix/fileRead.h storage/driver/posix/fileWrite.h storage/driver/posix/storage.h storage/fileRead.h storage/fileWrite.h storage/info.h storage/storage.h version.h
|
||||
storage/driver/posix/storage.o: storage/driver/posix/storage.c common/debug.h common/error.auto.h common/error.h common/io/filter/filter.h common/io/filter/group.h common/io/read.h common/io/write.h common/log.h common/logLevel.h common/memContext.h common/regExp.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h storage/driver/posix/common.h storage/driver/posix/fileRead.h storage/driver/posix/fileWrite.h storage/driver/posix/storage.h storage/fileRead.h storage/fileWrite.h storage/info.h storage/storage.h storage/storage.intern.h
|
||||
$(CC) $(CFLAGS) -c storage/driver/posix/storage.c -o storage/driver/posix/storage.o
|
||||
|
||||
storage/fileRead.o: storage/fileRead.c common/assert.h common/debug.h common/error.auto.h common/error.h common/io/filter/filter.h common/io/filter/group.h common/io/read.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/variant.h common/type/variantList.h storage/driver/posix/fileRead.h storage/fileRead.h
|
||||
storage/fileRead.o: storage/fileRead.c common/assert.h common/debug.h common/error.auto.h common/error.h common/io/filter/filter.h common/io/filter/group.h common/io/read.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/variant.h common/type/variantList.h storage/fileRead.h storage/fileRead.intern.h
|
||||
$(CC) $(CFLAGS) -c storage/fileRead.c -o storage/fileRead.o
|
||||
|
||||
storage/fileWrite.o: storage/fileWrite.c common/assert.h common/debug.h common/error.auto.h common/error.h common/io/filter/filter.h common/io/filter/group.h common/io/write.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/variant.h common/type/variantList.h storage/driver/posix/fileWrite.h storage/fileWrite.h version.h
|
||||
storage/fileWrite.o: storage/fileWrite.c common/assert.h common/debug.h common/error.auto.h common/error.h common/io/filter/filter.h common/io/filter/group.h common/io/write.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/variant.h common/type/variantList.h storage/fileWrite.h storage/fileWrite.intern.h version.h
|
||||
$(CC) $(CFLAGS) -c storage/fileWrite.c -o storage/fileWrite.o
|
||||
|
||||
storage/helper.o: storage/helper.c common/debug.h common/error.auto.h common/error.h common/io/filter/filter.h common/io/filter/group.h common/io/read.h common/io/write.h common/lock.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h config/config.auto.h config/config.h config/define.auto.h config/define.h storage/driver/posix/fileRead.h storage/driver/posix/fileWrite.h storage/fileRead.h storage/fileWrite.h storage/helper.h storage/info.h storage/storage.h version.h
|
||||
storage/helper.o: storage/helper.c common/debug.h common/error.auto.h common/error.h common/io/filter/filter.h common/io/filter/group.h common/io/read.h common/io/write.h common/lock.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h config/config.auto.h config/config.h config/define.auto.h config/define.h storage/driver/posix/fileRead.h storage/driver/posix/fileWrite.h storage/driver/posix/storage.h storage/fileRead.h storage/fileWrite.h storage/helper.h storage/info.h storage/storage.h storage/storage.intern.h
|
||||
$(CC) $(CFLAGS) -c storage/helper.c -o storage/helper.o
|
||||
|
||||
storage/storage.o: storage/storage.c common/assert.h common/debug.h common/error.auto.h common/error.h common/io/filter/filter.h common/io/filter/group.h common/io/io.h common/io/read.h common/io/write.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h common/wait.h storage/driver/posix/fileRead.h storage/driver/posix/fileWrite.h storage/driver/posix/storage.h storage/fileRead.h storage/fileWrite.h storage/info.h storage/storage.h version.h
|
||||
storage/storage.o: storage/storage.c common/assert.h common/debug.h common/error.auto.h common/error.h common/io/filter/filter.h common/io/filter/group.h common/io/io.h common/io/read.h common/io/write.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h common/wait.h storage/fileRead.h storage/fileWrite.h storage/info.h storage/storage.h storage/storage.intern.h
|
||||
$(CC) $(CFLAGS) -c storage/storage.c -o storage/storage.o
|
||||
|
@ -176,7 +176,7 @@ cmdArchiveGet(void)
|
||||
.noAtomic = true);
|
||||
|
||||
// Move (or copy if required) the file
|
||||
storageMoveNP(source, destination);
|
||||
storageMoveNP(storageSpool(), source, destination);
|
||||
|
||||
// Return success
|
||||
result = 0;
|
||||
|
@ -200,6 +200,11 @@ size_t strzToLog(const char *string, char *buffer, size_t bufferSize);
|
||||
#define FUNCTION_DEBUG_VOIDP_FORMAT(value, buffer, bufferSize) \
|
||||
ptrToLog(value, "void *", buffer, bufferSize)
|
||||
|
||||
#define FUNCTION_DEBUG_CONST_VOIDP_TYPE \
|
||||
const void *
|
||||
#define FUNCTION_DEBUG_CONST_VOIDP_FORMAT(value, buffer, bufferSize) \
|
||||
FUNCTION_DEBUG_VOIDP_FORMAT(value, buffer, bufferSize)
|
||||
|
||||
#define FUNCTION_DEBUG_VOIDPP_TYPE \
|
||||
void **
|
||||
#define FUNCTION_DEBUG_VOIDPP_FORMAT(value, buffer, bufferSize) \
|
||||
|
@ -15,6 +15,7 @@ Lock Handler
|
||||
#include "common/memContext.h"
|
||||
#include "common/wait.h"
|
||||
#include "storage/helper.h"
|
||||
#include "storage/storage.intern.h"
|
||||
#include "version.h"
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
|
@ -287,7 +287,7 @@ XS_EUPXS(XS_pgBackRest__LibC_storageDriverPosixPathRemove)
|
||||
;
|
||||
MEM_CONTEXT_XS_TEMP_BEGIN()
|
||||
{
|
||||
storageDriverPosixPathRemove(strNew(path), errorOnMissing, recurse);
|
||||
storageDriverPosixPathRemove(storageDriverPosixNew(strNew("/"), 0640, 750, true, NULL), strNew(path), errorOnMissing, recurse);
|
||||
}
|
||||
MEM_CONTEXT_XS_TEMP_END();
|
||||
}
|
||||
|
@ -8,6 +8,8 @@ Protocol Storage Helper
|
||||
#include "common/regExp.h"
|
||||
#include "config/config.h"
|
||||
#include "protocol/storage/helper.h"
|
||||
#include "storage/driver/posix/storage.h"
|
||||
#include "storage/storage.intern.h"
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Local variables
|
||||
@ -92,8 +94,10 @@ storageRepo(void)
|
||||
{
|
||||
protocolStorageHelper.stanza = strDup(cfgOptionStr(cfgOptStanza));
|
||||
protocolStorageHelper.walRegExp = regExpNew(strNew("^[0-F]{24}"));
|
||||
protocolStorageHelper.storageRepo = storageNewP(
|
||||
cfgOptionStr(cfgOptRepoPath), .pathExpressionFunction = storageRepoPathExpression);
|
||||
protocolStorageHelper.storageRepo = storageDriverPosixInterface(
|
||||
storageDriverPosixNew(
|
||||
cfgOptionStr(cfgOptRepoPath), STORAGE_MODE_FILE_DEFAULT, STORAGE_MODE_PATH_DEFAULT, false,
|
||||
storageRepoPathExpression));
|
||||
}
|
||||
MEM_CONTEXT_END();
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ Posix Storage File Read Driver
|
||||
#include "common/memContext.h"
|
||||
#include "storage/driver/posix/common.h"
|
||||
#include "storage/driver/posix/fileRead.h"
|
||||
#include "storage/fileRead.intern.h"
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Object type
|
||||
@ -17,7 +18,9 @@ Object type
|
||||
struct StorageDriverPosixFileRead
|
||||
{
|
||||
MemContext *memContext;
|
||||
|
||||
const StorageDriverPosix *storage;
|
||||
StorageFileRead *interface;
|
||||
IoRead *io;
|
||||
String *name;
|
||||
bool ignoreMissing;
|
||||
|
||||
@ -25,11 +28,21 @@ struct StorageDriverPosixFileRead
|
||||
bool eof;
|
||||
};
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Interface definition
|
||||
***********************************************************************************************************************************/
|
||||
static const StorageFileReadInterface storageFileReadInterface =
|
||||
{
|
||||
.ignoreMissing = (StorageFileReadIgnoreMissing)storageDriverPosixFileReadIgnoreMissing,
|
||||
.io = (StorageFileReadIo)storageDriverPosixFileReadIo,
|
||||
.name = (StorageFileReadName)storageDriverPosixFileReadName,
|
||||
};
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Create a new file
|
||||
***********************************************************************************************************************************/
|
||||
StorageDriverPosixFileRead *
|
||||
storageDriverPosixFileReadNew(const String *name, bool ignoreMissing)
|
||||
storageDriverPosixFileReadNew(const StorageDriverPosix *storage, const String *name, bool ignoreMissing)
|
||||
{
|
||||
FUNCTION_DEBUG_BEGIN(logLevelTrace);
|
||||
FUNCTION_DEBUG_PARAM(STRING, name);
|
||||
@ -45,10 +58,16 @@ storageDriverPosixFileReadNew(const String *name, bool ignoreMissing)
|
||||
{
|
||||
this = memNew(sizeof(StorageDriverPosixFileRead));
|
||||
this->memContext = MEM_CONTEXT_NEW();
|
||||
this->storage = storage;
|
||||
this->name = strDup(name);
|
||||
this->ignoreMissing = ignoreMissing;
|
||||
|
||||
this->handle = -1;
|
||||
|
||||
this->interface = storageFileReadNew(strNew(STORAGE_DRIVER_POSIX_TYPE), this, &storageFileReadInterface);
|
||||
this->io = ioReadNew(
|
||||
this, (IoReadOpen)storageDriverPosixFileReadOpen, (IoReadProcess)storageDriverPosixFileRead,
|
||||
(IoReadClose)storageDriverPosixFileReadClose, (IoReadEof)storageDriverPosixFileReadEof);
|
||||
}
|
||||
MEM_CONTEXT_NEW_END();
|
||||
|
||||
@ -176,6 +195,36 @@ storageDriverPosixFileReadIgnoreMissing(const StorageDriverPosixFileRead *this)
|
||||
FUNCTION_TEST_RESULT(BOOL, this->ignoreMissing);
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Get the interface
|
||||
***********************************************************************************************************************************/
|
||||
StorageFileRead *
|
||||
storageDriverPosixFileReadInterface(const StorageDriverPosixFileRead *this)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(STORAGE_DRIVER_POSIX_FILE_READ, this);
|
||||
|
||||
FUNCTION_TEST_ASSERT(this != NULL);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
FUNCTION_TEST_RESULT(STORAGE_FILE_READ, this->interface);
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Get the I/O interface
|
||||
***********************************************************************************************************************************/
|
||||
IoRead *
|
||||
storageDriverPosixFileReadIo(const StorageDriverPosixFileRead *this)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(STORAGE_DRIVER_POSIX_FILE_READ, this);
|
||||
|
||||
FUNCTION_TEST_ASSERT(this != NULL);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
FUNCTION_TEST_RESULT(IO_READ, this->io);
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
File name
|
||||
***********************************************************************************************************************************/
|
||||
|
@ -5,17 +5,19 @@ Posix Storage File Read Driver
|
||||
#define STORAGE_DRIVER_POSIX_FILEREAD_H
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Read file object
|
||||
Object type
|
||||
***********************************************************************************************************************************/
|
||||
typedef struct StorageDriverPosixFileRead StorageDriverPosixFileRead;
|
||||
|
||||
#include "common/type/buffer.h"
|
||||
#include "common/type/string.h"
|
||||
#include "storage/driver/posix/storage.h"
|
||||
#include "storage/fileRead.h"
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Constructor
|
||||
***********************************************************************************************************************************/
|
||||
StorageDriverPosixFileRead *storageDriverPosixFileReadNew(const String *name, bool ignoreMissing);
|
||||
StorageDriverPosixFileRead *storageDriverPosixFileReadNew(const StorageDriverPosix *storage, const String *name, bool ignoreMissing);
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Functions
|
||||
@ -29,6 +31,8 @@ Getters
|
||||
***********************************************************************************************************************************/
|
||||
bool storageDriverPosixFileReadEof(const StorageDriverPosixFileRead *this);
|
||||
bool storageDriverPosixFileReadIgnoreMissing(const StorageDriverPosixFileRead *this);
|
||||
StorageFileRead *storageDriverPosixFileReadInterface(const StorageDriverPosixFileRead *this);
|
||||
IoRead *storageDriverPosixFileReadIo(const StorageDriverPosixFileRead *this);
|
||||
const String *storageDriverPosixFileReadName(const StorageDriverPosixFileRead *this);
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
|
@ -11,8 +11,7 @@ Posix Storage File Write Driver
|
||||
#include "common/memContext.h"
|
||||
#include "storage/driver/posix/common.h"
|
||||
#include "storage/driver/posix/fileWrite.h"
|
||||
#include "storage/driver/posix/storage.h"
|
||||
#include "storage/fileWrite.h"
|
||||
#include "storage/fileWrite.intern.h"
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Object type
|
||||
@ -20,6 +19,9 @@ Object type
|
||||
struct StorageDriverPosixFileWrite
|
||||
{
|
||||
MemContext *memContext;
|
||||
const StorageDriverPosix *storage;
|
||||
StorageFileWrite *interface;
|
||||
IoWrite *io;
|
||||
|
||||
String *path;
|
||||
String *name;
|
||||
@ -34,6 +36,21 @@ struct StorageDriverPosixFileWrite
|
||||
int handle;
|
||||
};
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Interface definition
|
||||
***********************************************************************************************************************************/
|
||||
static const StorageFileWriteInterface storageFileWriteInterface =
|
||||
{
|
||||
.atomic = (StorageFileWriteAtomic)storageDriverPosixFileWriteAtomic,
|
||||
.createPath = (StorageFileWriteCreatePath)storageDriverPosixFileWriteCreatePath,
|
||||
.io = (StorageFileWriteIo)storageDriverPosixFileWriteIo,
|
||||
.modeFile = (StorageFileWriteModeFile)storageDriverPosixFileWriteModeFile,
|
||||
.modePath = (StorageFileWriteModePath)storageDriverPosixFileWriteModePath,
|
||||
.name = (StorageFileWriteName)storageDriverPosixFileWriteName,
|
||||
.syncFile = (StorageFileWriteSyncFile)storageDriverPosixFileWriteSyncFile,
|
||||
.syncPath = (StorageFileWriteSyncPath)storageDriverPosixFileWriteSyncPath,
|
||||
};
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
File open constants
|
||||
|
||||
@ -47,7 +64,8 @@ Create a new file
|
||||
***********************************************************************************************************************************/
|
||||
StorageDriverPosixFileWrite *
|
||||
storageDriverPosixFileWriteNew(
|
||||
const String *name, mode_t modeFile, mode_t modePath, bool createPath, bool syncFile, bool syncPath, bool atomic)
|
||||
const StorageDriverPosix *storage, const String *name, mode_t modeFile, mode_t modePath, bool createPath, bool syncFile,
|
||||
bool syncPath, bool atomic)
|
||||
{
|
||||
FUNCTION_DEBUG_BEGIN(logLevelTrace);
|
||||
FUNCTION_DEBUG_PARAM(STRING, name);
|
||||
@ -59,17 +77,24 @@ storageDriverPosixFileWriteNew(
|
||||
FUNCTION_DEBUG_PARAM(BOOL, atomic);
|
||||
|
||||
FUNCTION_TEST_ASSERT(name != NULL);
|
||||
FUNCTION_TEST_ASSERT(modeFile != 0);
|
||||
FUNCTION_TEST_ASSERT(modePath != 0);
|
||||
FUNCTION_DEBUG_END();
|
||||
|
||||
StorageDriverPosixFileWrite *this = NULL;
|
||||
|
||||
ASSERT_DEBUG(name != NULL);
|
||||
|
||||
// Create the file
|
||||
MEM_CONTEXT_NEW_BEGIN("StorageDriverPosixFileWrite")
|
||||
{
|
||||
this = memNew(sizeof(StorageDriverPosixFileWrite));
|
||||
this->memContext = MEM_CONTEXT_NEW();
|
||||
|
||||
this->storage = storage;
|
||||
this->interface = storageFileWriteNew(strNew(STORAGE_DRIVER_POSIX_TYPE), this, &storageFileWriteInterface);
|
||||
this->io = ioWriteNew(
|
||||
this, (IoWriteOpen)storageDriverPosixFileWriteOpen, (IoWriteProcess)storageDriverPosixFileWrite,
|
||||
(IoWriteClose)storageDriverPosixFileWriteClose);
|
||||
|
||||
this->path = strPath(name);
|
||||
this->name = strDup(name);
|
||||
this->nameTmp = atomic ? strNewFmt("%s." STORAGE_FILE_TEMP_EXT, strPtr(name)) : this->name;
|
||||
@ -108,7 +133,7 @@ storageDriverPosixFileWriteOpen(StorageDriverPosixFileWrite *this)
|
||||
if (this->handle == -1)
|
||||
{
|
||||
// Create the path
|
||||
storageDriverPosixPathCreate(this->path, false, false, this->modePath);
|
||||
storageDriverPosixPathCreate(this->storage, this->path, false, false, this->modePath);
|
||||
|
||||
// Try the open again
|
||||
this->handle = storageDriverPosixFileOpen(
|
||||
@ -174,7 +199,7 @@ storageDriverPosixFileWriteClose(StorageDriverPosixFileWrite *this)
|
||||
|
||||
// Sync the path
|
||||
if (this->syncPath)
|
||||
storageDriverPosixPathSync(this->path, false);
|
||||
storageDriverPosixPathSync(this->storage, this->path, false);
|
||||
|
||||
// This marks the file as closed
|
||||
this->handle = -1;
|
||||
@ -215,6 +240,36 @@ storageDriverPosixFileWriteCreatePath(const StorageDriverPosixFileWrite *this)
|
||||
FUNCTION_TEST_RESULT(BOOL, this->createPath);
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Get interface
|
||||
***********************************************************************************************************************************/
|
||||
StorageFileWrite *
|
||||
storageDriverPosixFileWriteInterface(const StorageDriverPosixFileWrite *this)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(STORAGE_DRIVER_POSIX_FILE_WRITE, this);
|
||||
|
||||
FUNCTION_TEST_ASSERT(this != NULL);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
FUNCTION_TEST_RESULT(STORAGE_FILE_WRITE, this->interface);
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Get I/O interface
|
||||
***********************************************************************************************************************************/
|
||||
IoWrite *
|
||||
storageDriverPosixFileWriteIo(const StorageDriverPosixFileWrite *this)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(STORAGE_DRIVER_POSIX_FILE_WRITE, this);
|
||||
|
||||
FUNCTION_TEST_ASSERT(this != NULL);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
FUNCTION_TEST_RESULT(IO_WRITE, this->io);
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Mode for the file to be created
|
||||
***********************************************************************************************************************************/
|
||||
@ -260,21 +315,6 @@ storageDriverPosixFileWriteName(const StorageDriverPosixFileWrite *this)
|
||||
FUNCTION_TEST_RESULT(CONST_STRING, this->name);
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
File path
|
||||
***********************************************************************************************************************************/
|
||||
const String *
|
||||
storageDriverPosixFileWritePath(const StorageDriverPosixFileWrite *this)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(STORAGE_DRIVER_POSIX_FILE_WRITE, this);
|
||||
|
||||
FUNCTION_TEST_ASSERT(this != NULL);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
FUNCTION_TEST_RESULT(CONST_STRING, this->path);
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Will the file be synced after it is closed?
|
||||
***********************************************************************************************************************************/
|
||||
|
@ -7,18 +7,20 @@ Posix Storage File Write Driver
|
||||
#include <sys/types.h>
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Write file object
|
||||
Object type
|
||||
***********************************************************************************************************************************/
|
||||
typedef struct StorageDriverPosixFileWrite StorageDriverPosixFileWrite;
|
||||
|
||||
#include "common/type/buffer.h"
|
||||
#include "common/type/string.h"
|
||||
#include "storage/driver/posix/storage.h"
|
||||
#include "storage/fileWrite.h"
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Constructor
|
||||
***********************************************************************************************************************************/
|
||||
StorageDriverPosixFileWrite *storageDriverPosixFileWriteNew(
|
||||
const String *name, mode_t modeFile, mode_t modePath, bool createPath, bool syncFile, bool syncPath, bool atomic);
|
||||
const StorageDriverPosix *storage, const String *name, mode_t modeFile, mode_t modePath, bool createPath, bool syncFile,
|
||||
bool syncPath, bool atomic);
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Functions
|
||||
@ -33,9 +35,11 @@ Getters
|
||||
bool storageDriverPosixFileWriteAtomic(const StorageDriverPosixFileWrite *this);
|
||||
bool storageDriverPosixFileWriteCreatePath(const StorageDriverPosixFileWrite *this);
|
||||
mode_t storageDriverPosixFileWriteModeFile(const StorageDriverPosixFileWrite *this);
|
||||
StorageFileWrite* storageDriverPosixFileWriteInterface(const StorageDriverPosixFileWrite *this);
|
||||
IoWrite *storageDriverPosixFileWriteIo(const StorageDriverPosixFileWrite *this);
|
||||
mode_t storageDriverPosixFileWriteModePath(const StorageDriverPosixFileWrite *this);
|
||||
const String *storageDriverPosixFileWriteName(const StorageDriverPosixFileWrite *this);
|
||||
const String *storageDriverPosixFileWritePath(const StorageDriverPosixFileWrite *this);
|
||||
const StorageDriverPosix *storageDriverPosixFileWriteStorage(const StorageDriverPosixFileWrite *this);
|
||||
bool storageDriverPosixFileWriteSyncFile(const StorageDriverPosixFileWrite *this);
|
||||
bool storageDriverPosixFileWriteSyncPath(const StorageDriverPosixFileWrite *this);
|
||||
|
||||
|
@ -19,17 +19,77 @@ Posix Storage Driver
|
||||
#include "common/regExp.h"
|
||||
#include "storage/driver/posix/storage.h"
|
||||
#include "storage/driver/posix/common.h"
|
||||
#include "storage/storage.h"
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Object type
|
||||
***********************************************************************************************************************************/
|
||||
struct StorageDriverPosix
|
||||
{
|
||||
MemContext *memContext; // Object memory context
|
||||
Storage *interface; // Driver interface
|
||||
};
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Interface definition
|
||||
***********************************************************************************************************************************/
|
||||
static const StorageInterface storageInterface =
|
||||
{
|
||||
.exists = (StorageExistsFn)storageDriverPosixExists,
|
||||
.info = (StorageInfoFn)storageDriverPosixInfo,
|
||||
.list = (StorageListFn)storageDriverPosixList,
|
||||
.move = (StorageMoveFn)storageDriverPosixMove,
|
||||
.newRead = (StorageNewReadFn)storageDriverPosixNewRead,
|
||||
.newWrite = (StorageNewWriteFn)storageDriverPosixNewWrite,
|
||||
.pathCreate = (StoragePathCreateFn)storageDriverPosixPathCreate,
|
||||
.pathRemove = (StoragePathRemoveFn)storageDriverPosixPathRemove,
|
||||
.pathSync = (StoragePathSyncFn)storageDriverPosixPathSync,
|
||||
.remove = (StorageRemoveFn)storageDriverPosixRemove,
|
||||
};
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
New object
|
||||
***********************************************************************************************************************************/
|
||||
StorageDriverPosix *
|
||||
storageDriverPosixNew(
|
||||
const String *path, mode_t modeFile, mode_t modePath, bool write, StoragePathExpressionCallback pathExpressionFunction)
|
||||
{
|
||||
FUNCTION_DEBUG_BEGIN(logLevelDebug);
|
||||
FUNCTION_DEBUG_PARAM(STRING, path);
|
||||
FUNCTION_DEBUG_PARAM(MODE, modeFile);
|
||||
FUNCTION_DEBUG_PARAM(MODE, modePath);
|
||||
FUNCTION_DEBUG_PARAM(BOOL, write);
|
||||
FUNCTION_DEBUG_PARAM(FUNCTIONP, pathExpressionFunction);
|
||||
|
||||
FUNCTION_TEST_ASSERT(path != NULL);
|
||||
FUNCTION_DEBUG_END();
|
||||
|
||||
// Create the file
|
||||
StorageDriverPosix *this = NULL;
|
||||
|
||||
MEM_CONTEXT_NEW_BEGIN("StorageDriverPosix")
|
||||
{
|
||||
this = memNew(sizeof(StorageDriverPosix));
|
||||
this->memContext = MEM_CONTEXT_NEW();
|
||||
|
||||
this->interface = storageNew(
|
||||
strNew(STORAGE_DRIVER_POSIX_TYPE), path, modeFile, modePath, write, pathExpressionFunction, this, &storageInterface);
|
||||
}
|
||||
MEM_CONTEXT_NEW_END();
|
||||
|
||||
FUNCTION_DEBUG_RESULT(STORAGE_DRIVER_POSIX, this);
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Does a file/path exist?
|
||||
***********************************************************************************************************************************/
|
||||
bool
|
||||
storageDriverPosixExists(const String *path)
|
||||
storageDriverPosixExists(const StorageDriverPosix *this, const String *path)
|
||||
{
|
||||
FUNCTION_DEBUG_BEGIN(logLevelTrace);
|
||||
FUNCTION_DEBUG_PARAM(STORAGE_DRIVER_POSIX, this);
|
||||
FUNCTION_DEBUG_PARAM(STRING, path);
|
||||
|
||||
FUNCTION_TEST_ASSERT(this != NULL);
|
||||
FUNCTION_DEBUG_ASSERT(path != NULL);
|
||||
FUNCTION_DEBUG_END();
|
||||
|
||||
@ -55,12 +115,14 @@ storageDriverPosixExists(const String *path)
|
||||
File/path info
|
||||
***********************************************************************************************************************************/
|
||||
StorageInfo
|
||||
storageDriverPosixInfo(const String *file, bool ignoreMissing)
|
||||
storageDriverPosixInfo(const StorageDriverPosix *this, const String *file, bool ignoreMissing)
|
||||
{
|
||||
FUNCTION_DEBUG_BEGIN(logLevelTrace);
|
||||
FUNCTION_DEBUG_PARAM(STORAGE_DRIVER_POSIX, this);
|
||||
FUNCTION_DEBUG_PARAM(STRING, file);
|
||||
FUNCTION_DEBUG_PARAM(BOOL, ignoreMissing);
|
||||
|
||||
FUNCTION_TEST_ASSERT(this != NULL);
|
||||
FUNCTION_DEBUG_ASSERT(file != NULL);
|
||||
FUNCTION_DEBUG_END();
|
||||
|
||||
@ -101,13 +163,15 @@ storageDriverPosixInfo(const String *file, bool ignoreMissing)
|
||||
Get a list of files from a directory
|
||||
***********************************************************************************************************************************/
|
||||
StringList *
|
||||
storageDriverPosixList(const String *path, bool errorOnMissing, const String *expression)
|
||||
storageDriverPosixList(const StorageDriverPosix *this, const String *path, bool errorOnMissing, const String *expression)
|
||||
{
|
||||
FUNCTION_DEBUG_BEGIN(logLevelTrace);
|
||||
FUNCTION_DEBUG_PARAM(STORAGE_DRIVER_POSIX, this);
|
||||
FUNCTION_DEBUG_PARAM(STRING, path);
|
||||
FUNCTION_DEBUG_PARAM(BOOL, errorOnMissing);
|
||||
FUNCTION_DEBUG_PARAM(STRING, expression);
|
||||
|
||||
FUNCTION_TEST_ASSERT(this != NULL);
|
||||
FUNCTION_DEBUG_ASSERT(path != NULL);
|
||||
FUNCTION_DEBUG_END();
|
||||
|
||||
@ -168,15 +232,17 @@ storageDriverPosixList(const String *path, bool errorOnMissing, const String *ex
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Move a file
|
||||
Move a path/file
|
||||
***********************************************************************************************************************************/
|
||||
bool
|
||||
storageDriverPosixMove(StorageDriverPosixFileRead *source, StorageDriverPosixFileWrite *destination)
|
||||
storageDriverPosixMove(const StorageDriverPosix *this, StorageDriverPosixFileRead *source, StorageDriverPosixFileWrite *destination)
|
||||
{
|
||||
FUNCTION_DEBUG_BEGIN(logLevelTrace);
|
||||
FUNCTION_DEBUG_PARAM(STORAGE_DRIVER_POSIX, this);
|
||||
FUNCTION_DEBUG_PARAM(STORAGE_DRIVER_POSIX_FILE_READ, source);
|
||||
FUNCTION_DEBUG_PARAM(STORAGE_DRIVER_POSIX_FILE_WRITE, destination);
|
||||
|
||||
FUNCTION_TEST_ASSERT(this != NULL);
|
||||
FUNCTION_TEST_ASSERT(source != NULL);
|
||||
FUNCTION_TEST_ASSERT(destination != NULL);
|
||||
FUNCTION_DEBUG_END();
|
||||
@ -187,7 +253,7 @@ storageDriverPosixMove(StorageDriverPosixFileRead *source, StorageDriverPosixFil
|
||||
{
|
||||
const String *sourceFile = storageDriverPosixFileReadName(source);
|
||||
const String *destinationFile = storageDriverPosixFileWriteName(destination);
|
||||
const String *destinationPath = storageDriverPosixFileWritePath(destination);
|
||||
const String *destinationPath = strPath(destinationFile);
|
||||
|
||||
// Attempt to move the file
|
||||
if (rename(strPtr(sourceFile), strPtr(destinationFile)) == -1)
|
||||
@ -195,7 +261,7 @@ storageDriverPosixMove(StorageDriverPosixFileRead *source, StorageDriverPosixFil
|
||||
// Detemine which file/path is missing
|
||||
if (errno == ENOENT)
|
||||
{
|
||||
if (!storageDriverPosixExists(sourceFile))
|
||||
if (!storageDriverPosixExists(this, sourceFile))
|
||||
THROW_SYS_ERROR_FMT(FileMissingError, "unable to move missing file '%s'", strPtr(sourceFile));
|
||||
|
||||
if (!storageDriverPosixFileWriteCreatePath(destination))
|
||||
@ -204,8 +270,8 @@ storageDriverPosixMove(StorageDriverPosixFileRead *source, StorageDriverPosixFil
|
||||
PathMissingError, "unable to move '%s' to missing path '%s'", strPtr(sourceFile), strPtr(destinationPath));
|
||||
}
|
||||
|
||||
storageDriverPosixPathCreate(destinationPath, false, false, storageDriverPosixFileWriteModePath(destination));
|
||||
result = storageDriverPosixMove(source, destination);
|
||||
storageDriverPosixPathCreate(this, destinationPath, false, false, storageDriverPosixFileWriteModePath(destination));
|
||||
result = storageDriverPosixMove(this, source, destination);
|
||||
}
|
||||
// Else the destination is on a different device so a copy will be needed
|
||||
else if (errno == EXDEV)
|
||||
@ -224,7 +290,7 @@ storageDriverPosixMove(StorageDriverPosixFileRead *source, StorageDriverPosixFil
|
||||
String *sourcePath = strPath(sourceFile);
|
||||
|
||||
if (!strEq(destinationPath, sourcePath))
|
||||
storageDriverPosixPathSync(sourcePath, false);
|
||||
storageDriverPosixPathSync(this, sourcePath, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -233,18 +299,67 @@ storageDriverPosixMove(StorageDriverPosixFileRead *source, StorageDriverPosixFil
|
||||
FUNCTION_DEBUG_RESULT(BOOL, result);
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
New file read object
|
||||
***********************************************************************************************************************************/
|
||||
StorageFileRead *
|
||||
storageDriverPosixNewRead(const StorageDriverPosix *this, const String *file, bool ignoreMissing)
|
||||
{
|
||||
FUNCTION_DEBUG_BEGIN(logLevelTrace);
|
||||
FUNCTION_DEBUG_PARAM(STORAGE_DRIVER_POSIX, this);
|
||||
FUNCTION_DEBUG_PARAM(STRING, file);
|
||||
FUNCTION_DEBUG_PARAM(BOOL, ignoreMissing);
|
||||
|
||||
FUNCTION_TEST_ASSERT(this != NULL);
|
||||
FUNCTION_DEBUG_ASSERT(file != NULL);
|
||||
FUNCTION_DEBUG_END();
|
||||
|
||||
FUNCTION_DEBUG_RESULT(STORAGE_FILE_READ, storageDriverPosixFileReadInterface(storageDriverPosixFileReadNew(this, file, ignoreMissing)));
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
New file write object
|
||||
***********************************************************************************************************************************/
|
||||
StorageFileWrite *
|
||||
storageDriverPosixNewWrite(
|
||||
const StorageDriverPosix *this, const String *file, mode_t modeFile, mode_t modePath, bool createPath, bool syncFile,
|
||||
bool syncPath, bool atomic)
|
||||
{
|
||||
FUNCTION_DEBUG_BEGIN(logLevelTrace);
|
||||
FUNCTION_DEBUG_PARAM(STORAGE_DRIVER_POSIX, this);
|
||||
FUNCTION_TEST_PARAM(STRING, file);
|
||||
FUNCTION_TEST_PARAM(MODE, modeFile);
|
||||
FUNCTION_TEST_PARAM(MODE, modePath);
|
||||
FUNCTION_TEST_PARAM(BOOL, createPath);
|
||||
FUNCTION_TEST_PARAM(BOOL, syncFile);
|
||||
FUNCTION_TEST_PARAM(BOOL, syncPath);
|
||||
FUNCTION_TEST_PARAM(BOOL, atomic);
|
||||
|
||||
FUNCTION_TEST_ASSERT(this != NULL);
|
||||
FUNCTION_DEBUG_ASSERT(file != NULL);
|
||||
FUNCTION_DEBUG_END();
|
||||
|
||||
FUNCTION_DEBUG_RESULT(
|
||||
STORAGE_FILE_WRITE,
|
||||
storageDriverPosixFileWriteInterface(
|
||||
storageDriverPosixFileWriteNew(this, file, modeFile, modePath, createPath, syncFile, syncPath, atomic)));
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Create a path
|
||||
***********************************************************************************************************************************/
|
||||
void
|
||||
storageDriverPosixPathCreate(const String *path, bool errorOnExists, bool noParentCreate, mode_t mode)
|
||||
storageDriverPosixPathCreate(
|
||||
const StorageDriverPosix *this, const String *path, bool errorOnExists, bool noParentCreate, mode_t mode)
|
||||
{
|
||||
FUNCTION_DEBUG_BEGIN(logLevelTrace);
|
||||
FUNCTION_DEBUG_PARAM(STORAGE_DRIVER_POSIX, this);
|
||||
FUNCTION_DEBUG_PARAM(STRING, path);
|
||||
FUNCTION_DEBUG_PARAM(BOOL, errorOnExists);
|
||||
FUNCTION_DEBUG_PARAM(BOOL, noParentCreate);
|
||||
FUNCTION_DEBUG_PARAM(MODE, mode);
|
||||
|
||||
FUNCTION_TEST_ASSERT(this != NULL);
|
||||
FUNCTION_DEBUG_ASSERT(path != NULL);
|
||||
FUNCTION_DEBUG_END();
|
||||
|
||||
@ -254,8 +369,8 @@ storageDriverPosixPathCreate(const String *path, bool errorOnExists, bool noPare
|
||||
// If the parent path does not exist then create it if allowed
|
||||
if (errno == ENOENT && !noParentCreate)
|
||||
{
|
||||
storageDriverPosixPathCreate(strPath(path), errorOnExists, noParentCreate, mode);
|
||||
storageDriverPosixPathCreate(path, errorOnExists, noParentCreate, mode);
|
||||
storageDriverPosixPathCreate(this, strPath(path), errorOnExists, noParentCreate, mode);
|
||||
storageDriverPosixPathCreate(this, path, errorOnExists, noParentCreate, mode);
|
||||
}
|
||||
// Ignore path exists if allowed
|
||||
else if (errno != EEXIST || errorOnExists)
|
||||
@ -269,13 +384,15 @@ storageDriverPosixPathCreate(const String *path, bool errorOnExists, bool noPare
|
||||
Remove a path
|
||||
***********************************************************************************************************************************/
|
||||
void
|
||||
storageDriverPosixPathRemove(const String *path, bool errorOnMissing, bool recurse)
|
||||
storageDriverPosixPathRemove(const StorageDriverPosix *this, const String *path, bool errorOnMissing, bool recurse)
|
||||
{
|
||||
FUNCTION_DEBUG_BEGIN(logLevelTrace);
|
||||
FUNCTION_DEBUG_PARAM(STORAGE_DRIVER_POSIX, this);
|
||||
FUNCTION_DEBUG_PARAM(STRING, path);
|
||||
FUNCTION_DEBUG_PARAM(BOOL, errorOnMissing);
|
||||
FUNCTION_DEBUG_PARAM(BOOL, recurse);
|
||||
|
||||
FUNCTION_TEST_ASSERT(this != NULL);
|
||||
FUNCTION_DEBUG_ASSERT(path != NULL);
|
||||
FUNCTION_DEBUG_END();
|
||||
|
||||
@ -285,7 +402,7 @@ storageDriverPosixPathRemove(const String *path, bool errorOnMissing, bool recur
|
||||
if (recurse)
|
||||
{
|
||||
// Get a list of files in this path
|
||||
StringList *fileList = storageDriverPosixList(path, errorOnMissing, NULL);
|
||||
StringList *fileList = storageDriverPosixList(this, path, errorOnMissing, NULL);
|
||||
|
||||
// Only continue if the path exists
|
||||
if (fileList != NULL)
|
||||
@ -300,7 +417,7 @@ storageDriverPosixPathRemove(const String *path, bool errorOnMissing, bool recur
|
||||
{
|
||||
// These errors indicate that the entry is actually a path so we'll try to delete it that way
|
||||
if (errno == EPERM || errno == EISDIR) // {uncovered - EPERM is not returned on tested systems}
|
||||
storageDriverPosixPathRemove(file, false, true);
|
||||
storageDriverPosixPathRemove(this, file, false, true);
|
||||
// Else error
|
||||
else
|
||||
THROW_SYS_ERROR_FMT(PathRemoveError, "unable to remove path/file '%s'", strPtr(file));
|
||||
@ -325,12 +442,14 @@ storageDriverPosixPathRemove(const String *path, bool errorOnMissing, bool recur
|
||||
Sync a path
|
||||
***********************************************************************************************************************************/
|
||||
void
|
||||
storageDriverPosixPathSync(const String *path, bool ignoreMissing)
|
||||
storageDriverPosixPathSync(const StorageDriverPosix *this, const String *path, bool ignoreMissing)
|
||||
{
|
||||
FUNCTION_DEBUG_BEGIN(logLevelTrace);
|
||||
FUNCTION_DEBUG_PARAM(STORAGE_DRIVER_POSIX, this);
|
||||
FUNCTION_DEBUG_PARAM(STRING, path);
|
||||
FUNCTION_DEBUG_PARAM(BOOL, ignoreMissing);
|
||||
|
||||
FUNCTION_TEST_ASSERT(this != NULL);
|
||||
FUNCTION_DEBUG_ASSERT(path != NULL);
|
||||
FUNCTION_DEBUG_END();
|
||||
|
||||
@ -354,12 +473,14 @@ storageDriverPosixPathSync(const String *path, bool ignoreMissing)
|
||||
Remove a file
|
||||
***********************************************************************************************************************************/
|
||||
void
|
||||
storageDriverPosixRemove(const String *file, bool errorOnMissing)
|
||||
storageDriverPosixRemove(const StorageDriverPosix *this, const String *file, bool errorOnMissing)
|
||||
{
|
||||
FUNCTION_DEBUG_BEGIN(logLevelTrace);
|
||||
FUNCTION_DEBUG_PARAM(STORAGE_DRIVER_POSIX, this);
|
||||
FUNCTION_DEBUG_PARAM(STRING, file);
|
||||
FUNCTION_DEBUG_PARAM(BOOL, errorOnMissing);
|
||||
|
||||
FUNCTION_TEST_ASSERT(this != NULL);
|
||||
FUNCTION_DEBUG_ASSERT(file != NULL);
|
||||
FUNCTION_DEBUG_END();
|
||||
|
||||
@ -372,3 +493,36 @@ storageDriverPosixRemove(const String *file, bool errorOnMissing)
|
||||
|
||||
FUNCTION_DEBUG_RESULT_VOID();
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Getters
|
||||
***********************************************************************************************************************************/
|
||||
Storage *
|
||||
storageDriverPosixInterface(const StorageDriverPosix *this)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_DEBUG_PARAM(STORAGE_DRIVER_POSIX, this);
|
||||
|
||||
FUNCTION_TEST_ASSERT(this != NULL);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
FUNCTION_TEST_RESULT(STORAGE, this->interface);
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Free the file
|
||||
***********************************************************************************************************************************/
|
||||
void
|
||||
storageDriverPosixFree(StorageDriverPosix *this)
|
||||
{
|
||||
FUNCTION_DEBUG_BEGIN(logLevelTrace);
|
||||
FUNCTION_DEBUG_PARAM(STORAGE_DRIVER_POSIX, this);
|
||||
FUNCTION_DEBUG_END();
|
||||
|
||||
if (this != NULL)
|
||||
{
|
||||
memContextFree(this->memContext);
|
||||
}
|
||||
|
||||
FUNCTION_DEBUG_RESULT_VOID();
|
||||
}
|
||||
|
@ -4,6 +4,11 @@ Posix Storage Driver
|
||||
#ifndef STORAGE_DRIVER_POSIX_STORAGE_H
|
||||
#define STORAGE_DRIVER_POSIX_STORAGE_H
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Object type
|
||||
***********************************************************************************************************************************/
|
||||
typedef struct StorageDriverPosix StorageDriverPosix;
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "common/type/buffer.h"
|
||||
@ -11,17 +16,59 @@ Posix Storage Driver
|
||||
#include "storage/driver/posix/fileRead.h"
|
||||
#include "storage/driver/posix/fileWrite.h"
|
||||
#include "storage/info.h"
|
||||
#include "storage/storage.intern.h"
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Function
|
||||
Driver type constant
|
||||
***********************************************************************************************************************************/
|
||||
bool storageDriverPosixExists(const String *path);
|
||||
StorageInfo storageDriverPosixInfo(const String *file, bool ignoreMissing);
|
||||
StringList *storageDriverPosixList(const String *path, bool errorOnMissing, const String *expression);
|
||||
bool storageDriverPosixMove(StorageDriverPosixFileRead *source, StorageDriverPosixFileWrite *destination);
|
||||
void storageDriverPosixPathCreate(const String *path, bool errorOnExists, bool noParentCreate, mode_t mode);
|
||||
void storageDriverPosixPathRemove(const String *path, bool errorOnMissing, bool recurse);
|
||||
void storageDriverPosixPathSync(const String *path, bool ignoreMissing);
|
||||
void storageDriverPosixRemove(const String *file, bool errorOnMissing);
|
||||
#define STORAGE_DRIVER_POSIX_TYPE "posix"
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Constructor
|
||||
***********************************************************************************************************************************/
|
||||
StorageDriverPosix *storageDriverPosixNew(
|
||||
const String *path, mode_t modeFile, mode_t modePath, bool write, StoragePathExpressionCallback pathExpressionFunction);
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Functions
|
||||
***********************************************************************************************************************************/
|
||||
bool storageDriverPosixExists(const StorageDriverPosix *this, const String *path);
|
||||
StorageInfo storageDriverPosixInfo(const StorageDriverPosix *this, const String *file, bool ignoreMissing);
|
||||
StringList *storageDriverPosixList(
|
||||
const StorageDriverPosix *this, const String *path, bool errorOnMissing, const String *expression);
|
||||
bool storageDriverPosixMove(
|
||||
const StorageDriverPosix *this, StorageDriverPosixFileRead *source, StorageDriverPosixFileWrite *destination);
|
||||
StorageFileRead *storageDriverPosixNewRead(const StorageDriverPosix *this, const String *file, bool ignoreMissing);
|
||||
StorageFileWrite *storageDriverPosixNewWrite(
|
||||
const StorageDriverPosix *this, const String *file, mode_t modeFile, mode_t modePath, bool createPath, bool syncFile,
|
||||
bool syncPath, bool atomic);
|
||||
void storageDriverPosixPathCreate(
|
||||
const StorageDriverPosix *this, const String *path, bool errorOnExists, bool noParentCreate, mode_t mode);
|
||||
void storageDriverPosixPathRemove(const StorageDriverPosix *this, const String *path, bool errorOnMissing, bool recurse);
|
||||
void storageDriverPosixPathSync(const StorageDriverPosix *this, const String *path, bool ignoreMissing);
|
||||
void storageDriverPosixRemove(const StorageDriverPosix *this, const String *file, bool errorOnMissing);
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Getters
|
||||
***********************************************************************************************************************************/
|
||||
Storage *storageDriverPosixInterface(const StorageDriverPosix *this);
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Destructor
|
||||
***********************************************************************************************************************************/
|
||||
void storageDriverPosixFree(StorageDriverPosix *this);
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Macros for function logging
|
||||
***********************************************************************************************************************************/
|
||||
#define FUNCTION_DEBUG_STORAGE_DRIVER_POSIX_TYPE \
|
||||
StorageDriverPosix *
|
||||
#define FUNCTION_DEBUG_STORAGE_DRIVER_POSIX_FORMAT(value, buffer, bufferSize) \
|
||||
objToLog(value, "StorageDriverPosix", buffer, bufferSize)
|
||||
|
||||
#define FUNCTION_DEBUG_CONST_STORAGE_DRIVER_POSIX_TYPE \
|
||||
const StorageDriverPosix *
|
||||
#define FUNCTION_DEBUG_CONST_STORAGE_DRIVER_POSIX_FORMAT(value, buffer, bufferSize) \
|
||||
objToLog(value, "StorageDriverPosix", buffer, bufferSize)
|
||||
|
||||
#endif
|
||||
|
@ -1,49 +1,52 @@
|
||||
/***********************************************************************************************************************************
|
||||
Storage File Read
|
||||
Storage File Read Interface
|
||||
***********************************************************************************************************************************/
|
||||
#include "common/assert.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/log.h"
|
||||
#include "common/memContext.h"
|
||||
#include "storage/fileRead.h"
|
||||
#include "storage/fileRead.intern.h"
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Storage file structure
|
||||
Object type
|
||||
***********************************************************************************************************************************/
|
||||
struct StorageFileRead
|
||||
{
|
||||
MemContext *memContext;
|
||||
StorageDriverPosixFileRead *fileDriver;
|
||||
IoRead *io;
|
||||
const String *type;
|
||||
const StorageFileReadInterface *interface;
|
||||
void *driver;
|
||||
|
||||
StorageFileReadIgnoreMissing ignoreMissing;
|
||||
StorageFileReadIo io;
|
||||
StorageFileReadName name;
|
||||
};
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Create a new storage file
|
||||
***********************************************************************************************************************************/
|
||||
StorageFileRead *
|
||||
storageFileReadNew(const String *name, bool ignoreMissing)
|
||||
storageFileReadNew(const String *type, void *driver, const StorageFileReadInterface *interface)
|
||||
{
|
||||
FUNCTION_DEBUG_BEGIN(logLevelTrace);
|
||||
FUNCTION_DEBUG_PARAM(STRING, name);
|
||||
FUNCTION_DEBUG_PARAM(BOOL, ignoreMissing);
|
||||
FUNCTION_DEBUG_PARAM(STRING, type);
|
||||
FUNCTION_DEBUG_PARAM(VOIDP, driver);
|
||||
FUNCTION_DEBUG_PARAM(STORAGE_FILE_READ_INTERFACE, interface);
|
||||
|
||||
FUNCTION_TEST_ASSERT(name != NULL);
|
||||
FUNCTION_TEST_ASSERT(type != NULL);
|
||||
FUNCTION_TEST_ASSERT(driver != NULL);
|
||||
FUNCTION_TEST_ASSERT(interface->ignoreMissing != NULL);
|
||||
FUNCTION_TEST_ASSERT(interface->io != NULL);
|
||||
FUNCTION_TEST_ASSERT(interface->name != NULL);
|
||||
FUNCTION_DEBUG_END();
|
||||
|
||||
StorageFileRead *this = NULL;
|
||||
|
||||
MEM_CONTEXT_NEW_BEGIN("StorageFileRead")
|
||||
{
|
||||
this = memNew(sizeof(StorageFileRead));
|
||||
this->memContext = memContextCurrent();
|
||||
|
||||
this->fileDriver = storageDriverPosixFileReadNew(name, ignoreMissing);
|
||||
|
||||
this->io = ioReadNew(
|
||||
this->fileDriver, (IoReadOpen)storageDriverPosixFileReadOpen, (IoReadProcess)storageDriverPosixFileRead,
|
||||
(IoReadClose)storageDriverPosixFileReadClose, (IoReadEof)storageDriverPosixFileReadEof);
|
||||
}
|
||||
MEM_CONTEXT_NEW_END();
|
||||
this = memNew(sizeof(StorageFileRead));
|
||||
this->memContext = memContextCurrent();
|
||||
this->type = type;
|
||||
this->interface = interface;
|
||||
this->driver = driver;
|
||||
|
||||
FUNCTION_DEBUG_RESULT(STORAGE_FILE_READ, this);
|
||||
}
|
||||
@ -70,7 +73,7 @@ storageFileReadMove(StorageFileRead *this, MemContext *parentNew)
|
||||
/***********************************************************************************************************************************
|
||||
Get file driver
|
||||
***********************************************************************************************************************************/
|
||||
StorageDriverPosixFileRead *
|
||||
void *
|
||||
storageFileReadDriver(const StorageFileRead *this)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
@ -79,22 +82,7 @@ storageFileReadDriver(const StorageFileRead *this)
|
||||
FUNCTION_TEST_ASSERT(this != NULL);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
FUNCTION_TEST_RESULT(STORAGE_DRIVER_POSIX_FILE_READ, this->fileDriver);
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Get io interface
|
||||
***********************************************************************************************************************************/
|
||||
IoRead *
|
||||
storageFileReadIo(const StorageFileRead *this)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(STORAGE_FILE_READ, this);
|
||||
|
||||
FUNCTION_TEST_ASSERT(this != NULL);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
FUNCTION_TEST_RESULT(IO_READ, this->io);
|
||||
FUNCTION_TEST_RESULT(VOIDP, this->driver);
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
@ -109,7 +97,22 @@ storageFileReadIgnoreMissing(const StorageFileRead *this)
|
||||
FUNCTION_TEST_ASSERT(this != NULL);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
FUNCTION_TEST_RESULT(BOOL, storageDriverPosixFileReadIgnoreMissing(this->fileDriver));
|
||||
FUNCTION_TEST_RESULT(BOOL, this->interface->ignoreMissing(this->driver));
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Get io interface
|
||||
***********************************************************************************************************************************/
|
||||
IoRead *
|
||||
storageFileReadIo(const StorageFileRead *this)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(STORAGE_FILE_READ, this);
|
||||
|
||||
FUNCTION_TEST_ASSERT(this != NULL);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
FUNCTION_TEST_RESULT(IO_READ, this->interface->io(this->driver));
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
@ -124,14 +127,40 @@ storageFileReadName(const StorageFileRead *this)
|
||||
FUNCTION_TEST_ASSERT(this != NULL);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
FUNCTION_TEST_RESULT(CONST_STRING, storageDriverPosixFileReadName(this->fileDriver));
|
||||
FUNCTION_TEST_RESULT(CONST_STRING, this->interface->name(this->driver));
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Get file type
|
||||
***********************************************************************************************************************************/
|
||||
const String *
|
||||
storageFileReadType(const StorageFileRead *this)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(STORAGE_FILE_READ, this);
|
||||
|
||||
FUNCTION_TEST_ASSERT(this != NULL);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
FUNCTION_TEST_RESULT(CONST_STRING, this->type);
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Render as string for logging
|
||||
***********************************************************************************************************************************/
|
||||
String *
|
||||
storageFileReadToLog(const StorageFileRead *this)
|
||||
{
|
||||
return strNewFmt(
|
||||
"{type: %s, name: %s, ignoreMissing: %s}", strPtr(this->type), strPtr(strToLog(storageFileReadName(this))),
|
||||
cvtBoolToConstZ(storageFileReadIgnoreMissing(this)));
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Free the file
|
||||
***********************************************************************************************************************************/
|
||||
void
|
||||
storageFileReadFree(StorageFileRead *this)
|
||||
storageFileReadFree(const StorageFileRead *this)
|
||||
{
|
||||
FUNCTION_DEBUG_BEGIN(logLevelTrace);
|
||||
FUNCTION_DEBUG_PARAM(STORAGE_FILE_READ, this);
|
||||
|
@ -1,23 +1,15 @@
|
||||
/***********************************************************************************************************************************
|
||||
Storage File Read
|
||||
Storage File Read Interface
|
||||
***********************************************************************************************************************************/
|
||||
#ifndef STORAGE_FILEREAD_H
|
||||
#define STORAGE_FILEREAD_H
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Storage file read object
|
||||
Object type
|
||||
***********************************************************************************************************************************/
|
||||
typedef struct StorageFileRead StorageFileRead;
|
||||
|
||||
#include "common/io/read.h"
|
||||
#include "common/type/buffer.h"
|
||||
#include "common/type/string.h"
|
||||
#include "storage/driver/posix/fileRead.h"
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Constructor
|
||||
***********************************************************************************************************************************/
|
||||
StorageFileRead *storageFileReadNew(const String *name, bool ignoreMissing);
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Functions
|
||||
@ -27,22 +19,25 @@ StorageFileRead *storageFileReadMove(StorageFileRead *this, MemContext *parentNe
|
||||
/***********************************************************************************************************************************
|
||||
Getters
|
||||
***********************************************************************************************************************************/
|
||||
StorageDriverPosixFileRead *storageFileReadDriver(const StorageFileRead *this);
|
||||
void *storageFileReadDriver(const StorageFileRead *this);
|
||||
IoRead *storageFileReadIo(const StorageFileRead *this);
|
||||
bool storageFileReadIgnoreMissing(const StorageFileRead *this);
|
||||
const String *storageFileReadName(const StorageFileRead *this);
|
||||
const String *storageFileReadType(const StorageFileRead *this);
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Destructor
|
||||
***********************************************************************************************************************************/
|
||||
void storageFileReadFree(StorageFileRead *this);
|
||||
void storageFileReadFree(const StorageFileRead *this);
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Macros for function logging
|
||||
***********************************************************************************************************************************/
|
||||
String *storageFileReadToLog(const StorageFileRead *this);
|
||||
|
||||
#define FUNCTION_DEBUG_STORAGE_FILE_READ_TYPE \
|
||||
StorageFileRead *
|
||||
#define FUNCTION_DEBUG_STORAGE_FILE_READ_FORMAT(value, buffer, bufferSize) \
|
||||
objToLog(value, "StorageFileRead", buffer, bufferSize)
|
||||
FUNCTION_DEBUG_STRING_OBJECT_FORMAT(value, storageFileReadToLog, buffer, bufferSize)
|
||||
|
||||
#endif
|
||||
|
36
src/storage/fileRead.intern.h
Normal file
36
src/storage/fileRead.intern.h
Normal file
@ -0,0 +1,36 @@
|
||||
/***********************************************************************************************************************************
|
||||
Storage File Read Interface Internal
|
||||
***********************************************************************************************************************************/
|
||||
#ifndef STORAGE_FILEREAD_INTERN_H
|
||||
#define STORAGE_FILEREAD_INTERN_H
|
||||
|
||||
#include "storage/fileRead.h"
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Interface
|
||||
***********************************************************************************************************************************/
|
||||
typedef bool (*StorageFileReadIgnoreMissing)(const void *driver);
|
||||
typedef IoRead *(*StorageFileReadIo)(const void *driver);
|
||||
typedef const String *(*StorageFileReadName)(const void *driver);
|
||||
|
||||
typedef struct StorageFileReadInterface
|
||||
{
|
||||
StorageFileReadIgnoreMissing ignoreMissing;
|
||||
StorageFileReadIo io;
|
||||
StorageFileReadName name;
|
||||
} StorageFileReadInterface;
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Constructor
|
||||
***********************************************************************************************************************************/
|
||||
StorageFileRead *storageFileReadNew(const String *type, void *driver, const StorageFileReadInterface *interface);
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Macros for function logging
|
||||
***********************************************************************************************************************************/
|
||||
#define FUNCTION_DEBUG_STORAGE_FILE_READ_INTERFACE_TYPE \
|
||||
StorageFileReadInterface *
|
||||
#define FUNCTION_DEBUG_STORAGE_FILE_READ_INTERFACE_FORMAT(value, buffer, bufferSize) \
|
||||
objToLog(value, "StorageFileReadInterface", buffer, bufferSize)
|
||||
|
||||
#endif
|
@ -1,20 +1,21 @@
|
||||
/***********************************************************************************************************************************
|
||||
Storage File Write
|
||||
Storage File Write Interface
|
||||
***********************************************************************************************************************************/
|
||||
#include "common/assert.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/log.h"
|
||||
#include "common/memContext.h"
|
||||
#include "storage/fileWrite.h"
|
||||
#include "storage/fileWrite.intern.h"
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Storage file structure
|
||||
Object type
|
||||
***********************************************************************************************************************************/
|
||||
struct StorageFileWrite
|
||||
{
|
||||
MemContext *memContext;
|
||||
StorageDriverPosixFileWrite *fileDriver;
|
||||
IoWrite *io;
|
||||
const String *type;
|
||||
void *driver;
|
||||
const StorageFileWriteInterface *interface;
|
||||
};
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
@ -24,37 +25,32 @@ This object expects its context to be created in advance. This is so the callin
|
||||
required multiple functions and contexts to make it safe.
|
||||
***********************************************************************************************************************************/
|
||||
StorageFileWrite *
|
||||
storageFileWriteNew(
|
||||
const String *name, mode_t modeFile, mode_t modePath, bool noCreatePath, bool noSyncFile, bool noSyncPath, bool noAtomic)
|
||||
storageFileWriteNew(const String *type, void *driver, const StorageFileWriteInterface *interface)
|
||||
{
|
||||
FUNCTION_DEBUG_BEGIN(logLevelTrace);
|
||||
FUNCTION_DEBUG_PARAM(STRING, name);
|
||||
FUNCTION_DEBUG_PARAM(MODE, modeFile);
|
||||
FUNCTION_DEBUG_PARAM(MODE, modePath);
|
||||
FUNCTION_DEBUG_PARAM(BOOL, noCreatePath);
|
||||
FUNCTION_DEBUG_PARAM(BOOL, noSyncFile);
|
||||
FUNCTION_DEBUG_PARAM(BOOL, noSyncPath);
|
||||
FUNCTION_DEBUG_PARAM(BOOL, noAtomic);
|
||||
FUNCTION_DEBUG_PARAM(STRING, type);
|
||||
FUNCTION_DEBUG_PARAM(VOIDP, driver);
|
||||
FUNCTION_DEBUG_PARAM(STORAGE_FILE_WRITE_INTERFACE, interface);
|
||||
|
||||
FUNCTION_TEST_ASSERT(name != NULL);
|
||||
FUNCTION_TEST_ASSERT(type != NULL);
|
||||
FUNCTION_TEST_ASSERT(driver != NULL);
|
||||
FUNCTION_TEST_ASSERT(interface != NULL);
|
||||
FUNCTION_TEST_ASSERT(interface->atomic != NULL);
|
||||
FUNCTION_TEST_ASSERT(interface->createPath != NULL);
|
||||
FUNCTION_TEST_ASSERT(interface->io != NULL);
|
||||
FUNCTION_TEST_ASSERT(interface->modeFile != NULL);
|
||||
FUNCTION_TEST_ASSERT(interface->modePath != NULL);
|
||||
FUNCTION_TEST_ASSERT(interface->name != NULL);
|
||||
FUNCTION_TEST_ASSERT(interface->syncFile != NULL);
|
||||
FUNCTION_TEST_ASSERT(interface->syncPath != NULL);
|
||||
FUNCTION_DEBUG_END();
|
||||
|
||||
StorageFileWrite *this = NULL;
|
||||
StorageFileWrite *this = memNew(sizeof(StorageFileWrite));
|
||||
this->memContext = memContextCurrent();
|
||||
|
||||
ASSERT_DEBUG(name != NULL);
|
||||
|
||||
MEM_CONTEXT_NEW_BEGIN("StorageFileWrite")
|
||||
{
|
||||
this = memNew(sizeof(StorageFileWrite));
|
||||
this->memContext = MEM_CONTEXT_NEW();
|
||||
|
||||
this->fileDriver = storageDriverPosixFileWriteNew(name, modeFile, modePath, noCreatePath, noSyncFile, noSyncPath, noAtomic);
|
||||
|
||||
this->io = ioWriteNew(
|
||||
this->fileDriver, (IoWriteOpen)storageDriverPosixFileWriteOpen, (IoWriteProcess)storageDriverPosixFileWrite,
|
||||
(IoWriteClose)storageDriverPosixFileWriteClose);
|
||||
}
|
||||
MEM_CONTEXT_NEW_END();
|
||||
this->type = type;
|
||||
this->driver = driver;
|
||||
this->interface = interface;
|
||||
|
||||
FUNCTION_DEBUG_RESULT(STORAGE_FILE_WRITE, this);
|
||||
}
|
||||
@ -92,7 +88,7 @@ storageFileWriteAtomic(const StorageFileWrite *this)
|
||||
FUNCTION_TEST_ASSERT(this != NULL);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
FUNCTION_TEST_RESULT(BOOL, storageDriverPosixFileWriteAtomic(this->fileDriver));
|
||||
FUNCTION_TEST_RESULT(BOOL, this->interface->atomic(this->driver));
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
@ -107,13 +103,13 @@ storageFileWriteCreatePath(const StorageFileWrite *this)
|
||||
FUNCTION_TEST_ASSERT(this != NULL);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
FUNCTION_TEST_RESULT(BOOL, storageDriverPosixFileWriteCreatePath(this->fileDriver));
|
||||
FUNCTION_TEST_RESULT(BOOL, this->interface->createPath(this->driver));
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Get file driver
|
||||
***********************************************************************************************************************************/
|
||||
StorageDriverPosixFileWrite *
|
||||
void *
|
||||
storageFileWriteFileDriver(const StorageFileWrite *this)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
@ -122,7 +118,7 @@ storageFileWriteFileDriver(const StorageFileWrite *this)
|
||||
FUNCTION_TEST_ASSERT(this != NULL);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
FUNCTION_TEST_RESULT(STORAGE_DRIVER_POSIX_FILE_WRITE, this->fileDriver);
|
||||
FUNCTION_TEST_RESULT(VOIDP, this->driver);
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
@ -137,7 +133,7 @@ storageFileWriteIo(const StorageFileWrite *this)
|
||||
FUNCTION_TEST_ASSERT(this != NULL);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
FUNCTION_TEST_RESULT(IO_WRITE, this->io);
|
||||
FUNCTION_TEST_RESULT(IO_WRITE, this->interface->io(this->driver));
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
@ -152,7 +148,7 @@ storageFileWriteModeFile(const StorageFileWrite *this)
|
||||
FUNCTION_TEST_ASSERT(this != NULL);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
FUNCTION_TEST_RESULT(MODE, storageDriverPosixFileWriteModeFile(this->fileDriver));
|
||||
FUNCTION_TEST_RESULT(MODE, this->interface->modeFile(this->driver));
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
@ -167,7 +163,7 @@ storageFileWriteModePath(const StorageFileWrite *this)
|
||||
FUNCTION_TEST_ASSERT(this != NULL);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
FUNCTION_TEST_RESULT(MODE, storageDriverPosixFileWriteModePath(this->fileDriver));
|
||||
FUNCTION_TEST_RESULT(MODE, this->interface->modePath(this->driver));
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
@ -182,22 +178,7 @@ storageFileWriteName(const StorageFileWrite *this)
|
||||
FUNCTION_TEST_ASSERT(this != NULL);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
FUNCTION_TEST_RESULT(CONST_STRING, storageDriverPosixFileWriteName(this->fileDriver));
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Get file path
|
||||
***********************************************************************************************************************************/
|
||||
const String *
|
||||
storageFileWritePath(const StorageFileWrite *this)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(STORAGE_FILE_WRITE, this);
|
||||
|
||||
FUNCTION_TEST_ASSERT(this != NULL);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
FUNCTION_TEST_RESULT(CONST_STRING, storageDriverPosixFileWritePath(this->fileDriver));
|
||||
FUNCTION_TEST_RESULT(CONST_STRING, this->interface->name(this->driver));
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
@ -212,7 +193,7 @@ storageFileWriteSyncFile(const StorageFileWrite *this)
|
||||
FUNCTION_TEST_ASSERT(this != NULL);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
FUNCTION_TEST_RESULT(BOOL, storageDriverPosixFileWriteSyncFile(this->fileDriver));
|
||||
FUNCTION_TEST_RESULT(BOOL, this->interface->syncFile(this->driver));
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
@ -227,7 +208,36 @@ storageFileWriteSyncPath(const StorageFileWrite *this)
|
||||
FUNCTION_TEST_ASSERT(this != NULL);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
FUNCTION_TEST_RESULT(BOOL, storageDriverPosixFileWriteSyncPath(this->fileDriver));
|
||||
FUNCTION_TEST_RESULT(BOOL, this->interface->syncPath(this->driver));
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Get file type
|
||||
***********************************************************************************************************************************/
|
||||
const String *
|
||||
storageFileWriteType(const StorageFileWrite *this)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(STORAGE_FILE_WRITE, this);
|
||||
|
||||
FUNCTION_TEST_ASSERT(this != NULL);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
FUNCTION_TEST_RESULT(CONST_STRING, this->type);
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Render as string for logging
|
||||
***********************************************************************************************************************************/
|
||||
String *
|
||||
storageFileWriteToLog(const StorageFileWrite *this)
|
||||
{
|
||||
return strNewFmt(
|
||||
"{type: %s, name: %s, modeFile: %04o, modePath: %04o, createPath: %s, syncFile: %s, syncPath: %s, atomic: %s}",
|
||||
strPtr(this->type), strPtr(strToLog(storageFileWriteName(this))), storageFileWriteModeFile(this),
|
||||
storageFileWriteModePath(this), cvtBoolToConstZ(storageFileWriteCreatePath(this)),
|
||||
cvtBoolToConstZ(storageFileWriteSyncFile(this)), cvtBoolToConstZ(storageFileWriteSyncPath(this)),
|
||||
cvtBoolToConstZ(storageFileWriteAtomic(this)));
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
|
@ -1,5 +1,5 @@
|
||||
/***********************************************************************************************************************************
|
||||
Storage File Write
|
||||
Storage File Write Interface
|
||||
***********************************************************************************************************************************/
|
||||
#ifndef STORAGE_FILEWRITE_H
|
||||
#define STORAGE_FILEWRITE_H
|
||||
@ -7,26 +7,13 @@ Storage File Write
|
||||
#include <sys/types.h>
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Storage file read object
|
||||
Object type
|
||||
***********************************************************************************************************************************/
|
||||
typedef struct StorageFileWrite StorageFileWrite;
|
||||
|
||||
#include "common/io/write.h"
|
||||
#include "common/type/buffer.h"
|
||||
#include "common/type/string.h"
|
||||
#include "storage/driver/posix/fileWrite.h"
|
||||
#include "version.h"
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Temporary file extension
|
||||
***********************************************************************************************************************************/
|
||||
#define STORAGE_FILE_TEMP_EXT PGBACKREST_BIN ".tmp"
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Constructor
|
||||
***********************************************************************************************************************************/
|
||||
StorageFileWrite *storageFileWriteNew(
|
||||
const String *name, mode_t modeFile, mode_t modePath, bool noCreatePath, bool noSyncFile, bool noSyncPath, bool noAtomic);
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Functions
|
||||
@ -38,14 +25,14 @@ Getters
|
||||
***********************************************************************************************************************************/
|
||||
bool storageFileWriteAtomic(const StorageFileWrite *this);
|
||||
bool storageFileWriteCreatePath(const StorageFileWrite *this);
|
||||
StorageDriverPosixFileWrite *storageFileWriteFileDriver(const StorageFileWrite *this);
|
||||
void *storageFileWriteFileDriver(const StorageFileWrite *this);
|
||||
IoWrite *storageFileWriteIo(const StorageFileWrite *this);
|
||||
mode_t storageFileWriteModeFile(const StorageFileWrite *this);
|
||||
mode_t storageFileWriteModePath(const StorageFileWrite *this);
|
||||
const String *storageFileWriteName(const StorageFileWrite *this);
|
||||
const String *storageFileWritePath(const StorageFileWrite *this);
|
||||
bool storageFileWriteSyncFile(const StorageFileWrite *this);
|
||||
bool storageFileWriteSyncPath(const StorageFileWrite *this);
|
||||
const String *storageFileWriteType(const StorageFileWrite *this);
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Destructor
|
||||
@ -55,9 +42,11 @@ void storageFileWriteFree(const StorageFileWrite *this);
|
||||
/***********************************************************************************************************************************
|
||||
Macros for function logging
|
||||
***********************************************************************************************************************************/
|
||||
String *storageFileWriteToLog(const StorageFileWrite *this);
|
||||
|
||||
#define FUNCTION_DEBUG_STORAGE_FILE_WRITE_TYPE \
|
||||
StorageFileWrite *
|
||||
#define FUNCTION_DEBUG_STORAGE_FILE_WRITE_FORMAT(value, buffer, bufferSize) \
|
||||
objToLog(value, "StorageFileWrite", buffer, bufferSize)
|
||||
FUNCTION_DEBUG_STRING_OBJECT_FORMAT(value, storageFileWriteToLog, buffer, bufferSize)
|
||||
|
||||
#endif
|
||||
|
52
src/storage/fileWrite.intern.h
Normal file
52
src/storage/fileWrite.intern.h
Normal file
@ -0,0 +1,52 @@
|
||||
/***********************************************************************************************************************************
|
||||
Storage File Write Internal
|
||||
***********************************************************************************************************************************/
|
||||
#ifndef STORAGE_FILEWRITE_INTERN_H
|
||||
#define STORAGE_FILEWRITE_INTERN_H
|
||||
|
||||
#include "storage/fileWrite.h"
|
||||
#include "version.h"
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Temporary file extension
|
||||
***********************************************************************************************************************************/
|
||||
#define STORAGE_FILE_TEMP_EXT PGBACKREST_BIN ".tmp"
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Interface
|
||||
***********************************************************************************************************************************/
|
||||
typedef bool (*StorageFileWriteAtomic)(const void *data);
|
||||
typedef bool (*StorageFileWriteCreatePath)(const void *data);
|
||||
typedef IoWrite *(*StorageFileWriteIo)(const void *data);
|
||||
typedef mode_t (*StorageFileWriteModeFile)(const void *data);
|
||||
typedef mode_t (*StorageFileWriteModePath)(const void *data);
|
||||
typedef const String *(*StorageFileWriteName)(const void *data);
|
||||
typedef bool (*StorageFileWriteSyncFile)(const void *data);
|
||||
typedef bool (*StorageFileWriteSyncPath)(const void *data);
|
||||
|
||||
typedef struct StorageFileWriteInterface
|
||||
{
|
||||
StorageFileWriteAtomic atomic;
|
||||
StorageFileWriteCreatePath createPath;
|
||||
StorageFileWriteIo io;
|
||||
StorageFileWriteModeFile modeFile;
|
||||
StorageFileWriteModePath modePath;
|
||||
StorageFileWriteName name;
|
||||
StorageFileWriteSyncFile syncFile;
|
||||
StorageFileWriteSyncPath syncPath;
|
||||
} StorageFileWriteInterface;
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Constructor
|
||||
***********************************************************************************************************************************/
|
||||
StorageFileWrite *storageFileWriteNew(const String *type, void *driver, const StorageFileWriteInterface *interface);
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Macros for function logging
|
||||
***********************************************************************************************************************************/
|
||||
#define FUNCTION_DEBUG_STORAGE_FILE_WRITE_INTERFACE_TYPE \
|
||||
StorageFileWriteInterface *
|
||||
#define FUNCTION_DEBUG_STORAGE_FILE_WRITE_INTERFACE_FORMAT(value, buffer, bufferSize) \
|
||||
objToLog(value, "StorageFileWriteInterface", buffer, bufferSize)
|
||||
|
||||
#endif
|
@ -6,6 +6,7 @@ Storage Helper
|
||||
#include "common/debug.h"
|
||||
#include "common/memContext.h"
|
||||
#include "config/config.h"
|
||||
#include "storage/driver/posix/storage.h"
|
||||
#include "storage/helper.h"
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
@ -59,7 +60,9 @@ storageLocal(void)
|
||||
|
||||
MEM_CONTEXT_BEGIN(memContextStorageHelper)
|
||||
{
|
||||
storageLocalData = storageNewNP(strNew("/"));
|
||||
storageLocalData = storageDriverPosixInterface(
|
||||
storageDriverPosixNew(
|
||||
strNew("/"), STORAGE_MODE_FILE_DEFAULT, STORAGE_MODE_PATH_DEFAULT, false, NULL));
|
||||
}
|
||||
MEM_CONTEXT_END();
|
||||
}
|
||||
@ -83,7 +86,9 @@ storageLocalWrite(void)
|
||||
|
||||
MEM_CONTEXT_BEGIN(memContextStorageHelper)
|
||||
{
|
||||
storageLocalWriteData = storageNewP(strNew("/"), .write = true);
|
||||
storageLocalWriteData = storageDriverPosixInterface(
|
||||
storageDriverPosixNew(
|
||||
strNew("/"), STORAGE_MODE_FILE_DEFAULT, STORAGE_MODE_PATH_DEFAULT, true, NULL));
|
||||
}
|
||||
MEM_CONTEXT_END();
|
||||
}
|
||||
@ -141,8 +146,10 @@ storageSpool(void)
|
||||
MEM_CONTEXT_BEGIN(memContextStorageHelper)
|
||||
{
|
||||
storageSpoolStanza = strDup(cfgOptionStr(cfgOptStanza));
|
||||
storageSpoolData = storageNewP(
|
||||
cfgOptionStr(cfgOptSpoolPath), .pathExpressionFunction = storageSpoolPathExpression, .write = true);
|
||||
storageSpoolData = storageDriverPosixInterface(
|
||||
storageDriverPosixNew(
|
||||
cfgOptionStr(cfgOptSpoolPath), STORAGE_MODE_FILE_DEFAULT, STORAGE_MODE_PATH_DEFAULT, true,
|
||||
storageSpoolPathExpression));
|
||||
}
|
||||
MEM_CONTEXT_END();
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ typedef enum
|
||||
} StorageType;
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Storage info
|
||||
Object type
|
||||
***********************************************************************************************************************************/
|
||||
typedef struct StorageInfo
|
||||
{
|
||||
|
@ -1,5 +1,5 @@
|
||||
/***********************************************************************************************************************************
|
||||
Storage Manager
|
||||
Storage Interface
|
||||
***********************************************************************************************************************************/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
@ -10,16 +10,19 @@ Storage Manager
|
||||
#include "common/log.h"
|
||||
#include "common/memContext.h"
|
||||
#include "common/wait.h"
|
||||
#include "storage/driver/posix/storage.h"
|
||||
#include "storage/storage.h"
|
||||
#include "storage/storage.intern.h"
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Storage structure
|
||||
Object type
|
||||
***********************************************************************************************************************************/
|
||||
struct Storage
|
||||
{
|
||||
MemContext *memContext;
|
||||
String *path;
|
||||
const void *driver;
|
||||
const StorageInterface *interface;
|
||||
const String *type;
|
||||
|
||||
const String *path;
|
||||
mode_t modeFile;
|
||||
mode_t modePath;
|
||||
bool write;
|
||||
@ -30,32 +33,48 @@ struct Storage
|
||||
New storage object
|
||||
***********************************************************************************************************************************/
|
||||
Storage *
|
||||
storageNew(const String *path, StorageNewParam param)
|
||||
storageNew(
|
||||
const String *type, const String *path, mode_t modeFile, mode_t modePath, bool write,
|
||||
StoragePathExpressionCallback pathExpressionFunction, const void *driver, const StorageInterface *interface)
|
||||
{
|
||||
FUNCTION_DEBUG_BEGIN(logLevelDebug);
|
||||
FUNCTION_DEBUG_BEGIN(logLevelTrace);
|
||||
FUNCTION_DEBUG_PARAM(STRING, type);
|
||||
FUNCTION_DEBUG_PARAM(STRING, path);
|
||||
FUNCTION_DEBUG_PARAM(MODE, param.modeFile);
|
||||
FUNCTION_DEBUG_PARAM(MODE, param.modePath);
|
||||
FUNCTION_DEBUG_PARAM(BOOL, param.write);
|
||||
FUNCTION_DEBUG_PARAM(FUNCTIONP, param.pathExpressionFunction);
|
||||
FUNCTION_DEBUG_PARAM(MODE, modeFile);
|
||||
FUNCTION_DEBUG_PARAM(MODE, modePath);
|
||||
FUNCTION_DEBUG_PARAM(BOOL, write);
|
||||
FUNCTION_DEBUG_PARAM(FUNCTIONP, pathExpressionFunction);
|
||||
FUNCTION_DEBUG_PARAM(VOIDP, driver);
|
||||
FUNCTION_DEBUG_PARAM(STORAGE_INTERFACE, interface);
|
||||
|
||||
FUNCTION_DEBUG_ASSERT(path != NULL);
|
||||
FUNCTION_TEST_ASSERT(type != NULL);
|
||||
FUNCTION_TEST_ASSERT(path != NULL);
|
||||
FUNCTION_TEST_ASSERT(driver != NULL);
|
||||
FUNCTION_TEST_ASSERT(interface != NULL);
|
||||
FUNCTION_TEST_ASSERT(interface->exists != NULL);
|
||||
FUNCTION_TEST_ASSERT(interface->info != NULL);
|
||||
FUNCTION_TEST_ASSERT(interface->list != NULL);
|
||||
FUNCTION_TEST_ASSERT(interface->move != NULL);
|
||||
FUNCTION_TEST_ASSERT(interface->newRead != NULL);
|
||||
FUNCTION_TEST_ASSERT(interface->newWrite != NULL);
|
||||
FUNCTION_TEST_ASSERT(interface->pathCreate != NULL);
|
||||
FUNCTION_TEST_ASSERT(interface->pathRemove != NULL);
|
||||
FUNCTION_TEST_ASSERT(interface->pathSync != NULL);
|
||||
FUNCTION_TEST_ASSERT(interface->remove != NULL);
|
||||
FUNCTION_DEBUG_END();
|
||||
|
||||
Storage *this = NULL;
|
||||
this = (Storage *)memNew(sizeof(Storage));
|
||||
this->memContext = memContextCurrent();
|
||||
this->driver = driver;
|
||||
this->interface = interface;
|
||||
this->type = type;
|
||||
|
||||
// Create the storage
|
||||
MEM_CONTEXT_NEW_BEGIN("Storage")
|
||||
{
|
||||
this = (Storage *)memNew(sizeof(Storage));
|
||||
this->memContext = MEM_CONTEXT_NEW();
|
||||
this->path = strDup(path);
|
||||
this->modeFile = param.modeFile == 0 ? STORAGE_MODE_FILE_DEFAULT : param.modeFile;
|
||||
this->modePath = param.modePath == 0 ? STORAGE_MODE_PATH_DEFAULT : param.modePath;
|
||||
this->write = param.write;
|
||||
this->pathExpressionFunction = param.pathExpressionFunction;
|
||||
}
|
||||
MEM_CONTEXT_NEW_END();
|
||||
this->path = strDup(path);
|
||||
this->modeFile = modeFile == 0 ? STORAGE_MODE_FILE_DEFAULT : modeFile;
|
||||
this->modePath = modePath == 0 ? STORAGE_MODE_PATH_DEFAULT : modePath;
|
||||
this->write = write;
|
||||
this->pathExpressionFunction = pathExpressionFunction;
|
||||
|
||||
FUNCTION_DEBUG_RESULT(STORAGE, this);
|
||||
}
|
||||
@ -137,7 +156,7 @@ storageExists(const Storage *this, const String *pathExp, StorageExistsParam par
|
||||
do
|
||||
{
|
||||
// Call driver function
|
||||
result = storageDriverPosixExists(path);
|
||||
result = this->interface->exists(this->driver, path);
|
||||
}
|
||||
while (!result && wait != NULL && waitMore(wait));
|
||||
}
|
||||
@ -230,7 +249,7 @@ storageInfo(const Storage *this, const String *fileExp, StorageInfoParam param)
|
||||
String *file = storagePathNP(this, fileExp);
|
||||
|
||||
// Call driver function
|
||||
result = storageDriverPosixInfo(file, param.ignoreMissing);
|
||||
result = this->interface->info(this->driver, file, param.ignoreMissing);
|
||||
}
|
||||
MEM_CONTEXT_TEMP_END();
|
||||
|
||||
@ -260,7 +279,7 @@ storageList(const Storage *this, const String *pathExp, StorageListParam param)
|
||||
String *path = storagePathNP(this, pathExp);
|
||||
|
||||
// Move list up to the old context
|
||||
result = strLstMove(storageDriverPosixList(path, param.errorOnMissing, param.expression), MEM_CONTEXT_OLD());
|
||||
result = strLstMove(this->interface->list(this->driver, path, param.errorOnMissing, param.expression), MEM_CONTEXT_OLD());
|
||||
}
|
||||
MEM_CONTEXT_TEMP_END();
|
||||
|
||||
@ -271,7 +290,7 @@ storageList(const Storage *this, const String *pathExp, StorageListParam param)
|
||||
Move a file
|
||||
***********************************************************************************************************************************/
|
||||
void
|
||||
storageMove(StorageFileRead *source, StorageFileWrite *destination)
|
||||
storageMove(const Storage *this, StorageFileRead *source, StorageFileWrite *destination)
|
||||
{
|
||||
FUNCTION_DEBUG_BEGIN(logLevelDebug);
|
||||
FUNCTION_DEBUG_PARAM(STORAGE_FILE_READ, source);
|
||||
@ -280,23 +299,26 @@ storageMove(StorageFileRead *source, StorageFileWrite *destination)
|
||||
FUNCTION_TEST_ASSERT(source != NULL);
|
||||
FUNCTION_TEST_ASSERT(destination != NULL);
|
||||
FUNCTION_DEBUG_ASSERT(!storageFileReadIgnoreMissing(source));
|
||||
FUNCTION_DEBUG_ASSERT(strEq(this->type, storageFileReadType(source)));
|
||||
FUNCTION_DEBUG_ASSERT(strEq(storageFileReadType(source), storageFileWriteType(destination)));
|
||||
FUNCTION_DEBUG_END();
|
||||
|
||||
MEM_CONTEXT_TEMP_BEGIN()
|
||||
{
|
||||
// If the file can't be moved it will need to be copied
|
||||
if (!storageDriverPosixMove(storageFileReadDriver(source), storageFileWriteFileDriver(destination)))
|
||||
if (!this->interface->move(this->driver, storageFileReadDriver(source), storageFileWriteFileDriver(destination)))
|
||||
{
|
||||
// Perform the copy
|
||||
storageCopyNP(source, destination);
|
||||
|
||||
// Remove the source file
|
||||
storageDriverPosixRemove(storageFileReadName(source), false);
|
||||
this->interface->remove(this->driver, storageFileReadName(source), false);
|
||||
|
||||
// Sync source path if the destination path was synced. We know the source and destination paths are different because
|
||||
// the move did not succeed. This will need updating when drivers other than Posix/CIFS are implemented.
|
||||
// the move did not succeed. This will need updating when drivers other than Posix/CIFS are implemented becaue there's
|
||||
// no way to get coverage on it now.
|
||||
if (storageFileWriteSyncPath(destination))
|
||||
storageDriverPosixPathSync(strPath(storageFileReadName(source)), false);
|
||||
this->interface->pathSync(this->driver, strPath(storageFileReadName(source)), false);
|
||||
}
|
||||
}
|
||||
MEM_CONTEXT_TEMP_END();
|
||||
@ -323,7 +345,7 @@ storageNewRead(const Storage *this, const String *fileExp, StorageNewReadParam p
|
||||
|
||||
MEM_CONTEXT_TEMP_BEGIN()
|
||||
{
|
||||
result = storageFileReadNew(storagePathNP(this, fileExp), param.ignoreMissing);
|
||||
result = this->interface->newRead(this->driver, storagePathNP(this, fileExp), param.ignoreMissing);
|
||||
|
||||
if (param.filterGroup != NULL)
|
||||
ioReadFilterGroupSet(storageFileReadIo(result), param.filterGroup);
|
||||
@ -360,8 +382,8 @@ storageNewWrite(const Storage *this, const String *fileExp, StorageNewWriteParam
|
||||
|
||||
MEM_CONTEXT_TEMP_BEGIN()
|
||||
{
|
||||
result = storageFileWriteNew(
|
||||
storagePathNP(this, fileExp), param.modeFile != 0 ? param.modeFile : this->modeFile,
|
||||
result = this->interface->newWrite(
|
||||
this->driver, storagePathNP(this, fileExp), param.modeFile != 0 ? param.modeFile : this->modeFile,
|
||||
param.modePath != 0 ? param.modePath : this->modePath, !param.noCreatePath, !param.noSyncFile, !param.noSyncPath,
|
||||
!param.noAtomic);
|
||||
|
||||
@ -505,8 +527,8 @@ storagePathCreate(const Storage *this, const String *pathExp, StoragePathCreateP
|
||||
String *path = storagePathNP(this, pathExp);
|
||||
|
||||
// Call driver function
|
||||
storageDriverPosixPathCreate(
|
||||
path, param.errorOnExists, param.noParentCreate, param.mode != 0 ? param.mode : this->modePath);
|
||||
this->interface->pathCreate(
|
||||
this->driver, path, param.errorOnExists, param.noParentCreate, param.mode != 0 ? param.mode : this->modePath);
|
||||
}
|
||||
MEM_CONTEXT_TEMP_END();
|
||||
|
||||
@ -535,7 +557,7 @@ storagePathRemove(const Storage *this, const String *pathExp, StoragePathRemoveP
|
||||
String *path = storagePathNP(this, pathExp);
|
||||
|
||||
// Call driver function
|
||||
storageDriverPosixPathRemove(path, param.errorOnMissing, param.recurse);
|
||||
this->interface->pathRemove(this->driver, path, param.errorOnMissing, param.recurse);
|
||||
}
|
||||
MEM_CONTEXT_TEMP_END();
|
||||
|
||||
@ -562,7 +584,7 @@ void storagePathSync(const Storage *this, const String *pathExp, StoragePathSync
|
||||
String *path = storagePathNP(this, pathExp);
|
||||
|
||||
// Call driver function
|
||||
storageDriverPosixPathSync(path, param.ignoreMissing);
|
||||
this->interface->pathSync(this->driver, path, param.ignoreMissing);
|
||||
}
|
||||
MEM_CONTEXT_TEMP_END();
|
||||
|
||||
@ -610,7 +632,7 @@ storageRemove(const Storage *this, const String *fileExp, StorageRemoveParam par
|
||||
String *file = storagePathNP(this, fileExp);
|
||||
|
||||
// Call driver function
|
||||
storageDriverPosixRemove(file, param.errorOnMissing);
|
||||
this->interface->remove(this->driver, file, param.errorOnMissing);
|
||||
}
|
||||
MEM_CONTEXT_TEMP_END();
|
||||
|
||||
@ -623,7 +645,8 @@ Render as string for logging
|
||||
String *
|
||||
storageToLog(const Storage *this)
|
||||
{
|
||||
return strNewFmt("{path: %s, write: %s}", strPtr(strQuoteZ(this->path, "\"")), cvtBoolToConstZ(this->write));
|
||||
return strNewFmt(
|
||||
"{type: %s, path: %s, write: %s}", strPtr(this->type), strPtr(strToLog(this->path)), cvtBoolToConstZ(this->write));
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
|
@ -1,5 +1,5 @@
|
||||
/***********************************************************************************************************************************
|
||||
Storage Manager
|
||||
Storage Interface
|
||||
***********************************************************************************************************************************/
|
||||
#ifndef STORAGE_STORAGE_H
|
||||
#define STORAGE_STORAGE_H
|
||||
@ -7,7 +7,7 @@ Storage Manager
|
||||
#include <sys/types.h>
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Storage object
|
||||
Object type
|
||||
***********************************************************************************************************************************/
|
||||
typedef struct Storage Storage;
|
||||
|
||||
@ -18,35 +18,6 @@ typedef struct Storage Storage;
|
||||
#include "storage/fileWrite.h"
|
||||
#include "storage/info.h"
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Default file and path modes
|
||||
***********************************************************************************************************************************/
|
||||
#define STORAGE_MODE_FILE_DEFAULT 0640
|
||||
#define STORAGE_MODE_PATH_DEFAULT 0750
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Path expression callback function type - used to modify paths based on expressions enclosed in <>
|
||||
***********************************************************************************************************************************/
|
||||
typedef String *(*StoragePathExpressionCallback)(const String *expression, const String *path);
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
storageNew
|
||||
***********************************************************************************************************************************/
|
||||
typedef struct StorageNewParam
|
||||
{
|
||||
mode_t modeFile;
|
||||
mode_t modePath;
|
||||
bool write;
|
||||
StoragePathExpressionCallback pathExpressionFunction;
|
||||
} StorageNewParam;
|
||||
|
||||
#define storageNewP(path, ...) \
|
||||
storageNew(path, (StorageNewParam){__VA_ARGS__})
|
||||
#define storageNewNP(path) \
|
||||
storageNew(path, (StorageNewParam){0})
|
||||
|
||||
Storage *storageNew(const String *path, StorageNewParam param);
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
storageCopy
|
||||
***********************************************************************************************************************************/
|
||||
@ -78,7 +49,7 @@ typedef struct StorageGetParam
|
||||
size_t exactSize;
|
||||
} StorageGetParam;
|
||||
|
||||
#define storageGetP(file, ...) \
|
||||
#define storageGetP(file, ...) \
|
||||
storageGet(file, (StorageGetParam){__VA_ARGS__})
|
||||
#define storageGetNP(file) \
|
||||
storageGet(file, (StorageGetParam){0})
|
||||
@ -119,10 +90,10 @@ StringList *storageList(const Storage *this, const String *pathExp, StorageListP
|
||||
/***********************************************************************************************************************************
|
||||
storageMove
|
||||
***********************************************************************************************************************************/
|
||||
#define storageMoveNP(source, destination) \
|
||||
storageMove(source, destination)
|
||||
#define storageMoveNP(this, source, destination) \
|
||||
storageMove(this, source, destination)
|
||||
|
||||
void storageMove(StorageFileRead *source, StorageFileWrite *destination);
|
||||
void storageMove(const Storage *this, StorageFileRead *source, StorageFileWrite *destination);
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
storageNewRead
|
||||
@ -240,14 +211,6 @@ typedef struct StorageRemoveParam
|
||||
|
||||
void storageRemove(const Storage *this, const String *fileExp, StorageRemoveParam param);
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
storageFree
|
||||
***********************************************************************************************************************************/
|
||||
#define storageFreeNP(this) \
|
||||
storageFree(this)
|
||||
|
||||
void storageFree(const Storage *this);
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Macros for function logging
|
||||
***********************************************************************************************************************************/
|
||||
|
65
src/storage/storage.intern.h
Normal file
65
src/storage/storage.intern.h
Normal file
@ -0,0 +1,65 @@
|
||||
/***********************************************************************************************************************************
|
||||
Storage Interface Internal
|
||||
***********************************************************************************************************************************/
|
||||
#ifndef STORAGE_STORAGE_INTERN_H
|
||||
#define STORAGE_STORAGE_INTERN_H
|
||||
|
||||
#include "storage/storage.h"
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Default file and path modes
|
||||
***********************************************************************************************************************************/
|
||||
#define STORAGE_MODE_FILE_DEFAULT 0640
|
||||
#define STORAGE_MODE_PATH_DEFAULT 0750
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Interface
|
||||
***********************************************************************************************************************************/
|
||||
typedef bool (*StorageExistsFn)(const void *driver, const String *path);
|
||||
typedef StorageInfo (*StorageInfoFn)(const void *driver, const String *file, bool ignoreMissing);
|
||||
typedef StringList *(*StorageListFn)(const void *driver, const String *path, bool errorOnMissing, const String *expression);
|
||||
typedef bool (*StorageMoveFn)(const void *driver, void *source, void *destination);
|
||||
typedef StorageFileRead *(*StorageNewReadFn)(const void *driver, const String *file, bool ignoreMissing);
|
||||
typedef StorageFileWrite *(*StorageNewWriteFn)(
|
||||
const void *driver, const String *file, mode_t modeFile, mode_t modePath, bool createPath, bool syncFile, bool syncPath,
|
||||
bool atomic);
|
||||
typedef void (*StoragePathCreateFn)(const void *driver, const String *path, bool errorOnExists, bool noParentCreate, mode_t mode);
|
||||
typedef void (*StoragePathRemoveFn)(const void *driver, const String *path, bool errorOnMissing, bool recurse);
|
||||
typedef void (*StoragePathSyncFn)(const void *driver, const String *path, bool ignoreMissing);
|
||||
typedef void (*StorageRemoveFn)(const void *driver, const String *file, bool errorOnMissing);
|
||||
|
||||
typedef struct StorageInterface
|
||||
{
|
||||
StorageExistsFn exists;
|
||||
StorageInfoFn info;
|
||||
StorageListFn list;
|
||||
StorageMoveFn move;
|
||||
StorageNewReadFn newRead;
|
||||
StorageNewWriteFn newWrite;
|
||||
StoragePathCreateFn pathCreate;
|
||||
StoragePathRemoveFn pathRemove;
|
||||
StoragePathSyncFn pathSync;
|
||||
StorageRemoveFn remove;
|
||||
} StorageInterface;
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Path expression callback function type - used to modify paths based on expressions enclosed in <>
|
||||
***********************************************************************************************************************************/
|
||||
typedef String *(*StoragePathExpressionCallback)(const String *expression, const String *path);
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Constructor
|
||||
***********************************************************************************************************************************/
|
||||
Storage *storageNew(
|
||||
const String *type, const String *path, mode_t modeFile, mode_t modePath, bool write,
|
||||
StoragePathExpressionCallback pathExpressionFunction, const void *driver, const StorageInterface *interface);
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Macros for function logging
|
||||
***********************************************************************************************************************************/
|
||||
#define FUNCTION_DEBUG_STORAGE_INTERFACE_TYPE \
|
||||
StorageInterface *
|
||||
#define FUNCTION_DEBUG_STORAGE_INTERFACE_FORMAT(value, buffer, bufferSize) \
|
||||
objToLog(value, "StorageInterface", buffer, bufferSize)
|
||||
|
||||
#endif
|
@ -119,18 +119,18 @@ P00 DEBUG: config/load::cfgLoad: => void
|
||||
P00 DEBUG: command/archive/get/get::cmdArchiveGet: (void)
|
||||
P00 DEBUG: command/archive/get/file::archiveGetFile: (archiveFile: {"700000007000000070000000"}, walDestination: {"[TEST_PATH]/db-master/db/base/pg_xlog/RECOVERYXLOG"})
|
||||
P00 DEBUG: command/control/control::lockStopTest: (void)
|
||||
P00 DEBUG: storage/storage::storageExists: (this: {path: "/", write: false}, pathExp: {"[TEST_PATH]/db-master/lock/db.stop"}, param.timeout: 0)
|
||||
P00 DEBUG: storage/storage::storageExists: (this: {type: posix, path: {"/"}, write: false}, pathExp: {"[TEST_PATH]/db-master/lock/db.stop"}, param.timeout: 0)
|
||||
P00 DEBUG: storage/storage::storageExists: => false
|
||||
P00 DEBUG: storage/storage::storageExists: (this: {path: "/", write: false}, pathExp: {"[TEST_PATH]/db-master/lock/all.stop"}, param.timeout: 0)
|
||||
P00 DEBUG: storage/storage::storageExists: (this: {type: posix, path: {"/"}, write: false}, pathExp: {"[TEST_PATH]/db-master/lock/all.stop"}, param.timeout: 0)
|
||||
P00 DEBUG: storage/storage::storageExists: => false
|
||||
P00 DEBUG: command/control/control::lockStopTest: => void
|
||||
P00 DEBUG: command/archive/get/file::archiveGetCheck: (archiveFile: {"700000007000000070000000"})
|
||||
P00 DEBUG: postgres/info::pgControlInfo: (pgPath: {"[TEST_PATH]/db-master/db/base"})
|
||||
P00 DEBUG: storage/storage::storageGet: (file: {StorageFileRead}, param.exactSize: 512)
|
||||
P00 DEBUG: storage/storage::storageGet: (file: {type: posix, name: {"[TEST_PATH]/db-master/db/base/global/pg_control"}, ignoreMissing: false}, param.exactSize: 512)
|
||||
P00 DEBUG: storage/storage::storageGet: => {used: 512, size: 512}
|
||||
P00 DEBUG: postgres/info::pgControlInfo: => {PgControlInfo}
|
||||
P00 DEBUG: storage/storage::storageNew: (path: {"[TEST_PATH]/db-master/repo"}, param.modeFile: 0000, param.modePath: 0000, param.write: false, param.pathExpressionFunction: (function *))
|
||||
P00 DEBUG: storage/storage::storageNew: => {path: "[TEST_PATH]/db-master/repo", write: false}
|
||||
P00 DEBUG: storage/driver/posix/storage::storageDriverPosixNew: (path: {"[TEST_PATH]/db-master/repo"}, modeFile: 0640, modePath: 0750, write: false, pathExpressionFunction: (function *))
|
||||
P00 DEBUG: storage/driver/posix/storage::storageDriverPosixNew: => {StorageDriverPosix}
|
||||
P00 DEBUG: info/infoArchive::infoArchiveNew: (fileName: {"<REPO:ARCHIVE>/archive.info"}, ignoreMissing: false)
|
||||
P00 DEBUG: info/infoPg::infoPgNew: (fileName: {"<REPO:ARCHIVE>/archive.info"})
|
||||
P00 DEBUG: info/info::infoNew: (fileName: {"<REPO:ARCHIVE>/archive.info"})
|
||||
@ -141,8 +141,8 @@ P00 DEBUG: info/infoPg::infoPgAdd: (this: {InfoPg}, infoPgData: {id: 1, ver
|
||||
P00 DEBUG: info/infoPg::infoPgAdd: => 0
|
||||
P00 DEBUG: info/infoPg::infoPgNew: => {InfoPg}
|
||||
P00 DEBUG: info/infoArchive::infoArchiveNew: => {InfoArchive}
|
||||
P00 DEBUG: command/archive/common::walSegmentFind: (storage: {path: "[TEST_PATH]/db-master/repo", write: false}, archiveId: {"9.4-1"}, walSegment: {"700000007000000070000000"})
|
||||
P00 DEBUG: storage/storage::storageList: (this: {path: "[TEST_PATH]/db-master/repo", write: false}, pathExp: {"<REPO:ARCHIVE>/9.4-1/7000000070000000"}, param.errorOnMissing: false, param.expression: {"^700000007000000070000000-[0-f]{40}(\.gz){0,1}$"})
|
||||
P00 DEBUG: command/archive/common::walSegmentFind: (storage: {type: posix, path: {"[TEST_PATH]/db-master/repo"}, write: false}, archiveId: {"9.4-1"}, walSegment: {"700000007000000070000000"})
|
||||
P00 DEBUG: storage/storage::storageList: (this: {type: posix, path: {"[TEST_PATH]/db-master/repo"}, write: false}, pathExp: {"<REPO:ARCHIVE>/9.4-1/7000000070000000"}, param.errorOnMissing: false, param.expression: {"^700000007000000070000000-[0-f]{40}(\.gz){0,1}$"})
|
||||
P00 DEBUG: storage/storage::storageList: => null
|
||||
P00 DEBUG: command/archive/common::walSegmentFind: => null
|
||||
P00 DEBUG: command/archive/get/file::archiveGetCheck: => null
|
||||
@ -163,18 +163,18 @@ P00 DEBUG: config/load::cfgLoad: => void
|
||||
P00 DEBUG: command/archive/get/get::cmdArchiveGet: (void)
|
||||
P00 DEBUG: command/archive/get/file::archiveGetFile: (archiveFile: {"000000010000000100000001"}, walDestination: {"[TEST_PATH]/db-master/db/base/pg_xlog/RECOVERYXLOG"})
|
||||
P00 DEBUG: command/control/control::lockStopTest: (void)
|
||||
P00 DEBUG: storage/storage::storageExists: (this: {path: "/", write: false}, pathExp: {"[TEST_PATH]/db-master/lock/db.stop"}, param.timeout: 0)
|
||||
P00 DEBUG: storage/storage::storageExists: (this: {type: posix, path: {"/"}, write: false}, pathExp: {"[TEST_PATH]/db-master/lock/db.stop"}, param.timeout: 0)
|
||||
P00 DEBUG: storage/storage::storageExists: => false
|
||||
P00 DEBUG: storage/storage::storageExists: (this: {path: "/", write: false}, pathExp: {"[TEST_PATH]/db-master/lock/all.stop"}, param.timeout: 0)
|
||||
P00 DEBUG: storage/storage::storageExists: (this: {type: posix, path: {"/"}, write: false}, pathExp: {"[TEST_PATH]/db-master/lock/all.stop"}, param.timeout: 0)
|
||||
P00 DEBUG: storage/storage::storageExists: => false
|
||||
P00 DEBUG: command/control/control::lockStopTest: => void
|
||||
P00 DEBUG: command/archive/get/file::archiveGetCheck: (archiveFile: {"000000010000000100000001"})
|
||||
P00 DEBUG: postgres/info::pgControlInfo: (pgPath: {"[TEST_PATH]/db-master/db/base"})
|
||||
P00 DEBUG: storage/storage::storageGet: (file: {StorageFileRead}, param.exactSize: 512)
|
||||
P00 DEBUG: storage/storage::storageGet: (file: {type: posix, name: {"[TEST_PATH]/db-master/db/base/global/pg_control"}, ignoreMissing: false}, param.exactSize: 512)
|
||||
P00 DEBUG: storage/storage::storageGet: => {used: 512, size: 512}
|
||||
P00 DEBUG: postgres/info::pgControlInfo: => {PgControlInfo}
|
||||
P00 DEBUG: storage/storage::storageNew: (path: {"[TEST_PATH]/db-master/repo"}, param.modeFile: 0000, param.modePath: 0000, param.write: false, param.pathExpressionFunction: (function *))
|
||||
P00 DEBUG: storage/storage::storageNew: => {path: "[TEST_PATH]/db-master/repo", write: false}
|
||||
P00 DEBUG: storage/driver/posix/storage::storageDriverPosixNew: (path: {"[TEST_PATH]/db-master/repo"}, modeFile: 0640, modePath: 0750, write: false, pathExpressionFunction: (function *))
|
||||
P00 DEBUG: storage/driver/posix/storage::storageDriverPosixNew: => {StorageDriverPosix}
|
||||
P00 DEBUG: info/infoArchive::infoArchiveNew: (fileName: {"<REPO:ARCHIVE>/archive.info"}, ignoreMissing: false)
|
||||
P00 DEBUG: info/infoPg::infoPgNew: (fileName: {"<REPO:ARCHIVE>/archive.info"})
|
||||
P00 DEBUG: info/info::infoNew: (fileName: {"<REPO:ARCHIVE>/archive.info"})
|
||||
@ -185,16 +185,16 @@ P00 DEBUG: info/infoPg::infoPgAdd: (this: {InfoPg}, infoPgData: {id: 1, ver
|
||||
P00 DEBUG: info/infoPg::infoPgAdd: => 0
|
||||
P00 DEBUG: info/infoPg::infoPgNew: => {InfoPg}
|
||||
P00 DEBUG: info/infoArchive::infoArchiveNew: => {InfoArchive}
|
||||
P00 DEBUG: command/archive/common::walSegmentFind: (storage: {path: "[TEST_PATH]/db-master/repo", write: false}, archiveId: {"9.4-1"}, walSegment: {"000000010000000100000001"})
|
||||
P00 DEBUG: storage/storage::storageList: (this: {path: "[TEST_PATH]/db-master/repo", write: false}, pathExp: {"<REPO:ARCHIVE>/9.4-1/0000000100000001"}, param.errorOnMissing: false, param.expression: {"^000000010000000100000001-[0-f]{40}(\.gz){0,1}$"})
|
||||
P00 DEBUG: command/archive/common::walSegmentFind: (storage: {type: posix, path: {"[TEST_PATH]/db-master/repo"}, write: false}, archiveId: {"9.4-1"}, walSegment: {"000000010000000100000001"})
|
||||
P00 DEBUG: storage/storage::storageList: (this: {type: posix, path: {"[TEST_PATH]/db-master/repo"}, write: false}, pathExp: {"<REPO:ARCHIVE>/9.4-1/0000000100000001"}, param.errorOnMissing: false, param.expression: {"^000000010000000100000001-[0-f]{40}(\.gz){0,1}$"})
|
||||
P00 DEBUG: storage/storage::storageList: => {["000000010000000100000001-ceb021d9bb41f220511e413b095d2b0d89fec113.gz"]}
|
||||
P00 DEBUG: command/archive/common::walSegmentFind: => {"000000010000000100000001-ceb021d9bb41f220511e413b095d2b0d89fec113.gz"}
|
||||
P00 DEBUG: command/archive/get/file::archiveGetCheck: => {"9.4-1/0000000100000001/000000010000000100000001-ceb021d9bb41f220511e413b095d2b0d89fec113.gz"}
|
||||
P00 DEBUG: storage/storage::storageNew: (path: {"/"}, param.modeFile: 0000, param.modePath: 0000, param.write: true, param.pathExpressionFunction: null)
|
||||
P00 DEBUG: storage/storage::storageNew: => {path: "/", write: true}
|
||||
P00 DEBUG: storage/driver/posix/storage::storageDriverPosixNew: (path: {"/"}, modeFile: 0640, modePath: 0750, write: true, pathExpressionFunction: null)
|
||||
P00 DEBUG: storage/driver/posix/storage::storageDriverPosixNew: => {StorageDriverPosix}
|
||||
P00 DEBUG: common/io/filter/group::ioFilterGroupAdd: (this: {inputSame: false, done: true}, filter: {IoFilter})
|
||||
P00 DEBUG: common/io/filter/group::ioFilterGroupAdd: => void
|
||||
P00 DEBUG: storage/storage::storageCopy: (source: {StorageFileRead}, destination: {StorageFileWrite})
|
||||
P00 DEBUG: storage/storage::storageCopy: (source: {type: posix, name: {"[TEST_PATH]/db-master/repo/archive/db/9.4-1/0000000100000001/000000010000000100000001-ceb021d9bb41f220511e413b095d2b0d89fec113.gz"}, ignoreMissing: false}, destination: {type: posix, name: {"[TEST_PATH]/db-master/db/base/pg_xlog/RECOVERYXLOG"}, modeFile: 0640, modePath: 0750, createPath: false, syncFile: false, syncPath: false, atomic: false})
|
||||
P00 DEBUG: storage/storage::storageCopy: => true
|
||||
P00 DEBUG: command/archive/get/file::archiveGetFile: => 0
|
||||
P00 INFO: found 000000010000000100000001 in the archive
|
||||
|
@ -536,18 +536,18 @@ P00 DEBUG: config/load::cfgLoad: => void
|
||||
P00 DEBUG: command/archive/get/get::cmdArchiveGet: (void)
|
||||
P00 DEBUG: command/archive/get/file::archiveGetFile: (archiveFile: {"000000010000000100000002"}, walDestination: {"[TEST_PATH]/db-master/db/base/pg_xlog/RECOVERYXLOG"})
|
||||
P00 DEBUG: command/control/control::lockStopTest: (void)
|
||||
P00 DEBUG: storage/storage::storageExists: (this: {path: "/", write: false}, pathExp: {"[TEST_PATH]/db-master/lock/db.stop"}, param.timeout: 0)
|
||||
P00 DEBUG: storage/storage::storageExists: (this: {type: posix, path: {"/"}, write: false}, pathExp: {"[TEST_PATH]/db-master/lock/db.stop"}, param.timeout: 0)
|
||||
P00 DEBUG: storage/storage::storageExists: => false
|
||||
P00 DEBUG: storage/storage::storageExists: (this: {path: "/", write: false}, pathExp: {"[TEST_PATH]/db-master/lock/all.stop"}, param.timeout: 0)
|
||||
P00 DEBUG: storage/storage::storageExists: (this: {type: posix, path: {"/"}, write: false}, pathExp: {"[TEST_PATH]/db-master/lock/all.stop"}, param.timeout: 0)
|
||||
P00 DEBUG: storage/storage::storageExists: => false
|
||||
P00 DEBUG: command/control/control::lockStopTest: => void
|
||||
P00 DEBUG: command/archive/get/file::archiveGetCheck: (archiveFile: {"000000010000000100000002"})
|
||||
P00 DEBUG: postgres/info::pgControlInfo: (pgPath: {"[TEST_PATH]/db-master/db/base"})
|
||||
P00 DEBUG: storage/storage::storageGet: (file: {StorageFileRead}, param.exactSize: 512)
|
||||
P00 DEBUG: storage/storage::storageGet: (file: {type: posix, name: {"[TEST_PATH]/db-master/db/base/global/pg_control"}, ignoreMissing: false}, param.exactSize: 512)
|
||||
P00 DEBUG: storage/storage::storageGet: => {used: 512, size: 512}
|
||||
P00 DEBUG: postgres/info::pgControlInfo: => {PgControlInfo}
|
||||
P00 DEBUG: storage/storage::storageNew: (path: {"[TEST_PATH]/db-master/repo"}, param.modeFile: 0000, param.modePath: 0000, param.write: false, param.pathExpressionFunction: (function *))
|
||||
P00 DEBUG: storage/storage::storageNew: => {path: "[TEST_PATH]/db-master/repo", write: false}
|
||||
P00 DEBUG: storage/driver/posix/storage::storageDriverPosixNew: (path: {"[TEST_PATH]/db-master/repo"}, modeFile: 0640, modePath: 0750, write: false, pathExpressionFunction: (function *))
|
||||
P00 DEBUG: storage/driver/posix/storage::storageDriverPosixNew: => {StorageDriverPosix}
|
||||
P00 DEBUG: info/infoArchive::infoArchiveNew: (fileName: {"<REPO:ARCHIVE>/archive.info"}, ignoreMissing: false)
|
||||
P00 DEBUG: info/infoPg::infoPgNew: (fileName: {"<REPO:ARCHIVE>/archive.info"})
|
||||
P00 DEBUG: info/info::infoNew: (fileName: {"<REPO:ARCHIVE>/archive.info"})
|
||||
@ -560,16 +560,16 @@ P00 DEBUG: info/infoPg::infoPgAdd: (this: {InfoPg}, infoPgData: {id: 1, ver
|
||||
P00 DEBUG: info/infoPg::infoPgAdd: => 1
|
||||
P00 DEBUG: info/infoPg::infoPgNew: => {InfoPg}
|
||||
P00 DEBUG: info/infoArchive::infoArchiveNew: => {InfoArchive}
|
||||
P00 DEBUG: command/archive/common::walSegmentFind: (storage: {path: "[TEST_PATH]/db-master/repo", write: false}, archiveId: {"9.3-1"}, walSegment: {"000000010000000100000002"})
|
||||
P00 DEBUG: storage/storage::storageList: (this: {path: "[TEST_PATH]/db-master/repo", write: false}, pathExp: {"<REPO:ARCHIVE>/9.3-1/0000000100000001"}, param.errorOnMissing: false, param.expression: {"^000000010000000100000002-[0-f]{40}(\.gz){0,1}$"})
|
||||
P00 DEBUG: command/archive/common::walSegmentFind: (storage: {type: posix, path: {"[TEST_PATH]/db-master/repo"}, write: false}, archiveId: {"9.3-1"}, walSegment: {"000000010000000100000002"})
|
||||
P00 DEBUG: storage/storage::storageList: (this: {type: posix, path: {"[TEST_PATH]/db-master/repo"}, write: false}, pathExp: {"<REPO:ARCHIVE>/9.3-1/0000000100000001"}, param.errorOnMissing: false, param.expression: {"^000000010000000100000002-[0-f]{40}(\.gz){0,1}$"})
|
||||
P00 DEBUG: storage/storage::storageList: => {["000000010000000100000002-488ba4b8b98acc510bce86b8f16e3c1ed9886a29.gz"]}
|
||||
P00 DEBUG: command/archive/common::walSegmentFind: => {"000000010000000100000002-488ba4b8b98acc510bce86b8f16e3c1ed9886a29.gz"}
|
||||
P00 DEBUG: command/archive/get/file::archiveGetCheck: => {"9.3-1/0000000100000001/000000010000000100000002-488ba4b8b98acc510bce86b8f16e3c1ed9886a29.gz"}
|
||||
P00 DEBUG: storage/storage::storageNew: (path: {"/"}, param.modeFile: 0000, param.modePath: 0000, param.write: true, param.pathExpressionFunction: null)
|
||||
P00 DEBUG: storage/storage::storageNew: => {path: "/", write: true}
|
||||
P00 DEBUG: storage/driver/posix/storage::storageDriverPosixNew: (path: {"/"}, modeFile: 0640, modePath: 0750, write: true, pathExpressionFunction: null)
|
||||
P00 DEBUG: storage/driver/posix/storage::storageDriverPosixNew: => {StorageDriverPosix}
|
||||
P00 DEBUG: common/io/filter/group::ioFilterGroupAdd: (this: {inputSame: false, done: true}, filter: {IoFilter})
|
||||
P00 DEBUG: common/io/filter/group::ioFilterGroupAdd: => void
|
||||
P00 DEBUG: storage/storage::storageCopy: (source: {StorageFileRead}, destination: {StorageFileWrite})
|
||||
P00 DEBUG: storage/storage::storageCopy: (source: {type: posix, name: {"[TEST_PATH]/db-master/repo/archive/db/9.3-1/0000000100000001/000000010000000100000002-488ba4b8b98acc510bce86b8f16e3c1ed9886a29.gz"}, ignoreMissing: false}, destination: {type: posix, name: {"[TEST_PATH]/db-master/db/base/pg_xlog/RECOVERYXLOG"}, modeFile: 0640, modePath: 0750, createPath: false, syncFile: false, syncPath: false, atomic: false})
|
||||
P00 DEBUG: storage/storage::storageCopy: => true
|
||||
P00 DEBUG: command/archive/get/file::archiveGetFile: => 0
|
||||
P00 INFO: found 000000010000000100000002 in the archive
|
||||
|
@ -3,9 +3,10 @@ Test Archive Common
|
||||
***********************************************************************************************************************************/
|
||||
#include <unistd.h>
|
||||
|
||||
#include "common/harnessConfig.h"
|
||||
|
||||
#include "protocol/storage/helper.h"
|
||||
#include "storage/driver/posix/storage.h"
|
||||
|
||||
#include "common/harnessConfig.h"
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Test Run
|
||||
@ -16,7 +17,8 @@ testRun(void)
|
||||
FUNCTION_HARNESS_VOID();
|
||||
|
||||
// Create default storage object for testing
|
||||
Storage *storageTest = storageNewP(strNew(testPath()), .write = true);
|
||||
Storage *storageTest = storageDriverPosixInterface(
|
||||
storageDriverPosixNew(strNew(testPath()), STORAGE_MODE_FILE_DEFAULT, STORAGE_MODE_PATH_DEFAULT, true, NULL));
|
||||
|
||||
// *****************************************************************************************************************************
|
||||
if (testBegin("archiveAsyncStatus()"))
|
||||
|
@ -7,6 +7,7 @@ Test Archive Get Command
|
||||
#include "common/harnessConfig.h"
|
||||
#include "common/harnessFork.h"
|
||||
#include "compress/gzipCompress.h"
|
||||
#include "storage/driver/posix/storage.h"
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Create test pg_control file
|
||||
@ -29,7 +30,8 @@ testRun(void)
|
||||
{
|
||||
FUNCTION_HARNESS_VOID();
|
||||
|
||||
Storage *storageTest = storageNewP(strNew(testPath()), .write = true);
|
||||
Storage *storageTest = storageDriverPosixInterface(
|
||||
storageDriverPosixNew(strNew(testPath()), STORAGE_MODE_FILE_DEFAULT, STORAGE_MODE_PATH_DEFAULT, true, NULL));
|
||||
|
||||
// *****************************************************************************************************************************
|
||||
if (testBegin("archiveGetCheck()"))
|
||||
|
@ -1,6 +1,8 @@
|
||||
/***********************************************************************************************************************************
|
||||
Test Archive Push Command
|
||||
***********************************************************************************************************************************/
|
||||
#include "storage/driver/posix/storage.h"
|
||||
|
||||
#include "common/harnessConfig.h"
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
@ -12,7 +14,8 @@ testRun(void)
|
||||
FUNCTION_HARNESS_VOID();
|
||||
|
||||
// Create default storage object for testing
|
||||
Storage *storageTest = storageNewP(strNew(testPath()), .write = true);
|
||||
Storage *storageTest = storageDriverPosixInterface(
|
||||
storageDriverPosixNew(strNew(testPath()), STORAGE_MODE_FILE_DEFAULT, STORAGE_MODE_PATH_DEFAULT, true, NULL));
|
||||
|
||||
// *****************************************************************************************************************************
|
||||
if (testBegin("cmdArchivePush()"))
|
||||
|
@ -2,6 +2,7 @@
|
||||
Test Command Control
|
||||
***********************************************************************************************************************************/
|
||||
#include "common/harnessConfig.h"
|
||||
#include "storage/driver/posix/storage.h"
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Test Run
|
||||
@ -12,7 +13,8 @@ testRun(void)
|
||||
FUNCTION_HARNESS_VOID();
|
||||
|
||||
// Create default storage object for testing
|
||||
Storage *storageTest = storageNewP(strNew(testPath()), .write = true);
|
||||
Storage *storageTest = storageDriverPosixInterface(
|
||||
storageDriverPosixNew(strNew(testPath()), STORAGE_MODE_FILE_DEFAULT, STORAGE_MODE_PATH_DEFAULT, true, NULL));
|
||||
|
||||
// *****************************************************************************************************************************
|
||||
if (testBegin("lockStopFileName()"))
|
||||
|
@ -2,6 +2,7 @@
|
||||
Test Lock Handler
|
||||
***********************************************************************************************************************************/
|
||||
#include "common/time.h"
|
||||
#include "storage/driver/posix/storage.h"
|
||||
|
||||
#include "common/harnessFork.h"
|
||||
|
||||
@ -14,7 +15,8 @@ testRun(void)
|
||||
FUNCTION_HARNESS_VOID();
|
||||
|
||||
// Create default storage object for testing
|
||||
Storage *storageTest = storageNewP(strNew(testPath()), .write = true);
|
||||
Storage *storageTest = storageDriverPosixInterface(
|
||||
storageDriverPosixNew(strNew(testPath()), STORAGE_MODE_FILE_DEFAULT, STORAGE_MODE_PATH_DEFAULT, true, NULL));
|
||||
|
||||
// *****************************************************************************************************************************
|
||||
if (testBegin("lockAcquireFile() and lockReleaseFile()"))
|
||||
|
@ -2,6 +2,7 @@
|
||||
Test Help Command
|
||||
***********************************************************************************************************************************/
|
||||
#include "config/parse.h"
|
||||
#include "storage/driver/posix/storage.h"
|
||||
#include "storage/storage.h"
|
||||
#include "version.h"
|
||||
|
||||
@ -353,7 +354,8 @@ testRun(void)
|
||||
// Restore normal stdout
|
||||
dup2(stdoutSave, STDOUT_FILENO);
|
||||
|
||||
Storage *storage = storageNewNP(strNew(testPath()));
|
||||
Storage *storage = storageDriverPosixInterface(
|
||||
storageDriverPosixNew(strNew(testPath()), STORAGE_MODE_FILE_DEFAULT, STORAGE_MODE_PATH_DEFAULT, false, NULL));
|
||||
TEST_RESULT_STR(strPtr(strNewBuf(storageGetNP(storageNewReadNP(storage, stdoutFile)))), generalHelp, " check text");
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,8 @@ testRun(void)
|
||||
|
||||
// Remove the copy and store only the main info file. One is required.
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
storageMoveNP(storageNewReadNP(storageLocal(), fileNameCopy), storageNewWriteNP(storageLocalWrite(), fileName));
|
||||
storageMoveNP(
|
||||
storageLocal(), storageNewReadNP(storageLocal(), fileNameCopy), storageNewWriteNP(storageLocalWrite(), fileName));
|
||||
|
||||
// Only main info exists and is required
|
||||
TEST_ASSIGN(info, infoNew(storageLocal(), fileName), "infoNew() - load file");
|
||||
|
@ -1,6 +1,7 @@
|
||||
/***********************************************************************************************************************************
|
||||
Test PostgreSQL Info
|
||||
***********************************************************************************************************************************/
|
||||
#include "storage/driver/posix/storage.h"
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Test Run
|
||||
@ -10,7 +11,8 @@ testRun(void)
|
||||
{
|
||||
FUNCTION_HARNESS_VOID();
|
||||
|
||||
Storage *storageTest = storageNewP(strNew(testPath()), .write = true);
|
||||
Storage *storageTest = storageDriverPosixInterface(
|
||||
storageDriverPosixNew(strNew(testPath()), STORAGE_MODE_FILE_DEFAULT, STORAGE_MODE_PATH_DEFAULT, true, NULL));
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------------------------------
|
||||
if (testBegin("pgVersionMap()"))
|
||||
|
@ -13,7 +13,8 @@ testRun(void)
|
||||
FUNCTION_HARNESS_VOID();
|
||||
|
||||
// Create default storage object for testing
|
||||
Storage *storageTest = storageNewP(strNew(testPath()), .write = true);
|
||||
Storage *storageTest = storageDriverPosixInterface(
|
||||
storageDriverPosixNew(strNew(testPath()), STORAGE_MODE_FILE_DEFAULT, STORAGE_MODE_PATH_DEFAULT, true, NULL));
|
||||
ioBufferSizeSet(2);
|
||||
|
||||
// Create a directory and file that cannot be accessed to test permissions errors
|
||||
@ -27,7 +28,7 @@ testRun(void)
|
||||
0, "create no perm path/file");
|
||||
|
||||
// *****************************************************************************************************************************
|
||||
if (testBegin("StorageFile"))
|
||||
if (testBegin("storageDriverPosixFile*()"))
|
||||
{
|
||||
TEST_ERROR_FMT(
|
||||
storageDriverPosixFileOpen(pathNoPerm, O_RDONLY, 0, false, false, "test"), PathOpenError,
|
||||
@ -74,7 +75,7 @@ testRun(void)
|
||||
StorageFileRead *file = NULL;
|
||||
|
||||
TEST_ASSIGN(file, storageNewReadP(storageTest, fileNoPerm, .ignoreMissing = true), "new read file");
|
||||
TEST_RESULT_PTR(storageFileReadDriver(file), file->fileDriver, " check file driver");
|
||||
TEST_RESULT_PTR(storageFileReadDriver(file), file->driver, " check driver");
|
||||
TEST_RESULT_BOOL(storageFileReadIgnoreMissing(file), true, " check ignore missing");
|
||||
TEST_RESULT_STR(strPtr(storageFileReadName(file)), strPtr(fileNoPerm), " check name");
|
||||
|
||||
@ -105,7 +106,7 @@ testRun(void)
|
||||
TEST_RESULT_BOOL(ioReadOpen(storageFileReadIo(file)), true, " open file");
|
||||
|
||||
// Close the file handle so operations will fail
|
||||
close(file->fileDriver->handle);
|
||||
close(((StorageDriverPosixFileRead *)file->driver)->handle);
|
||||
|
||||
TEST_ERROR_FMT(
|
||||
ioRead(storageFileReadIo(file), outBuffer), FileReadError,
|
||||
@ -115,7 +116,7 @@ testRun(void)
|
||||
"unable to close '%s': [9] Bad file descriptor", strPtr(fileName));
|
||||
|
||||
// Set file handle to -1 so the close on free with not fail
|
||||
file->fileDriver->handle = -1;
|
||||
((StorageDriverPosixFileRead *)file->driver)->handle = -1;
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
Buffer *buffer = bufNew(0);
|
||||
@ -128,6 +129,7 @@ testRun(void)
|
||||
|
||||
TEST_RESULT_BOOL(ioReadOpen(storageFileReadIo(file)), true, " open file");
|
||||
TEST_RESULT_STR(strPtr(storageFileReadName(file)), strPtr(fileName), " check file name");
|
||||
TEST_RESULT_STR(strPtr(storageFileReadType(file)), "posix", " check file type");
|
||||
|
||||
TEST_RESULT_VOID(ioRead(storageFileReadIo(file), outBuffer), " load data");
|
||||
bufCat(buffer, outBuffer);
|
||||
@ -161,9 +163,9 @@ testRun(void)
|
||||
|
||||
TEST_RESULT_VOID(ioReadClose(storageFileReadIo(file)), " close file");
|
||||
|
||||
TEST_RESULT_VOID(storageFileReadFree(file), " free file");
|
||||
TEST_RESULT_VOID(storageFileReadFree(storageNewReadNP(storageTest, fileName)), " free file");
|
||||
TEST_RESULT_VOID(storageFileReadFree(NULL), " free null file");
|
||||
TEST_RESULT_VOID(storageDriverPosixFileReadFree(NULL), " free null file");
|
||||
TEST_RESULT_VOID(storageDriverPosixFileReadFree(NULL), " free null posix file");
|
||||
|
||||
TEST_RESULT_VOID(storageFileReadMove(NULL, memContextTop()), " move null file");
|
||||
}
|
||||
@ -182,11 +184,10 @@ testRun(void)
|
||||
|
||||
TEST_RESULT_BOOL(storageFileWriteAtomic(file), false, " check atomic");
|
||||
TEST_RESULT_BOOL(storageFileWriteCreatePath(file), false, " check create path");
|
||||
TEST_RESULT_PTR(storageFileWriteFileDriver(file), file->fileDriver, " check file driver");
|
||||
TEST_RESULT_PTR(storageFileWriteFileDriver(file), file->driver, " check file driver");
|
||||
TEST_RESULT_INT(storageFileWriteModeFile(file), 0444, " check mode file");
|
||||
TEST_RESULT_INT(storageFileWriteModePath(file), 0555, " check mode path");
|
||||
TEST_RESULT_STR(strPtr(storageFileWriteName(file)), strPtr(fileNoPerm), " check name");
|
||||
TEST_RESULT_STR(strPtr(storageFileWritePath(file)), strPtr(strPath(fileNoPerm)), " check path");
|
||||
TEST_RESULT_BOOL(storageFileWriteSyncPath(file), false, " check sync path");
|
||||
TEST_RESULT_BOOL(storageFileWriteSyncFile(file), false, " check sync file");
|
||||
|
||||
@ -214,7 +215,7 @@ testRun(void)
|
||||
TEST_RESULT_VOID(ioWriteOpen(storageFileWriteIo(file)), " open file");
|
||||
|
||||
// Close the file handle so operations will fail
|
||||
close(file->fileDriver->handle);
|
||||
close(((StorageDriverPosixFileWrite *)file->driver)->handle);
|
||||
storageRemoveP(storageTest, fileTmp, .errorOnMissing = true);
|
||||
|
||||
TEST_ERROR_FMT(
|
||||
@ -225,18 +226,19 @@ testRun(void)
|
||||
"unable to sync '%s': [9] Bad file descriptor", strPtr(fileName));
|
||||
|
||||
// Disable file sync so the close can be reached
|
||||
file->fileDriver->syncFile = false;
|
||||
((StorageDriverPosixFileWrite *)file->driver)->syncFile = false;
|
||||
|
||||
TEST_ERROR_FMT(
|
||||
storageDriverPosixFileWriteClose(storageFileWriteFileDriver(file)), FileCloseError,
|
||||
"unable to close '%s': [9] Bad file descriptor", strPtr(fileName));
|
||||
|
||||
// Set file handle to -1 so the close on free with not fail
|
||||
file->fileDriver->handle = -1;
|
||||
((StorageDriverPosixFileWrite *)file->driver)->handle = -1;
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
TEST_ASSIGN(file, storageNewWriteNP(storageTest, fileName), "new write file");
|
||||
TEST_RESULT_STR(strPtr(storageFileWriteName(file)), strPtr(fileName), " check file name");
|
||||
TEST_RESULT_STR(strPtr(storageFileWriteType(file)), "posix", " check file type");
|
||||
TEST_RESULT_VOID(ioWriteOpen(storageFileWriteIo(file)), " open file");
|
||||
|
||||
// Rename the file back to original name from tmp -- this will cause the rename in close to fail
|
||||
@ -246,7 +248,7 @@ testRun(void)
|
||||
"unable to move '%s' to '%s': [2] No such file or directory", strPtr(fileTmp), strPtr(fileName));
|
||||
|
||||
// Set file handle to -1 so the close on free with not fail
|
||||
file->fileDriver->handle = -1;
|
||||
((StorageDriverPosixFileWrite *)file->driver)->handle = -1;
|
||||
|
||||
storageRemoveP(storageTest, fileName, .errorOnMissing = true);
|
||||
|
||||
@ -262,7 +264,7 @@ testRun(void)
|
||||
TEST_RESULT_VOID(ioWrite(storageFileWriteIo(file), bufNew(0)), " write zero buffer to file");
|
||||
TEST_RESULT_VOID(ioWrite(storageFileWriteIo(file), buffer), " write to file");
|
||||
TEST_RESULT_VOID(ioWriteClose(storageFileWriteIo(file)), " close file");
|
||||
TEST_RESULT_VOID(storageFileWriteFree(file), " free file");
|
||||
TEST_RESULT_VOID(storageFileWriteFree(storageNewWriteNP(storageTest, fileName)), " free file");
|
||||
TEST_RESULT_VOID(storageFileWriteFree(NULL), " free null file");
|
||||
TEST_RESULT_VOID(storageDriverPosixFileWriteFree(NULL), " free null posix file");
|
||||
TEST_RESULT_VOID(storageFileWriteMove(NULL, memContextTop()), " move null file");
|
||||
|
@ -33,8 +33,10 @@ testRun(void)
|
||||
FUNCTION_HARNESS_VOID();
|
||||
|
||||
// Create default storage object for testing
|
||||
Storage *storageTest = storageNewP(strNew(testPath()), .write = true);
|
||||
Storage *storageTmp = storageNewP(strNew("/tmp"), .write = true);
|
||||
Storage *storageTest = storageDriverPosixInterface(
|
||||
storageDriverPosixNew(strNew(testPath()), STORAGE_MODE_FILE_DEFAULT, STORAGE_MODE_PATH_DEFAULT, true, NULL));
|
||||
Storage *storageTmp = storageDriverPosixInterface(
|
||||
storageDriverPosixNew(strNew("/tmp"), 0, 0, true, NULL));
|
||||
ioBufferSizeSet(2);
|
||||
|
||||
// Create a directory and file that cannot be accessed to test permissions errors
|
||||
@ -51,10 +53,8 @@ testRun(void)
|
||||
if (testBegin("storageNew() and storageFree()"))
|
||||
{
|
||||
Storage *storageTest = NULL;
|
||||
|
||||
TEST_ERROR(storageNewNP(NULL), AssertError, "function debug assertion 'path != NULL' failed");
|
||||
|
||||
TEST_ASSIGN(storageTest, storageNewNP(strNew("/")), "new storage (defaults)");
|
||||
TEST_ASSIGN(
|
||||
storageTest, storageDriverPosixInterface(storageDriverPosixNew(strNew("/"), 0640, 0750, false, NULL)), "new storage (defaults)");
|
||||
TEST_RESULT_STR(strPtr(storageTest->path), "/", " check path");
|
||||
TEST_RESULT_INT(storageTest->modeFile, 0640, " check file mode");
|
||||
TEST_RESULT_INT(storageTest->modePath, 0750, " check path mode");
|
||||
@ -62,10 +62,7 @@ testRun(void)
|
||||
TEST_RESULT_BOOL(storageTest->pathExpressionFunction == NULL, true, " check expression function is not set");
|
||||
|
||||
TEST_ASSIGN(
|
||||
storageTest,
|
||||
storageNewP(
|
||||
strNew("/path/to"), .modeFile = 0600, .modePath = 0700, .write = true,
|
||||
.pathExpressionFunction = storageTestPathExpression),
|
||||
storageTest, storageDriverPosixInterface(storageDriverPosixNew(strNew("/path/to"), 0600, 0700, true, storageTestPathExpression)),
|
||||
"new storage (non-default)");
|
||||
TEST_RESULT_STR(strPtr(storageTest->path), "/path/to", " check path");
|
||||
TEST_RESULT_INT(storageTest->modeFile, 0600, " check file mode");
|
||||
@ -75,6 +72,9 @@ testRun(void)
|
||||
|
||||
TEST_RESULT_VOID(storageFree(storageTest), "free storage");
|
||||
TEST_RESULT_VOID(storageFree(NULL), "free null storage");
|
||||
|
||||
TEST_RESULT_VOID(storageDriverPosixFree(storageDriverPosixNew(strNew("/"), 0640, 0750, false, NULL)), "free posix storage");
|
||||
TEST_RESULT_VOID(storageDriverPosixFree(NULL), "free null posix storage");
|
||||
}
|
||||
|
||||
// *****************************************************************************************************************************
|
||||
@ -248,14 +248,14 @@ testRun(void)
|
||||
StorageFileWrite *destination = storageNewWriteNP(storageTest, destinationFile);
|
||||
|
||||
TEST_ERROR_FMT(
|
||||
storageMoveNP(source, destination), FileMissingError,
|
||||
storageMoveNP(storageTest, source, destination), FileMissingError,
|
||||
"unable to move missing file '%s': [2] No such file or directory", strPtr(sourceFile));
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
source = storageNewReadNP(storageTest, fileNoPerm);
|
||||
|
||||
TEST_ERROR_FMT(
|
||||
storageMoveNP(source, destination), FileMoveError,
|
||||
storageMoveNP(storageTest, source, destination), FileMoveError,
|
||||
"unable to move '%s' to '%s': [13] Permission denied", strPtr(fileNoPerm), strPtr(destinationFile));
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
@ -266,14 +266,14 @@ testRun(void)
|
||||
destination = storageNewWriteP(storageTest, destinationFile, .noCreatePath = true);
|
||||
|
||||
TEST_ERROR_FMT(
|
||||
storageMoveNP(source, destination), PathMissingError,
|
||||
storageMoveNP(storageTest, source, destination), PathMissingError,
|
||||
"unable to move '%s' to missing path '%s': [2] No such file or directory", strPtr(sourceFile),
|
||||
strPtr(strPath(destinationFile)));
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
destination = storageNewWriteNP(storageTest, destinationFile);
|
||||
|
||||
TEST_RESULT_VOID(storageMoveNP(source, destination), "move file to subpath");
|
||||
TEST_RESULT_VOID(storageMoveNP(storageTest, source, destination), "move file to subpath");
|
||||
TEST_RESULT_BOOL(storageExistsNP(storageTest, sourceFile), false, "check source file not exists");
|
||||
TEST_RESULT_BOOL(storageExistsNP(storageTest, destinationFile), true, "check destination file exists");
|
||||
TEST_RESULT_STR(
|
||||
@ -286,7 +286,7 @@ testRun(void)
|
||||
destinationFile = strNewFmt("%s/sub/destination2.txt", testPath());
|
||||
destination = storageNewWriteNP(storageTest, destinationFile);
|
||||
|
||||
TEST_RESULT_VOID(storageMoveNP(source, destination), "move file to same path");
|
||||
TEST_RESULT_VOID(storageMoveNP(storageTest, source, destination), "move file to same path");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
sourceFile = destinationFile;
|
||||
@ -294,7 +294,7 @@ testRun(void)
|
||||
destinationFile = strNewFmt("%s/source.txt", testPath());
|
||||
destination = storageNewWriteP(storageTest, destinationFile, .noSyncPath = true);
|
||||
|
||||
TEST_RESULT_VOID(storageMoveNP(source, destination), "move file to parent path (no sync)");
|
||||
TEST_RESULT_VOID(storageMoveNP(storageTest, source, destination), "move file to parent path (no sync)");
|
||||
|
||||
// Move across filesystems
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
@ -303,7 +303,7 @@ testRun(void)
|
||||
destinationFile = strNewFmt("/tmp/destination.txt");
|
||||
destination = storageNewWriteNP(storageTmp, destinationFile);
|
||||
|
||||
TEST_RESULT_VOID(storageMoveNP(source, destination), "move file to another filesystem");
|
||||
TEST_RESULT_VOID(storageMoveNP(storageTest, source, destination), "move file to another filesystem");
|
||||
TEST_RESULT_BOOL(storageExistsNP(storageTest, sourceFile), false, "check source file not exists");
|
||||
TEST_RESULT_BOOL(storageExistsNP(storageTmp, destinationFile), true, "check destination file exists");
|
||||
|
||||
@ -314,7 +314,7 @@ testRun(void)
|
||||
destinationFile = strNewFmt("%s/source.txt", testPath());
|
||||
destination = storageNewWriteP(storageTest, destinationFile, .noSyncPath = true);
|
||||
|
||||
TEST_RESULT_VOID(storageMoveNP(source, destination), "move file to another filesystem without path sync");
|
||||
TEST_RESULT_VOID(storageMoveNP(storageTest, source, destination), "move file to another filesystem without path sync");
|
||||
TEST_RESULT_BOOL(storageExistsNP(storageTmp, sourceFile), false, "check source file not exists");
|
||||
TEST_RESULT_BOOL(storageExistsNP(storageTest, destinationFile), true, "check destination file exists");
|
||||
|
||||
@ -326,7 +326,7 @@ testRun(void)
|
||||
{
|
||||
Storage *storageTest = NULL;
|
||||
|
||||
TEST_ASSIGN(storageTest, storageNewNP(strNew("/")), "new storage /");
|
||||
TEST_ASSIGN(storageTest, storageDriverPosixInterface(storageDriverPosixNew(strNew("/"), 0640, 0750, false, NULL)), "new storage /");
|
||||
TEST_RESULT_STR(strPtr(storagePathNP(storageTest, NULL)), "/", " root dir");
|
||||
TEST_RESULT_STR(strPtr(storagePathNP(storageTest, strNew("/"))), "/", " same as root dir");
|
||||
TEST_RESULT_STR(strPtr(storagePathNP(storageTest, strNew("subdir"))), "/subdir", " simple subdir");
|
||||
@ -336,8 +336,7 @@ testRun(void)
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
TEST_ASSIGN(
|
||||
storageTest,
|
||||
storageNewP(strNew("/path/to"), .pathExpressionFunction = storageTestPathExpression),
|
||||
storageTest, storageDriverPosixInterface(storageDriverPosixNew(strNew("/path/to"), 0640, 0750, false, storageTestPathExpression)),
|
||||
"new storage /path/to with expression");
|
||||
TEST_RESULT_STR(strPtr(storagePathNP(storageTest, NULL)), "/path/to", " root dir");
|
||||
TEST_RESULT_STR(strPtr(storagePathNP(storageTest, strNew("/path/to"))), "/path/to", " absolute root dir");
|
||||
@ -530,7 +529,7 @@ testRun(void)
|
||||
// *****************************************************************************************************************************
|
||||
if (testBegin("storagePut() and storageGet()"))
|
||||
{
|
||||
Storage *storageTest = storageNewP(strNew("/"), .write = true);
|
||||
Storage *storageTest = storageDriverPosixInterface(storageDriverPosixNew(strNew("/"), 0640, 0750, true, NULL));
|
||||
|
||||
TEST_ERROR_FMT(
|
||||
storageGetNP(storageNewReadNP(storageTest, strNew(testPath()))), FileReadError,
|
||||
|
Reference in New Issue
Block a user