fcntl.2 (2011 03)

f
fcntl(2) fcntl(2)
F_SETLK64 Same as F_SETLK, except arg is a pointer to
struct flock64 instead of
struct flock.
F_SETLKW64 Same as F_SETLKW, except arg is a pointer to
struct flock64 instead of
struct flock.
F_GETOWN If fildes refers to a socket,
fcntl() returns the process or process group ID
specified to receive
SIGURG signals when out-of-band data is available. Positive
values indicate a process ID; negative values, other than -1, indicate a process
group ID.
F_SETOWN If fildes refers to a socket,
fcntl() sets the process or process group ID specified
to receive
SIGURG signals when out-of-band data is available, using the value of
the third argument, arg , taken as type
int. Positive values indicate a process ID;
negative values, other than -1, indicate a process group ID.
F_GETTIMES Gets the current times for the file identified by fildes . The
F_GETTIMES third
argument, arg, is a pointer to the
struct attr_timbuf defined in
<sys/fcntl1.h>
(see F_SETTIMES).
F_SETTIMES Sets the current times for the file identified by fildes . To execute the cmd without
error,
F_SETTIMES requires superuser privilege. The F_SETTIMES third argu-
ment, arg, is a pointer to the struct attr_timbuf that is defined in
<sys/fcntl1.h>. The
attr_timbuf structure contains the file’s atime (access
time), mtime (modification time), and ctime (file attribute change time) values.
Here is the definition of the structure:
struct attr_timbuf {
timestruc_t atime; /* access */
timestruc_t mtime; /* data modification */
timestruc_t ctime; /* attribute change */
};
This cmd is useful when it is necessary to save a file’s current time values and then,
after copying or moving the file, set back atime and mtime. Note that ctime is not
restored to the original value; the value of ctime after
F_SETTIMES is file system
dependent.
An example using
F_GETTIMES and F_SETTIMES follows:
# include <sys/fcntl.h>
# include <sys/fcntl1.h>
int
main()
{
int fd ;
struct attr_timbuf tstamp;
/* Create a file*/
fd=open("/var/tmp/foo",O_CREAT|O_RDWR);
/* Use F_GETTIMES to obtain the current times
* of the file
*/
fcntl(fd,F_GETTIMES,&tstamp);
/* Access or modify fd */
/* Now use F_SETTIMES to reinstate the
* original atime and mtime.
*/
fcntl(fd,F_SETTIMES,&tstamp);
}
2 Hewlett-Packard Company 2 HP-UX 11i Version 3: March 2011