Skip to content

Commit 7ba1cac

Browse files
committed
fix
1 parent 6785c8e commit 7ba1cac

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

src/backend/storage/file/cfs.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,18 +260,20 @@ static void cfs_rc4_init(void)
260260
}
261261
}
262262

263-
void cfs_encrypt(void* block, uint32 offs, uint32 size)
263+
void cfs_encrypt(const char* fname, void* block, uint32 offs, uint32 size)
264264
{
265265
if (cfs_encryption)
266266
{
267+
elog(LOG, "cfs_encrypt, fname = %s, offs = %d, size = %d", fname, offs, size);
267268
cfs_rc4_encrypt_block(block, offs, size);
268269
}
269270
}
270271

271-
void cfs_decrypt(void* block, uint32 offs, uint32 size)
272+
void cfs_decrypt(const char* fname, void* block, uint32 offs, uint32 size)
272273
{
273274
if (cfs_encryption)
274275
{
276+
elog(LOG, "cfs_decrypt, fname = %s, offs = %d, size = %d", fname, offs, size);
275277
cfs_rc4_encrypt_block(block, offs, size);
276278
}
277279
}
@@ -693,7 +695,7 @@ static bool cfs_gc_file(char* map_path)
693695
Assert(res == (off_t)CFS_INODE_OFFS(inode));
694696
rc = cfs_read_file(fd, block, size);
695697
Assert(rc);
696-
cfs_decrypt(block, (off_t)i*BLCKSZ, size);
698+
cfs_decrypt(file_bck_path, block, (off_t)i*BLCKSZ, size);
697699
res = cfs_decompress(decomressedBlock, BLCKSZ, block, size);
698700
if (res != BLCKSZ) {
699701
pg_atomic_fetch_sub_u32(&map->lock, CFS_GC_LOCK); /* release lock */

src/backend/storage/file/fd.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1742,7 +1742,7 @@ FileRead(File file, char *buffer, int amount)
17421742
}
17431743
} while (size != 0);
17441744

1745-
cfs_decrypt(compressedBuffer, VfdCache[file].seekPos, amount);
1745+
cfs_decrypt(VfdCache[file].fileName, compressedBuffer, VfdCache[file].seekPos, amount);
17461746

17471747
returnCode = cfs_decompress(buffer, BLCKSZ, compressedBuffer, amount);
17481748
if (returnCode != BLCKSZ)
@@ -1769,7 +1769,7 @@ FileRead(File file, char *buffer, int amount)
17691769
{
17701770
if (VfdCache[file].fileFlags & PG_COMPRESSION)
17711771
{
1772-
cfs_decrypt(buffer, VfdCache[file].seekPos, amount);
1772+
cfs_decrypt(VfdCache[file].fileName, buffer, VfdCache[file].seekPos, amount);
17731773
}
17741774
VfdCache[file].seekPos += returnCode;
17751775
}
@@ -1877,12 +1877,12 @@ FileWrite(File file, char *buffer, int amount)
18771877
inode = CFS_INODE(compressedSize, pos);
18781878
buffer = compressedBuffer;
18791879
amount = compressedSize;
1880-
cfs_encrypt(buffer, VfdCache[file].seekPos, amount);
1880+
cfs_encrypt(VfdCache[file].fileName, buffer, VfdCache[file].seekPos, amount);
18811881
} else {
18821882
if (cfs_encryption) {
18831883
memcpy(compressedBuffer, buffer, BLCKSZ);
18841884
buffer = compressedBuffer;
1885-
cfs_encrypt(buffer, VfdCache[file].seekPos, amount);
1885+
cfs_encrypt(VfdCache[file].fileName, buffer, VfdCache[file].seekPos, amount);
18861886
}
18871887
if (CFS_INODE_SIZE(inode) != BLCKSZ) {
18881888
pos = cfs_alloc_page(map, CFS_INODE_SIZE(inode), BLCKSZ);

src/include/storage/cfs.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ FileMap* cfs_mmap(int md);
8787
int cfs_munmap(FileMap* map);
8888
void cfs_initialize(void);
8989

90-
void cfs_encrypt(void* block, uint32 offs, uint32 size);
91-
void cfs_decrypt(void* block, uint32 offs, uint32 size);
90+
void cfs_encrypt(const char* fname, void* block, uint32 offs, uint32 size);
91+
void cfs_decrypt(const char* fname, void* block, uint32 offs, uint32 size);
9292

9393
extern CfsState* cfs_state;
9494

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy