Sponsored Content
Operating Systems Solaris Difference between hard link and copy command Post 302376459 by masloff on Tuesday 1st of December 2009 11:55:06 AM
Old 12-01-2009
hardlink - is a pointer, name, that points to a data; i.e. it`s just an alternative filename; it has same inode number as the file it was created from

copy - obviously, copy of the data; point to a different direction that file it was copyed from; has different inode number

also difference is in system calls, but that`s somewhat deep-diving into issue
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Differences between hard link and soft link

Hi all! I'd like to know the differences between hard links and soft links. I've already read the ln manpage, but i'm not quite sure of what i understood. Does a hard link sort of copy the file to a new name, give it the same inode number and same rights? What exactly should I do to do this:... (3 Replies)
Discussion started by: penguin-friend
3 Replies

2. UNIX for Dummies Questions & Answers

Why use a hard link

Someone asked me a question today about the difference between a hard link and a soft link. That got me thinking and maybe someone can answer. Why would I ever use a hard link if I can use a soft link instead? (2 Replies)
Discussion started by: dangral
2 Replies

3. UNIX for Dummies Questions & Answers

Difference between hard link and soft link in unix

Hi All, Can any one please explain me what is the difference between hard link and soft link in UNIX. Thanks in advance Raja Chokalingam. (2 Replies)
Discussion started by: RAJACHOKALINGAM
2 Replies

4. UNIX for Dummies Questions & Answers

need some info about symbolic link and hard link

hello folks how y'all doin well i have some questions about symbolic link and hard link hope some one answer me i open terminal and join as root and i wrote ln -s blah blah then i wrote ls i see red file called blah blah but didn't understand what is this can some one explain and... (2 Replies)
Discussion started by: detective linux
2 Replies

5. UNIX for Advanced & Expert Users

Hard link

Hello, In unix, the normal user can't create a hardlink for a directory. why..? Is there any difference between creating a hard link for a file and directory? The super user can create a hard link for directories. Why we cannot create and super user can create.? Please, can anyone help... (1 Reply)
Discussion started by: nagalenoj
1 Replies

6. UNIX for Dummies Questions & Answers

Hard Link vs SOft Link????

Hi PLease let me know the usage of Hard Link vs Soft Link i.e what is the basic difference and what happens when one file is changed or deleted in both the cases??? thanks (3 Replies)
Discussion started by: skyineyes
3 Replies

7. UNIX for Dummies Questions & Answers

Difference between hard link and soft link

Hi Experts, Please help me out to find out difference between a hard link and a soft link. I am new in unix plz help me with some example commands ( for creating such links). Regards S.Kamakshi :) (2 Replies)
Discussion started by: kamakshi s
2 Replies

8. Shell Programming and Scripting

Find Hard Link

Goodmorning everybody. A question: How can i match if a file is an hard link or not? (6 Replies)
Discussion started by: Guccio
6 Replies

9. UNIX for Advanced & Expert Users

Hard Link Examples

Hello, Please move this if I chose the wrong forum category. This question pertains to Unix and Linux I believe. I google the difference between hard and symbolic/soft links and I understand the difference. What I am trying to find is a real example of a hard link being used in a Operating... (11 Replies)
Discussion started by: jaysunn
11 Replies

10. Solaris

difference between copy and mcopy command

Hi, Can anyone explain me the usage of mcopy command and also the difference between copy and mcopy. As per my understanding through both we can copy multiple files or DOS files . Any help on this will be really helpful. (3 Replies)
Discussion started by: rogerben
3 Replies
ARCHIVE_ENTRY_LINKIFY(3)				   BSD Library Functions Manual 				  ARCHIVE_ENTRY_LINKIFY(3)

NAME
archive_entry_linkresolver, archive_entry_linkresolver_new, archive_entry_linkresolver_set_strategy, archive_entry_linkresolver_free, archive_entry_linkify -- hardlink resolver functions LIBRARY
Streaming Archive Library (libarchive, -larchive) SYNOPSIS
#include <archive_entry.h> struct archive_entry_linkresolver * archive_entry_linkresolver_new(void); void archive_entry_linkresolver_set_strategy(struct archive_entry_linkresolver *resolver, int format); void archive_entry_linkresolver_free(struct archive_entry_linkresolver *resolver); void archive_entry_linkify(struct archive_entry_linkresolver *resolver, struct archive_entry **entry, struct archive_entry **sparse); DESCRIPTION
Programs that want to create archives have to deal with hardlinks. Hardlinks are handled in different ways by the archive formats. The basic strategies are: 1. Ignore hardlinks and store the body for each reference (old cpio, zip). 2. Store the body the first time an inode is seen (ustar, pax). 3. Store the body the last time an inode is seen (new cpio). The archive_entry_linkresolver functions help by providing a unified interface and handling the complexity behind the scene. The archive_entry_linkresolver functions assume that archive_entry instances have valid nlinks, inode and device values. The inode and device value is used to match entries. The nlinks value is used to determined if all references have been found and if the internal refer- ences can be recycled. The archive_entry_linkresolver_new() function allocates a new link resolver. The instance can be freed using archive_entry_linkresolver_free(). All deferred entries are flushed and the internal storage is freed. The archive_entry_linkresolver_set_strategy() function selects the optimal hardlink strategy for the given format. The format code can be obtained from archive_format(3). The function can be called more than once, but it is recommended to flush all deferred entries first. The archive_entry_linkify() function is the core of archive_entry_linkresolver. The entry() argument points to the archive_entry that should be written. Depending on the strategy one of the following actions is taken: 1. For the simple archive formats *entry is left unmodified and *sparse is set to NULL. 2. For tar like archive formats, *sparse is set to NULL. If *entry is NULL, no action is taken. If the hardlink count of *entry is larger than 1 and the file type is a regular file or symbolic link, the internal list is searched for a matching inode. If such an inode is found, the link count is decremented and the file size of *entry is set to 0 to notify that no body should be written. If no such inode is found, a copy of the entry is added to the internal cache with a link count reduced by one. 3. For new cpio like archive formats a value for *entry of NULL is used to flush deferred entries. In that case *entry is set to an arbi- trary deferred entry and the entry itself is removed from the internal list. If the internal list is empty, *entry is set to NULL. In either case, *sparse is set to NULL and the function returns. If the hardlink count of *entry is one or the file type is a directory or device, *sparse is set to NULL and no further action is taken. Otherwise, the internal list is searched for a matching inode. If such an inode is not found, the entry is added to the internal list, both *entry and *sparse are set to NULL and the function returns. If such an inode is found, the link count is decremented. If it remains larger than one, the existing entry on the internal list is swapped with *entry after retaining the link count. The existing entry is returned in *entry. If the link count reached one, the new entry is also removed from the internal list and returned in *sparse. Otherwise *sparse is set to NULL. The general usage is therefore: 1. For each new archive entry, call archive_entry_linkify(). 2. Keep in mind that the entries returned may have a size of 0 now. 3. If *entry is not NULL, archive it. 4. If *sparse is not NULL, archive it. 5. After all entries have been written to disk, call archive_entry_linkify() with *entry set to NULL and archive the returned entry as long as it is not NULL. RETURN VALUES
archive_entry_linkresolver_new() returns NULL on malloc(3) failures. SEE ALSO
archive_entry(3) BSD
February 2, 2012 BSD
All times are GMT -4. The time now is 02:57 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy