diff options
Diffstat (limited to 'usr/src')
-rw-r--r-- | usr/src/cmd/ndmpd/tlm/tlm_backup_reader.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/usr/src/cmd/ndmpd/tlm/tlm_backup_reader.c b/usr/src/cmd/ndmpd/tlm/tlm_backup_reader.c index 9ae4368101..73a6670148 100644 --- a/usr/src/cmd/ndmpd/tlm/tlm_backup_reader.c +++ b/usr/src/cmd/ndmpd/tlm/tlm_backup_reader.c @@ -617,6 +617,7 @@ tlm_output_xattr(char *dir, char *name, char *chkdir, char *snapname; /* snapshot name */ int section; /* section of a huge file */ int fd; + int afd = 0; longlong_t seek_spot = 0; /* location in the file */ /* for Multi Volume record */ u_longlong_t pos; @@ -695,16 +696,15 @@ tlm_output_xattr(char *dir, char *name, char *chkdir, if (sysattr_rdonly(dtp->d_name)) continue; - (void) close(fd); - fd = attropen(fnamep, dtp->d_name, O_RDONLY); - if (fd == -1) { + afd = attropen(fnamep, dtp->d_name, O_RDONLY); + if (afd == -1) { NDMP_LOG(LOG_DEBUG, "problem(%d) opening xattr file [%s][%s]", errno, fullname, fnamep); goto tear_down; } - (void) output_xattr_header(fullname, dtp->d_name, fd, + (void) output_xattr_header(fullname, dtp->d_name, afd, tlm_acls, section, local_commands); (void) snprintf(attrname, TLM_MAX_PATH_NAME, "/dev/null/%s", dtp->d_name); @@ -763,7 +763,7 @@ tlm_output_xattr(char *dir, char *name, char *chkdir, } read_size = min(section_size, actual_size); - if ((actual_size = read(fd, buf, read_size)) < 0) + if ((actual_size = read(afd, buf, read_size)) < 0) break; if (sysattr_read) { @@ -788,14 +788,19 @@ tlm_output_xattr(char *dir, char *name, char *chkdir, seek_spot += actual_size; section_size -= actual_size; } + (void) close(afd); + afd = -1; } tear_down: local_commands->tc_buffers->tbs_buffer[ local_commands->tc_buffers->tbs_buffer_in].tb_seek_spot = 0; + if (afd > 0) + (void) close(afd); + + /* closedir closes fd too */ (void) closedir(dp); - (void) close(fd); err_out: free(fullname); |