diff options
author | Robert Haas <rhaas@postgresql.org> | 2016-03-08 10:09:50 -0500 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2016-03-08 10:09:50 -0500 |
commit | 070140ee48e8524493f882a278b5ced255b34b65 (patch) | |
tree | 9522e28cf3fd5ebbacba892ccebc014110caf455 /src/backend/storage/file/fd.c | |
parent | 77a1d1e79892a20ed15a67be42b96949b8546bf6 (diff) | |
download | postgresql-070140ee48e8524493f882a278b5ced255b34b65.tar.gz postgresql-070140ee48e8524493f882a278b5ced255b34b65.zip |
Add some functions to fd.c for the convenience of extensions.
For example, if you want to perform an ioctl() on a file descriptor
opened through the fd.c routines, there's no way to do that without
being able to get at the underlying fd.
KaiGai Kohei
Diffstat (limited to 'src/backend/storage/file/fd.c')
-rw-r--r-- | src/backend/storage/file/fd.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/backend/storage/file/fd.c b/src/backend/storage/file/fd.c index 1b301001f09..37a2ae6b643 100644 --- a/src/backend/storage/file/fd.c +++ b/src/backend/storage/file/fd.c @@ -1577,6 +1577,40 @@ FilePathName(File file) return VfdCache[file].fileName; } +/* + * Return the raw file descriptor of an opened file. + * + * The returned file descriptor will be valid until the file is closed, but + * there are a lot of things that can make that happen. So the caller should + * be careful not to do much of anything else before it finishes using the + * returned file descriptor. + */ +int +FileGetRawDesc(File file) +{ + Assert(FileIsValid(file)); + return VfdCache[file].fd; +} + +/* + * FileGetRawFlags - returns the file flags on open(2) + */ +int +FileGetRawFlags(File file) +{ + Assert(FileIsValid(file)); + return VfdCache[file].fileFlags; +} + +/* + * FileGetRawMode - returns the mode bitmask passed to open(2) + */ +int +FileGetRawMode(File file) +{ + Assert(FileIsValid(file)); + return VfdCache[file].fileMode; +} /* * Make room for another allocatedDescs[] array entry if needed and possible. |