- status = -1;
- if (fd < 0)
- open_error (file_name);
- else if (fstat (fd, &st) != 0)
- {
- stat_error (file_name);
- close (fd);
- }
- else if (close (fd) != 0)
- close_error (file_name);
- else
- {
- struct delayed_set_stat *h;
- struct delayed_symlink *p =
- xmalloc (offsetof (struct delayed_symlink, target)
- + strlen (current_stat_info.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_info.stat.st_uid;
- p->gid = current_stat_info.stat.st_gid;
- p->sources = xmalloc (offsetof (struct string_list, string)
- + strlen (file_name) + 1);
- p->sources->next = 0;
- strcpy (p->sources->string, file_name);
- strcpy (p->target, current_stat_info.link_name);
-
- h = delayed_set_stat_head;
- if (h && ! h->after_symlinks
- && strncmp (file_name, h->file_name, h->file_name_len) == 0
- && ISSLASH (file_name[h->file_name_len])
- && (base_name (file_name)
- == 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);
- }
-
- status = 0;
- }
- }