Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit070140e

Browse files
committed
Add some functions to fd.c for the convenience of extensions.
For example, if you want to perform an ioctl() on a file descriptoropened through the fd.c routines, there's no way to do that withoutbeing able to get at the underlying fd.KaiGai Kohei
1 parent77a1d1e commit070140e

File tree

2 files changed

+37
-0
lines changed
  • src
    • backend/storage/file
    • include/storage

2 files changed

+37
-0
lines changed

‎src/backend/storage/file/fd.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1577,6 +1577,40 @@ FilePathName(File file)
15771577
returnVfdCache[file].fileName;
15781578
}
15791579

1580+
/*
1581+
* Return the raw file descriptor of an opened file.
1582+
*
1583+
* The returned file descriptor will be valid until the file is closed, but
1584+
* there are a lot of things that can make that happen. So the caller should
1585+
* be careful not to do much of anything else before it finishes using the
1586+
* returned file descriptor.
1587+
*/
1588+
int
1589+
FileGetRawDesc(Filefile)
1590+
{
1591+
Assert(FileIsValid(file));
1592+
returnVfdCache[file].fd;
1593+
}
1594+
1595+
/*
1596+
* FileGetRawFlags - returns the file flags on open(2)
1597+
*/
1598+
int
1599+
FileGetRawFlags(Filefile)
1600+
{
1601+
Assert(FileIsValid(file));
1602+
returnVfdCache[file].fileFlags;
1603+
}
1604+
1605+
/*
1606+
* FileGetRawMode - returns the mode bitmask passed to open(2)
1607+
*/
1608+
int
1609+
FileGetRawMode(Filefile)
1610+
{
1611+
Assert(FileIsValid(file));
1612+
returnVfdCache[file].fileMode;
1613+
}
15801614

15811615
/*
15821616
* Make room for another allocatedDescs[] array entry if needed and possible.

‎src/include/storage/fd.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ extern intFileSync(File file);
7575
externoff_tFileSeek(Filefile,off_toffset,intwhence);
7676
externintFileTruncate(Filefile,off_toffset);
7777
externchar*FilePathName(Filefile);
78+
externintFileGetRawDesc(Filefile);
79+
externintFileGetRawFlags(Filefile);
80+
externintFileGetRawMode(Filefile);
7881

7982
/* Operations that allow use of regular stdio --- USE WITH CAUTION */
8083
externFILE*AllocateFile(constchar*name,constchar*mode);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp