ufdhold and ufdrele Kernel Service

Purpose

Increment or decrement a file descriptor reference count.

Syntax

int ufdhold( fd)
int fd;

int ufdrele(fd)
int fd;

Parameter

Item Description
fd Identifies the file descriptor.

Description

Attention: It is extremely important that the calls to ufdhold and ufdrele kernel service are balanced. If a file descriptor is held more times than it is released, the close subroutine on the descriptor never completes. The process hangs and cannot be killed. If the descriptor is released more times than it is held, the system panics.

The ufdhold and ufdrele kernel services increment and decrement a file-descriptor reference count. Together, these kernel services maintain the file descriptor reference count. The ufdhold kernel service increments the count. The ufdrele kernel service decrements the count.

These subroutines are supported for kernel extensions that provide their own file-descriptor-based system calls. This support is required for synchronization with the close subroutine.

When a thread is executing a file-descriptor-based system call, it is necessary that the logical file system (LFS) be aware of it. The LFS uses the count in the file descriptor to monitor the number of system calls currently using any particular file descriptor. To keep the count accurately, any thread using the file descriptor must increment the count before performing any operation and decrement the count when all activity using the file descriptor is completed for that system call.

Execution Environment

These kernel services can be called from the process environment only.

Return Values

Item Description
0 Indicates successful completion.
EBADF Indicates that the fd parameter is not a file descriptor for an open file.