paranoia code removed. Is now in separate tree under GPL v2+.
realpath.c: patch from Debian and N. Boullis
This commit is contained in:
@@ -23,11 +23,6 @@
|
||||
|
||||
SUBDIRS = data driver
|
||||
|
||||
if BUILD_CD_PARANOIA
|
||||
testparanoia=testparanoia
|
||||
testparanoia_LDADD = $(LIBCDIO_PARANOIA_LIBS) $(LIBCDIO_CDDA_LIBS) $(LIBCDIO_LIBS) $(LTLIBICONV)
|
||||
endif
|
||||
|
||||
hack = check_sizeof testassert testgetdevices testischar \
|
||||
testisocd testisocd2 testiso9660 test_lib_driver_util \
|
||||
$(testparanoia) testpregap testunconfig
|
||||
|
||||
@@ -65,7 +65,7 @@ get_temporary_name(const char *dirname, const char *errmsg)
|
||||
{
|
||||
char *new_filename = tempnam(NULL, "syml");
|
||||
if (NULL == new_filename) {
|
||||
printf("Could not generate %s name\n", errmsg);
|
||||
printf("Could not generate %s name\n", errmsg);
|
||||
}
|
||||
return new_filename;
|
||||
}
|
||||
@@ -74,11 +74,11 @@ static int check_rc(int rc, const char *psz_operation,
|
||||
const char *psz_filename)
|
||||
{
|
||||
if (-1 == rc) {
|
||||
printf("%s %s failed with error: %s\n",
|
||||
psz_operation, psz_filename, strerror(errno));
|
||||
printf("%s %s failed with error: %s\n",
|
||||
psz_operation, psz_filename, strerror(errno));
|
||||
} else if (0 != rc) {
|
||||
printf("%s %s gives weird return %d\n",
|
||||
psz_operation, psz_filename, rc);
|
||||
printf("%s %s gives weird return %d\n",
|
||||
psz_operation, psz_filename, rc);
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
@@ -99,18 +99,18 @@ main(int argc, const char *argv[])
|
||||
|
||||
psz_tmp_subdir = get_temporary_name(NULL, "temporary directory");
|
||||
if (NULL == psz_tmp_subdir) {
|
||||
exit(77);
|
||||
exit(77);
|
||||
}
|
||||
|
||||
if (-1 == check_rc(mkdir(psz_tmp_subdir, 0700),
|
||||
"mkdir", psz_tmp_subdir))
|
||||
exit(77);
|
||||
"mkdir", psz_tmp_subdir))
|
||||
exit(77);
|
||||
|
||||
cdio_realpath(psz_tmp_subdir, tmp_subdir);
|
||||
|
||||
if (0 == strlen(tmp_subdir)) {
|
||||
fprintf(stderr, "cdio_realpath on temp directory %s failed\n",
|
||||
psz_tmp_subdir);
|
||||
psz_tmp_subdir);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@@ -122,49 +122,49 @@ main(int argc, const char *argv[])
|
||||
|
||||
psz_orig_file = get_temporary_name(NULL, "file");
|
||||
if (NULL != psz_orig_file) {
|
||||
FILE *fp = fopen(psz_orig_file, "w");
|
||||
char orig_file[PATH_MAX+1] = {0};
|
||||
int rc;
|
||||
char symlink_file[PATH_MAX+1] = {0};
|
||||
FILE *fp = fopen(psz_orig_file, "w");
|
||||
char orig_file[PATH_MAX+1] = {0};
|
||||
int rc;
|
||||
char symlink_file[PATH_MAX+1] = {0};
|
||||
|
||||
fprintf(fp, "testing\n");
|
||||
fclose(fp);
|
||||
cdio_realpath(psz_orig_file, orig_file);
|
||||
if (0 == strlen(orig_file)) {
|
||||
fprintf(stderr, "cdio_realpath on temp file %s failed\n",
|
||||
psz_orig_file);
|
||||
exit(2);
|
||||
}
|
||||
fprintf(fp, "testing\n");
|
||||
fclose(fp);
|
||||
cdio_realpath(psz_orig_file, orig_file);
|
||||
if (0 == strlen(orig_file)) {
|
||||
fprintf(stderr, "cdio_realpath on temp file %s failed\n",
|
||||
psz_orig_file);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
psz_symlink_file = get_temporary_name(NULL, "symlink file");
|
||||
rc = check_rc(symlink(psz_orig_file, psz_symlink_file),
|
||||
"symlink", psz_symlink_file);
|
||||
if (0 == rc) {
|
||||
/* Just when you thought we'd forgotten, here is our first
|
||||
test! */
|
||||
cdio_realpath(psz_symlink_file, psz_file_check);
|
||||
if (0 != strncmp(psz_file_check, orig_file, PATH_MAX)) {
|
||||
fprintf(stderr, "simple cdio_realpath failed: %s vs %s\n",
|
||||
psz_file_check, orig_file);
|
||||
exit(3);
|
||||
}
|
||||
check_rc(unlink(psz_symlink_file), "unlink", psz_symlink_file);
|
||||
}
|
||||
|
||||
/* Make sure we handle a cyclic symbolic name, e.g. xx -> xx */
|
||||
cdio_realpath(psz_symlink_file, symlink_file);
|
||||
rc = check_rc(symlink(psz_symlink_file, psz_symlink_file),
|
||||
"symlink", psz_symlink_file);
|
||||
if (0 == rc) {
|
||||
cdio_realpath(psz_symlink_file, psz_file_check);
|
||||
if (0 != strncmp(psz_file_check, symlink_file, PATH_MAX)) {
|
||||
fprintf(stderr, "direct cdio_realpath cycle test failed. %s vs %s\n",
|
||||
psz_file_check, symlink_file);
|
||||
exit(4);
|
||||
}
|
||||
check_rc(unlink(psz_symlink_file), "unlink", psz_symlink_file);
|
||||
}
|
||||
|
||||
psz_symlink_file = get_temporary_name(NULL, "symlink file");
|
||||
rc = check_rc(symlink(psz_orig_file, psz_symlink_file),
|
||||
"symlink", psz_symlink_file);
|
||||
if (0 == rc) {
|
||||
/* Just when you thought we'd forgotten, here is our first
|
||||
test! */
|
||||
cdio_realpath(psz_symlink_file, psz_file_check);
|
||||
if (0 != strncmp(psz_file_check, orig_file, PATH_MAX)) {
|
||||
fprintf(stderr, "simple cdio_realpath failed: %s vs %s\n",
|
||||
psz_file_check, orig_file);
|
||||
exit(3);
|
||||
}
|
||||
check_rc(unlink(psz_symlink_file), "unlink", psz_symlink_file);
|
||||
}
|
||||
|
||||
/* Make sure we handle a cyclic symbolic name, e.g. xx -> xx */
|
||||
cdio_realpath(psz_symlink_file, symlink_file);
|
||||
rc = check_rc(symlink(psz_symlink_file, psz_symlink_file),
|
||||
"symlink", psz_symlink_file);
|
||||
if (0 == rc) {
|
||||
cdio_realpath(psz_symlink_file, psz_file_check);
|
||||
if (0 != strncmp(psz_file_check, symlink_file, PATH_MAX)) {
|
||||
fprintf(stderr, "direct cdio_realpath cycle test failed. %s vs %s\n",
|
||||
psz_file_check, symlink_file);
|
||||
exit(4);
|
||||
}
|
||||
check_rc(unlink(psz_symlink_file), "unlink", psz_symlink_file);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
check_rc(unlink(psz_orig_file), "unlink", psz_orig_file);
|
||||
|
||||
Reference in New Issue
Block a user