return file;
}
-static struct file *copy_file(struct file *old)
+static struct file *copy_file(struct file *old, int new_association)
{
struct file *file = xcalloc(1, old->class->size);
list_add_tail(&file->files, &old->proc->files);
file->class = old->class;
- file->association = old->association;
+ file->association = new_association;
file->name = xstrdup(old->name);
file->stat = old->stat;
* path is the same to save stat() call.
*/
prev = list_last_entry(&proc->files, struct file, files);
- if (prev && prev->name && strcmp(prev->name, sym) == 0) {
- f = copy_file(prev);
- f->association = assoc;
- } else {
+ if (prev && prev->name && strcmp(prev->name, sym) == 0)
+ f = copy_file(prev, assoc);
+ else {
const struct file_class *class;
if (ul_path_stat(pc, &sb, 0, name) < 0)
*/
prev = list_last_entry(&proc->files, struct file, files);
- if (prev && prev->stat.st_dev == devno && prev->stat.st_ino == ino) {
- f = copy_file(prev);
- f->association = -assoc;
- } else if ((path = strchr(buf, '/'))) {
+ if (prev && prev->stat.st_dev == devno && prev->stat.st_ino == ino)
+ f = copy_file(prev, -assoc);
+ else if ((path = strchr(buf, '/'))) {
rtrim_whitespace((unsigned char *) path);
if (stat(path, &sb) < 0)
/* If a file is mapped but deleted from the file system,