Преглед изворни кода

Comment a bit on the xattr extraction logic

* src/extract.c (extract_file): Document why we pre-create with S_IWUSR.
(set_xattr): Drop the INVERT_PERMISSIONS doc leftover.
Pavel Raiskup пре 1 година
родитељ
комит
e7987b72c6
1 измењених фајлова са 8 додато и 5 уклоњено
  1. 8 5
      src/extract.c

+ 8 - 5
src/extract.c

@@ -902,11 +902,10 @@ maybe_recoverable (char *file_name, bool regular, bool *interdir_made)
    (e.g. on Lustre distributed parallel filesystem - setting info about how many
    (e.g. on Lustre distributed parallel filesystem - setting info about how many
    servers is this file striped over, stripe size, mirror copies, etc.
    servers is this file striped over, stripe size, mirror copies, etc.
    in advance dramatically improves the following  performance of reading and
    in advance dramatically improves the following  performance of reading and
-   writing a file).  If not restoring permissions, invert the INVERT_PERMISSIONS
-   bits from the file's current permissions.  TYPEFLAG specifies the type of the
-   file.  Return a negative number (setting errno) on failure, zero if
-   successful but FILE_NAME was not created (e.g., xattrs not
-   available), and a positive number if FILE_NAME was created.  */
+   writing a file).  TYPEFLAG specifies the type of the file.  Return a negative
+   number (setting errno) on failure, zero if successful but FILE_NAME was not
+   created (e.g., xattrs not available), and a positive number if FILE_NAME was
+   created.  */
 static int
 static int
 set_xattr (char const *file_name, struct tar_stat_info const *st,
 set_xattr (char const *file_name, struct tar_stat_info const *st,
            mode_t mode, char typeflag)
            mode_t mode, char typeflag)
@@ -1271,6 +1270,10 @@ extract_file (char *file_name, int typeflag)
   else
   else
     {
     {
       int file_created;
       int file_created;
+      /* Either we pre-create the file in set_xattr(), or we just directly open
+         the file in open_output_file() with O_CREAT.  If pre-creating, we need
+         to use S_IWUSR so we can open the file O_WRONLY in open_output_file().
+         The additional mode bit is cleared later by set_stat()->set_mode().  */
       while (((file_created = set_xattr (file_name, &current_stat_info,
       while (((file_created = set_xattr (file_name, &current_stat_info,
 					 mode | S_IWUSR, typeflag))
 					 mode | S_IWUSR, typeflag))
 	      < 0)
 	      < 0)