iso9660_fs.c: reallocate filename when Rock-Ridge name is bigger.
rock.c: variable name changes cd-info.c: don't translate file name when there are Rock-Ridge Extensions.
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
$Id: iso9660_fs.c,v 1.17 2005/02/17 11:54:28 rocky Exp $
|
$Id: iso9660_fs.c,v 1.18 2005/02/18 01:31:08 rocky Exp $
|
||||||
|
|
||||||
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
|
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
|
||||||
Copyright (C) 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com>
|
Copyright (C) 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com>
|
||||||
@@ -52,7 +52,7 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
static const char _rcsid[] = "$Id: iso9660_fs.c,v 1.17 2005/02/17 11:54:28 rocky Exp $";
|
static const char _rcsid[] = "$Id: iso9660_fs.c,v 1.18 2005/02/18 01:31:08 rocky Exp $";
|
||||||
|
|
||||||
/* Implementation of iso9660_t type */
|
/* Implementation of iso9660_t type */
|
||||||
struct _iso9660_s {
|
struct _iso9660_s {
|
||||||
@@ -794,16 +794,16 @@ _iso9660_dir_to_statbuf (iso9660_dir_t *p_iso9660_dir, bool_3way_t b_xa,
|
|||||||
uint8_t i_joliet_level)
|
uint8_t i_joliet_level)
|
||||||
{
|
{
|
||||||
uint8_t dir_len= iso9660_get_dir_len(p_iso9660_dir);
|
uint8_t dir_len= iso9660_get_dir_len(p_iso9660_dir);
|
||||||
unsigned int filename_len;
|
unsigned int i_fname;
|
||||||
unsigned int stat_len;
|
unsigned int stat_len;
|
||||||
iso9660_stat_t *p_stat;
|
iso9660_stat_t *p_stat;
|
||||||
|
|
||||||
if (!dir_len) return NULL;
|
if (!dir_len) return NULL;
|
||||||
|
|
||||||
filename_len = from_711(p_iso9660_dir->filename_len);
|
i_fname = from_711(p_iso9660_dir->filename_len);
|
||||||
|
|
||||||
/* .. string in statbuf is one longer than in p_iso9660_dir's listing '\1' */
|
/* .. string in statbuf is one longer than in p_iso9660_dir's listing '\1' */
|
||||||
stat_len = sizeof(iso9660_stat_t)+filename_len+2;
|
stat_len = sizeof(iso9660_stat_t)+i_fname+2;
|
||||||
|
|
||||||
p_stat = calloc(1, stat_len);
|
p_stat = calloc(1, stat_len);
|
||||||
p_stat->type = (p_iso9660_dir->file_flags & ISO_DIRECTORY)
|
p_stat->type = (p_iso9660_dir->file_flags & ISO_DIRECTORY)
|
||||||
@@ -813,29 +813,31 @@ _iso9660_dir_to_statbuf (iso9660_dir_t *p_iso9660_dir, bool_3way_t b_xa,
|
|||||||
p_stat->secsize = _cdio_len2blocks (p_stat->size, ISO_BLOCKSIZE);
|
p_stat->secsize = _cdio_len2blocks (p_stat->size, ISO_BLOCKSIZE);
|
||||||
p_stat->b_rock = dunno; /*FIXME should do based on mask */
|
p_stat->b_rock = dunno; /*FIXME should do based on mask */
|
||||||
|
|
||||||
if ('\0' == p_iso9660_dir->filename[0] && 1 == filename_len)
|
if ('\0' == p_iso9660_dir->filename[0] && 1 == i_fname)
|
||||||
strcpy (p_stat->filename, ".");
|
strcpy (p_stat->filename, ".");
|
||||||
else if ('\1' == p_iso9660_dir->filename[0] && 1 == filename_len)
|
else if ('\1' == p_iso9660_dir->filename[0] && 1 == i_fname)
|
||||||
strcpy (p_stat->filename, "..");
|
strcpy (p_stat->filename, "..");
|
||||||
else {
|
else {
|
||||||
char rr_fname[256];
|
char rr_fname[256] = "";
|
||||||
int i_rr_fname_len =
|
int i_rr_fname =
|
||||||
get_rock_ridge_filename(p_iso9660_dir, rr_fname, p_stat);
|
get_rock_ridge_filename(p_iso9660_dir, rr_fname, p_stat);
|
||||||
if (i_rr_fname_len > 0) {
|
if (i_rr_fname > 0) {
|
||||||
strncpy(p_stat->filename, rr_fname, i_rr_fname_len+1);
|
if (i_rr_fname > i_fname)
|
||||||
|
realloc(p_stat, sizeof(iso9660_stat_t)+i_rr_fname+2);
|
||||||
|
strncpy(p_stat->filename, rr_fname, i_rr_fname+1);
|
||||||
} else {
|
} else {
|
||||||
#ifdef HAVE_JOLIET
|
#ifdef HAVE_JOLIET
|
||||||
if (i_joliet_level && i_rr_fname_len > 0) {
|
if (i_joliet_level && i_rr_fname > 0) {
|
||||||
int i_inlen = filename_len;
|
int i_inlen = i_fname;
|
||||||
int i_outlen = (i_inlen / 2);
|
int i_outlen = (i_inlen / 2);
|
||||||
char *p_psz_out = NULL;
|
char *p_psz_out = NULL;
|
||||||
ucs2be_to_locale(p_iso9660_dir->filename, i_inlen,
|
ucs2be_to_locale(p_iso9660_dir->filename, i_inlen, &p_psz_out,
|
||||||
&p_psz_out, i_outlen);
|
i_outlen);
|
||||||
strncpy(p_stat->filename, p_psz_out, filename_len);
|
strncpy(p_stat->filename, p_psz_out, i_fname);
|
||||||
free(p_psz_out);
|
free(p_psz_out);
|
||||||
} else
|
} else
|
||||||
#endif /*HAVE_JOLIET*/
|
#endif /*HAVE_JOLIET*/
|
||||||
strncpy (p_stat->filename, p_iso9660_dir->filename, filename_len);
|
strncpy (p_stat->filename, p_iso9660_dir->filename, i_fname);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -851,7 +853,7 @@ _iso9660_dir_to_statbuf (iso9660_dir_t *p_iso9660_dir, bool_3way_t b_xa,
|
|||||||
{
|
{
|
||||||
int su_length = iso9660_get_dir_len(p_iso9660_dir)
|
int su_length = iso9660_get_dir_len(p_iso9660_dir)
|
||||||
- sizeof (iso9660_dir_t);
|
- sizeof (iso9660_dir_t);
|
||||||
su_length -= filename_len;
|
su_length -= i_fname;
|
||||||
|
|
||||||
if (su_length % 2)
|
if (su_length % 2)
|
||||||
su_length--;
|
su_length--;
|
||||||
@@ -876,7 +878,7 @@ _iso9660_dir_to_statbuf (iso9660_dir_t *p_iso9660_dir, bool_3way_t b_xa,
|
|||||||
" ignoring XA attributes for this file entry.");
|
" ignoring XA attributes for this file entry.");
|
||||||
cdio_debug ("%d %d %d, '%c%c' (%d, %d)",
|
cdio_debug ("%d %d %d, '%c%c' (%d, %d)",
|
||||||
iso9660_get_dir_len(p_iso9660_dir),
|
iso9660_get_dir_len(p_iso9660_dir),
|
||||||
filename_len,
|
i_fname,
|
||||||
su_length,
|
su_length,
|
||||||
xa_data->signature[0], xa_data->signature[1],
|
xa_data->signature[0], xa_data->signature[1],
|
||||||
xa_data->signature[0], xa_data->signature[1]);
|
xa_data->signature[0], xa_data->signature[1]);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
$Id: rock.c,v 1.3 2005/02/14 07:49:46 rocky Exp $
|
$Id: rock.c,v 1.4 2005/02/18 01:31:08 rocky Exp $
|
||||||
|
|
||||||
Copyright (C) 2005 Rocky Bernstein <rocky@panix.com>
|
Copyright (C) 2005 Rocky Bernstein <rocky@panix.com>
|
||||||
Adapted from GNU/Linux fs/isofs/rock.c (C) 1992, 1993 Eric Youngdale
|
Adapted from GNU/Linux fs/isofs/rock.c (C) 1992, 1993 Eric Youngdale
|
||||||
@@ -91,7 +91,7 @@ get_rock_ridge_filename(iso9660_dir_t * de, /*out*/ char * psz_name,
|
|||||||
int len;
|
int len;
|
||||||
unsigned char *chr;
|
unsigned char *chr;
|
||||||
CONTINUE_DECLS;
|
CONTINUE_DECLS;
|
||||||
int retnamlen = 0;
|
int i_namelen = 0;
|
||||||
int truncate=0;
|
int truncate=0;
|
||||||
|
|
||||||
if (!p_stat || nope == p_stat->b_rock) return 0;
|
if (!p_stat || nope == p_stat->b_rock) return 0;
|
||||||
@@ -140,7 +140,7 @@ get_rock_ridge_filename(iso9660_dir_t * de, /*out*/ char * psz_name,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
strncat(psz_name, rr->u.NM.name, rr->len - 5);
|
strncat(psz_name, rr->u.NM.name, rr->len - 5);
|
||||||
retnamlen += rr->len - 5;
|
i_namelen += rr->len - 5;
|
||||||
break;
|
break;
|
||||||
case SIG('P','X'):
|
case SIG('P','X'):
|
||||||
p_stat->st_mode = from_733(rr->u.PX.st_mode);
|
p_stat->st_mode = from_733(rr->u.PX.st_mode);
|
||||||
@@ -186,7 +186,7 @@ get_rock_ridge_filename(iso9660_dir_t * de, /*out*/ char * psz_name,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
free(buffer);
|
free(buffer);
|
||||||
return retnamlen; /* If 0, this file did not have a NM field */
|
return i_namelen; /* If 0, this file did not have a NM field */
|
||||||
out:
|
out:
|
||||||
free(buffer);
|
free(buffer);
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
$Id: cd-info.c,v 1.113 2005/02/17 11:54:28 rocky Exp $
|
$Id: cd-info.c,v 1.114 2005/02/18 01:31:08 rocky Exp $
|
||||||
|
|
||||||
Copyright (C) 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com>
|
Copyright (C) 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com>
|
||||||
Copyright (C) 1996, 1997, 1998 Gerd Knorr <kraxel@bytesex.org>
|
Copyright (C) 1996, 1997, 1998 Gerd Knorr <kraxel@bytesex.org>
|
||||||
@@ -538,8 +538,8 @@ static void
|
|||||||
print_iso9660_recurse (CdIo_t *p_cdio, const char pathname[],
|
print_iso9660_recurse (CdIo_t *p_cdio, const char pathname[],
|
||||||
cdio_fs_anal_t fs)
|
cdio_fs_anal_t fs)
|
||||||
{
|
{
|
||||||
CdioList_t *entlist;
|
CdioList_t *p_entlist;
|
||||||
CdioList_t *dirlist = _cdio_list_new ();
|
CdioList_t *p_dirlist = _cdio_list_new ();
|
||||||
CdioListNode_t *entnode;
|
CdioListNode_t *entnode;
|
||||||
uint8_t i_joliet_level;
|
uint8_t i_joliet_level;
|
||||||
|
|
||||||
@@ -547,73 +547,78 @@ print_iso9660_recurse (CdIo_t *p_cdio, const char pathname[],
|
|||||||
? 0
|
? 0
|
||||||
: cdio_get_joliet_level(p_cdio);
|
: cdio_get_joliet_level(p_cdio);
|
||||||
|
|
||||||
entlist = iso9660_fs_readdir (p_cdio, pathname, false);
|
p_entlist = iso9660_fs_readdir (p_cdio, pathname, false);
|
||||||
|
|
||||||
printf ("%s:\n", pathname);
|
printf ("%s:\n", pathname);
|
||||||
|
|
||||||
if (NULL == entlist) {
|
if (NULL == p_entlist) {
|
||||||
report( stderr, "Error getting above directory information\n" );
|
report( stderr, "Error getting above directory information\n" );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Iterate over files in this directory */
|
/* Iterate over files in this directory */
|
||||||
|
|
||||||
_CDIO_LIST_FOREACH (entnode, entlist)
|
_CDIO_LIST_FOREACH (entnode, p_entlist)
|
||||||
{
|
{
|
||||||
iso9660_stat_t *statbuf = _cdio_list_node_data (entnode);
|
iso9660_stat_t *p_statbuf = _cdio_list_node_data (entnode);
|
||||||
char *iso_name = statbuf->filename;
|
char *psz_iso_name = p_statbuf->filename;
|
||||||
char _fullname[4096] = { 0, };
|
char _fullname[4096] = { 0, };
|
||||||
char translated_name[MAX_ISONAME+1];
|
char translated_name[MAX_ISONAME+1];
|
||||||
#define DATESTR_SIZE 30
|
#define DATESTR_SIZE 30
|
||||||
char date_str[DATESTR_SIZE];
|
char date_str[DATESTR_SIZE];
|
||||||
|
|
||||||
iso9660_name_translate_ext(iso_name, translated_name, i_joliet_level);
|
if (yep != p_statbuf->b_rock) {
|
||||||
|
iso9660_name_translate_ext(psz_iso_name, translated_name,
|
||||||
|
i_joliet_level);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
snprintf (_fullname, sizeof (_fullname), "%s%s", pathname,
|
snprintf (_fullname, sizeof (_fullname), "%s%s", pathname,
|
||||||
iso_name);
|
psz_iso_name);
|
||||||
|
|
||||||
strncat (_fullname, "/", sizeof (_fullname));
|
strncat (_fullname, "/", sizeof (_fullname));
|
||||||
|
|
||||||
if (statbuf->type == _STAT_DIR
|
if (p_statbuf->type == _STAT_DIR
|
||||||
&& strcmp (iso_name, ".")
|
&& strcmp (psz_iso_name, ".")
|
||||||
&& strcmp (iso_name, ".."))
|
&& strcmp (psz_iso_name, ".."))
|
||||||
_cdio_list_append (dirlist, strdup (_fullname));
|
_cdio_list_append (p_dirlist, strdup (_fullname));
|
||||||
|
|
||||||
if (fs & CDIO_FS_ANAL_XA) {
|
if (fs & CDIO_FS_ANAL_XA) {
|
||||||
printf ( " %c %s %d %d [fn %.2d] [LSN %6lu] ",
|
printf ( " %c %s %d %d [fn %.2d] [LSN %6lu] ",
|
||||||
(statbuf->type == _STAT_DIR) ? 'd' : '-',
|
(p_statbuf->type == _STAT_DIR) ? 'd' : '-',
|
||||||
iso9660_get_xa_attr_str (statbuf->xa.attributes),
|
iso9660_get_xa_attr_str (p_statbuf->xa.attributes),
|
||||||
uint16_from_be (statbuf->xa.user_id),
|
uint16_from_be (p_statbuf->xa.user_id),
|
||||||
uint16_from_be (statbuf->xa.group_id),
|
uint16_from_be (p_statbuf->xa.group_id),
|
||||||
statbuf->xa.filenum,
|
p_statbuf->xa.filenum,
|
||||||
(long unsigned int) statbuf->lsn);
|
(long unsigned int) p_statbuf->lsn);
|
||||||
|
|
||||||
if (uint16_from_be(statbuf->xa.attributes) & XA_ATTR_MODE2FORM2) {
|
if (uint16_from_be(p_statbuf->xa.attributes) & XA_ATTR_MODE2FORM2) {
|
||||||
printf ("%9u (%9u)",
|
printf ("%9u (%9u)",
|
||||||
(unsigned int) statbuf->secsize * M2F2_SECTOR_SIZE,
|
(unsigned int) p_statbuf->secsize * M2F2_SECTOR_SIZE,
|
||||||
(unsigned int) statbuf->size);
|
(unsigned int) p_statbuf->size);
|
||||||
} else {
|
} else {
|
||||||
printf ("%9u", (unsigned int) statbuf->size);
|
printf ("%9u", (unsigned int) p_statbuf->size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
strftime(date_str, DATESTR_SIZE, "%b %d %Y %H:%M ", &statbuf->tm);
|
strftime(date_str, DATESTR_SIZE, "%b %d %Y %H:%M ", &p_statbuf->tm);
|
||||||
printf (" %s %s\n", date_str, translated_name);
|
printf (" %s %s\n", date_str, (yep != p_statbuf->b_rock)
|
||||||
|
? translated_name : psz_iso_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
_cdio_list_free (entlist, true);
|
_cdio_list_free (p_entlist, true);
|
||||||
|
|
||||||
printf ("\n");
|
printf ("\n");
|
||||||
|
|
||||||
/* Now recurse over the directories. */
|
/* Now recurse over the directories. */
|
||||||
|
|
||||||
_CDIO_LIST_FOREACH (entnode, dirlist)
|
_CDIO_LIST_FOREACH (entnode, p_dirlist)
|
||||||
{
|
{
|
||||||
char *_fullname = _cdio_list_node_data (entnode);
|
char *_fullname = _cdio_list_node_data (entnode);
|
||||||
|
|
||||||
print_iso9660_recurse (p_cdio, _fullname, fs);
|
print_iso9660_recurse (p_cdio, _fullname, fs);
|
||||||
}
|
}
|
||||||
|
|
||||||
_cdio_list_free (dirlist, true);
|
_cdio_list_free (p_dirlist, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|||||||
Reference in New Issue
Block a user