lib/commit: Don't try to call linkat() for import on distinct devices
authorColin Walters <walters@verbum.org>
Tue, 19 Sep 2017 19:07:30 +0000 (15:07 -0400)
committerAtomic Bot <atomic-devel@projectatomic.io>
Thu, 21 Sep 2017 19:14:59 +0000 (19:14 +0000)
While opening a repo we've recorded the device/inode for a while; use it to
avoid calling `linkat()` during object import if we know it's going to fail.

Closes: #1193
Approved by: jlebon

src/libostree/ostree-repo-commit.c

index 6d770dea3d0cf5c97cecdf9b82218c39d559ab28..e8bb23959ebed4f9d8a585cb668b3cda749be036 100644 (file)
@@ -3189,8 +3189,9 @@ import_via_hardlink_is_possible (OstreeRepo *src_repo,
                                  OstreeRepo *dest_repo,
                                  OstreeObjectType objtype)
 {
-  /* We need the ability to make hardlinks */
-  if (src_repo->owner_uid != dest_repo->owner_uid)
+  /* hardlinks require the owner to match and to be on the same device */
+  if (!(src_repo->owner_uid == dest_repo->owner_uid &&
+        src_repo->device == dest_repo->device))
     return FALSE;
   /* Equal modes are always compatible */
   if (src_repo->mode == dest_repo->mode)