Backing Up and Restoring POSIX File Links

A backup application can use the BackupWrite function to recreate POSIX file links.

The BackupRead function does not return POSIX file link data. A backup application must maintain the link information itself. The following pseudocode presents algorithms for backing up and restoring POSIX file link data along with other file information.

PseudoCode Algorithm for Backing Up POSIX File Links

  1. Initialize and empty a list of known links.

  2. While there are more files to back up

  3. Read the disk and get the next file.

  4. Open the file for read.

  5. Call GetFileInformationByHandle() to get the

NumberOfLinks and the FileIndex.

  1. If the NumberOfLinks is greater than 1

  2. Search the list of know links looking for

the same FileIndex.

  1. If a match is NOT found

  2. add the full path of the file and the

FileIndex to the list.

  1. Call BackupRead() to copy all data to

your backup media.

10. Else

  1. Mark the data as a LINK on your backup media

11. store the full path from the list

to your backup media.

  1. Endif

  2. Else

  3. Call BackupRead() to copy all data to your

backup media.

  1. Endif

  2. EndWhile

PseudoCode Algorithm for Restoring POSIX File Links

  1. While there are more files to restore

  2. If the file is a LINK

  3. use the full path which was saved as data

to open the file.

  1. Initialize a WIN32_STREAM_ID structure with

dwStreamId equal to BACKUP_LINK.

  1. Initialize the dwStreamAttributes to 0.

  2. Initialize the dwStreamNameSize to 0.

  3. Initialize a buffer containing the full path

of the file you are restoring in UNICODE.

  1. Initialize the dwStreamSizeHigh to 0.

  2. Initialize the dwStreamSizeLow to the size

in bytes of the buffer containing the full path.

  1. Call BackupWrite() with the WIN32_STREAM_ID

  2. Call BackupWrite() with the buffer containing

the full path.

13. Else

14. Call BackupWrite() with the data stored on

your backup media.

15. Endif

16. EndWhile

Software for developers
Delphi Components
.Net Components
Software for Android Developers
More information resources
MegaDetailed.Net
Unix Manual Pages
Delphi Examples
Databases for Amazon shops developers
Amazon Categories Database
Browse Nodes Database