summaryrefslogtreecommitdiff
path: root/usr/src/cmd/cdrw
diff options
context:
space:
mode:
authorec158148 <none@none>2005-09-01 09:36:15 -0700
committerec158148 <none@none>2005-09-01 09:36:15 -0700
commit416baccdfbdf5cf94094097179a33abd373ed35e (patch)
tree0be78bc00283deaaf08c169759b790a97840b706 /usr/src/cmd/cdrw
parent0b5c9250b17799ab6af5fd285c7f4a3ba5b97822 (diff)
downloadillumos-gate-416baccdfbdf5cf94094097179a33abd373ed35e.tar.gz
4368821 cdrw should 1st check for the existance of tmp-dir
Diffstat (limited to 'usr/src/cmd/cdrw')
-rw-r--r--usr/src/cmd/cdrw/bstream.c30
-rw-r--r--usr/src/cmd/cdrw/bstream.h4
-rw-r--r--usr/src/cmd/cdrw/copycd.c10
3 files changed, 23 insertions, 21 deletions
diff --git a/usr/src/cmd/cdrw/bstream.c b/usr/src/cmd/cdrw/bstream.c
index 59e688ca1d..73c5f0e6c8 100644
--- a/usr/src/cmd/cdrw/bstream.c
+++ b/usr/src/cmd/cdrw/bstream.c
@@ -20,7 +20,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -595,27 +595,27 @@ open_temp_file_stream(void)
return (h);
}
+/*
+ * check_avail_temp_space returns 0 if there is adequate space
+ * in the temporary directory, or a non-zero error code if
+ * something goes wrong
+ */
int
-check_avail_temp_space(off_t req_size)
+check_avail_temp_space(size_t req_size)
{
- char *t;
struct statvfs buf;
- uint64_t free_size;
-
-
- t = get_tmp_name();
+ size_t free_size = 0;
- if (statvfs(t, &buf) < 0)
- return (0);
+ if (statvfs(get_tmp_name(), &buf) < 0) {
+ return (errno);
+ }
- free_size = (uint64_t)buf.f_bfree;
- free_size *= (uint64_t)buf.f_frsize;
+ free_size = buf.f_bfree * buf.f_frsize;
- if (free_size <= ((uint64_t)req_size))
- return (0);
+ if (free_size <= req_size)
+ return (ENOMEM);
- /* path directory and there is enough free space */
- return (1);
+ return (0);
}
diff --git a/usr/src/cmd/cdrw/bstream.h b/usr/src/cmd/cdrw/bstream.h
index a2d2cbbbab..734ea069a6 100644
--- a/usr/src/cmd/cdrw/bstream.h
+++ b/usr/src/cmd/cdrw/bstream.h
@@ -20,7 +20,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -72,7 +72,7 @@ bstreamhandle open_file_write_stream(char *fname);
bstreamhandle open_temp_file_stream(void);
char *str_errno_to_string(int serrno);
-int check_avail_temp_space(off_t req_size);
+int check_avail_temp_space(size_t req_size);
char *get_tmp_name(void);
#ifdef __cplusplus
diff --git a/usr/src/cmd/cdrw/copycd.c b/usr/src/cmd/cdrw/copycd.c
index 1979cfce9a..0479e6ac12 100644
--- a/usr/src/cmd/cdrw/copycd.c
+++ b/usr/src/cmd/cdrw/copycd.c
@@ -33,6 +33,7 @@
#include <limits.h>
#include <unistd.h>
#include <libintl.h>
+#include <string.h>
#include "main.h"
#include "util.h"
@@ -298,10 +299,11 @@ copy_cd(void)
end_tno, (audio_cd == 1) ? gettext("audio") : gettext("data"),
(end_tno > 1) ? "s" : "", (long)((total_nblks*blksize)/1024));
- if (!check_avail_temp_space(total_nblks*blksize)) {
- err_msg(gettext("Not enough space in temporary directory\n"));
- err_msg(
- gettext("Use -m to specify alternate temporary directory\n"));
+ if ((ret = check_avail_temp_space(total_nblks*blksize)) != 0) {
+ err_msg(gettext("Cannot use temporary directory : %s\n"),
+ strerror(ret));
+ err_msg(gettext("Use -m to specify alternate"
+ " temporary directory\n"));
exit(1);
}