- status = -1;
- if (fd < 0)
- open_error (CURRENT_FILE_NAME);
- else if (fstat (fd, &st) != 0)
- {
- stat_error (CURRENT_FILE_NAME);
- close (fd);
- }
- else if (close (fd) != 0)
- close_error (CURRENT_FILE_NAME);
- else
- {
- struct delayed_set_stat *h;
- struct delayed_symlink *p =
- xmalloc (offsetof (struct delayed_symlink, target)
- + strlen (current_link_name) + 1);
- p->next = delayed_symlink_head;
- delayed_symlink_head = p;
- p->dev = st.st_dev;
- p->ino = st.st_ino;
- p->mtime = st.st_mtime;
- p->uid = current_stat.st_uid;
- p->gid = current_stat.st_gid;
- p->sources = xmalloc (offsetof (struct string_list, string)
- + strlen (CURRENT_FILE_NAME) + 1);
- p->sources->next = 0;
- strcpy (p->sources->string, CURRENT_FILE_NAME);
- strcpy (p->target, current_link_name);
-
- h = delayed_set_stat_head;
- if (h && ! h->after_symlinks
- && strncmp (CURRENT_FILE_NAME, h->file_name, h->file_name_len) == 0
- && ISSLASH (CURRENT_FILE_NAME[h->file_name_len])
- && (base_name (CURRENT_FILE_NAME)
- == CURRENT_FILE_NAME + h->file_name_len + 1))
- {
- do
- {
- h->after_symlinks = 1;
-
- if (stat (h->file_name, &st) != 0)
- stat_error (h->file_name);
- else
- {
- h->stat_info.st_dev = st.st_dev;
- h->stat_info.st_ino = st.st_ino;
- }
- }
- while ((h = h->next) && ! h->after_symlinks);
- }