Manual Pages for UNIX Darwin command on man exchangedata
MyWebUniversity

Manual Pages for UNIX Darwin command on man exchangedata

EXCHANGEDATA(2) BSD System Calls Manual EXCHANGEDATA(2)

NAME

eexxcchhaannggeeddaattaa - atomically exchange data between two files

SYNOPSIS

##iinncclluuddee <>

int eexxcchhaannggeeddaattaa(const char * path1, const char * path2, unsigned long options);

DESCRIPTION

The eexxcchhaannggeeddaattaa() function swaps the contents of the files referenced by path1 and path2 in an atomic fashion. That is, all concurrent processes

will either see the pre-exchanged state or the post-exchanged state; they

can never see the files in an inconsistent state. The data in all forks is swapped in this way. The options parameter lets you control specific aspects of the function's behaviour. Open file descriptors follow the swapped data. Thus, a descriptor that previously referenced path1 will now reference the data that's accessible via path2, and vice versa.

In general, the file attributes (metadata) are not exchanged. Specifi-

cally, the object identifier attributes (that is, the ATTRCMNOBJID and

ATTRCMNOBJPERMANENTID attributes as defined by the getattrlist(2) func-

tion) are not swapped. An exception to this general rule is that the modification time attribute ( ATTRCMNMODTIME ) is swapped.

When combined, these features allow you to implement a 'safe save' func-

tion that does not break references to the file (for example, aliases). You first save the new contents to a temporary file and then exchange the data of the original file and the temporary. Programs that reference the file via an object identifier will continue to reference the original file, but now it has the new data. The path1 and path2 parameters must both reference valid files. All directories listed in the path names leading to these files must be searchable. You must have write access to the files. The options parameter is a bit set that controls the behaviour of eexxcchhaannggeeddaattaa(). The following option bits are defined.

FSOPTNOFOLLOW If this bit is set, eexxcchhaannggeeddaattaa() will not follow a sym-

link if it occurs as the last component of path1 or path2.

RETURN VALUES

Upon successful completion a value of 0 is returned. Otherwise, a value

of -1 is returned and errno is set to indicate the error.

CCOOMMPPAATTIIBBIILLIITTYY Not all volumes support eexxcchhaannggeeddaattaa(). You can test whether a volume

supports eexxcchhaannggeeddaattaa() by using getattrlist(2) to get the volume capa-

bilities attribute ATTRVOLCAPABILITIES, and then testing the VOLCAPINTEXCHANGEDATA flag. EERRRROORRSS eexxcchhaannggeeddaattaa() will fail if: [ENOTSUP] The volume does not support eexxcchhaannggeeddaattaa(). [ENOTDIR] A component of the path prefix is not a directory.

[ENAMETOOLONG] A component of a path name exceeded NAMEMAX charac-

ters, or an entire path name exceeded PATHMAX charac-

ters. [ENOENT] Either file does not exist. [EACCES] Search permission is denied for a component of the path prefix.

[ELOOP] Too many symbolic links were encountered in translat-

ing the pathname. [EFAULT] path1 or path2 points to an invalid address. [EXDEV] path1 and path2 are on different volumes (mounted file systems). [EINVAL] path1 or path2 reference the same file. [EINVAL] You try to exchange something other than a regular file (for example, a directory). [EIO] An I/O error occurred while reading from or writing to the file system.

SEE ALSO

getattrlist(2) HISTORY A eexxcchhaannggeeddaattaa() function call appeared in Darwin 1.3.1 (Mac OS X version 10.0). Darwin December 15, 2003 Darwin




Contact us      |      About us      |      Term of use      |       Copyright © 2000-2019 MyWebUniversity.com ™