all: Add iso9660_get_rock_attr_str to get an ls-like mode string for rock

ridge.

{cd,iso}-info.c util.{c,h}: put common printing routine in util.c

rock.h: add enum for NM flags
iso9660.h: move mode_t typedef so it can be used in rock.h
xa.{c,h}: small typos.

test/*: in most cases better output. On VCD's however there there is a
slight regression on displaying the filename someitmes. Will be
addressed later.
This commit is contained in:
rocky
2005-02-20 10:21:01 +00:00
parent 0a048cb05c
commit a8e1fd6038
21 changed files with 470 additions and 296 deletions

View File

@@ -1,4 +1,4 @@
# $Id: Makefile.am,v 1.31 2005/01/06 11:55:09 rocky Exp $
# $Id: Makefile.am,v 1.32 2005/02/20 10:21:01 rocky Exp $
#
# Copyright (C) 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com>
#
@@ -35,7 +35,7 @@ endif
if BUILD_CD_DRIVE
cd_drive_SOURCES = cd-drive.c util.c util.h
cd_drive_LDADD = $(LIBCDIO_LIBS) $(LIBPOPT_LIBS) $(LIBICONV)
cd_drive_LDADD = $(LIBISO9660_LIBS) $(LIBCDIO_LIBS) $(LIBPOPT_LIBS) $(LIBICONV)
bin_cd_drive = cd-drive
endif
@@ -53,7 +53,7 @@ endif
if BUILD_CD_READ
cd_read_SOURCES = cd-read.c util.c util.h
cd_read_LDADD = $(LIBCDIO_LIBS) $(LIBPOPT_LIBS) $(LIBICONV)
cd_read_LDADD = $(LIBISO9660_LIBS) $(LIBCDIO_LIBS) $(LIBPOPT_LIBS) $(LIBICONV)
bin_cd_read = cd-read
endif

View File

@@ -1,5 +1,5 @@
/*
$Id: cd-info.c,v 1.115 2005/02/19 11:43:05 rocky Exp $
$Id: cd-info.c,v 1.116 2005/02/20 10:21:01 rocky Exp $
Copyright (C) 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com>
Copyright (C) 1996, 1997, 1998 Gerd Knorr <kraxel@bytesex.org>
@@ -92,6 +92,8 @@ struct arguments
int silent;
int no_header;
int no_joliet;
int no_xa;
int no_rock_ridge;
int print_iso9660;
int list_drives;
source_image_t source_image;
@@ -239,6 +241,12 @@ parse_options (int argc, const char *argv[])
0, "Don't use Joliet extensions"},
#endif /*HAVE_JOLIET*/
{"no-rock-ridge", '\0', POPT_ARG_NONE, &opts.no_rock_ridge,
0, "Don't use Rock-Ridge-extension information"},
{"no-xa", '\0', POPT_ARG_NONE, &opts.no_xa,
0, "Don't use XA-extension information"},
{"quiet", 'q', POPT_ARG_NONE, &opts.silent, 0,
"Don't produce warning output" },
@@ -591,8 +599,6 @@ print_iso9660_recurse (CdIo_t *p_cdio, const char pathname[],
char *psz_iso_name = p_statbuf->filename;
char _fullname[4096] = { 0, };
char translated_name[MAX_ISONAME+1];
#define DATESTR_SIZE 30
char date_str[DATESTR_SIZE];
if (yep != p_statbuf->b_rock) {
iso9660_name_translate_ext(psz_iso_name, translated_name,
@@ -610,26 +616,8 @@ print_iso9660_recurse (CdIo_t *p_cdio, const char pathname[],
&& strcmp (psz_iso_name, ".."))
_cdio_list_append (p_dirlist, strdup (_fullname));
if (fs & CDIO_FS_ANAL_XA) {
printf ( " %c %s %d %d [fn %.2d] [LSN %6lu] ",
(p_statbuf->type == _STAT_DIR) ? 'd' : '-',
iso9660_get_xa_attr_str (p_statbuf->xa.attributes),
uint16_from_be (p_statbuf->xa.user_id),
uint16_from_be (p_statbuf->xa.group_id),
p_statbuf->xa.filenum,
(long unsigned int) p_statbuf->lsn);
if (uint16_from_be(p_statbuf->xa.attributes) & XA_ATTR_MODE2FORM2) {
printf ("%9u (%9u)",
(unsigned int) p_statbuf->secsize * M2F2_SECTOR_SIZE,
(unsigned int) p_statbuf->size);
} else {
printf ("%9u", (unsigned int) p_statbuf->size);
}
}
strftime(date_str, DATESTR_SIZE, "%b %d %Y %H:%M ", &p_statbuf->tm);
printf (" %s %s\n", date_str, (yep != p_statbuf->b_rock)
? translated_name : psz_iso_name);
print_fs_attrs(p_statbuf, opts.no_rock_ridge, fs & CDIO_FS_ANAL_XA,
translated_name, psz_iso_name);
}
_cdio_list_free (p_entlist, true);
@@ -831,7 +819,9 @@ init(void)
opts.silent = false;
opts.list_drives = false;
opts.no_header = false;
opts.no_joliet = false;
opts.no_joliet = 0;
opts.no_rock_ridge = 0;
opts.no_xa = 0;
opts.no_device = 0;
opts.no_disc_mode = 0;
opts.debug_level = 0;

View File

@@ -1,5 +1,5 @@
/*
$Id: iso-info.c,v 1.24 2005/02/19 11:43:05 rocky Exp $
$Id: iso-info.c,v 1.25 2005/02/20 10:21:01 rocky Exp $
Copyright (C) 2004, 2005 Rocky Bernstein <rocky@panix.com>
@@ -202,8 +202,6 @@ print_iso9660_recurse (iso9660_t *p_iso, const char pathname[])
char *iso_name = p_statbuf->filename;
char _fullname[4096] = { 0, };
char translated_name[MAX_ISONAME+1];
#define DATESTR_SIZE 30
char date_str[DATESTR_SIZE];
if (yep != p_statbuf->b_rock) {
iso9660_name_translate_ext(iso_name, translated_name, i_joliet_level);
@@ -214,7 +212,6 @@ print_iso9660_recurse (iso9660_t *p_iso, const char pathname[])
iso_name);
}
strncat (_fullname, "/", sizeof (_fullname));
if (p_statbuf->type == _STAT_DIR
@@ -223,26 +220,10 @@ print_iso9660_recurse (iso9660_t *p_iso, const char pathname[])
_cdio_list_append (dirlist, strdup (_fullname));
if (opts.print_iso9660) {
if (iso9660_ifs_is_xa(p_iso) && 0 == opts.no_xa) {
printf ( " %c %s %d %d [fn %.2d] [LSN %6lu] ",
(p_statbuf->type == _STAT_DIR) ? 'd' : '-',
iso9660_get_xa_attr_str (p_statbuf->xa.attributes),
uint16_from_be (p_statbuf->xa.user_id),
uint16_from_be (p_statbuf->xa.group_id),
p_statbuf->xa.filenum,
(long unsigned int) p_statbuf->lsn);
if (uint16_from_be(p_statbuf->xa.attributes) & XA_ATTR_MODE2FORM2) {
printf ("%9u (%9u)",
(unsigned int) p_statbuf->secsize * M2F2_SECTOR_SIZE,
(unsigned int) p_statbuf->size);
}
} else {
printf ("%9u", (unsigned int) p_statbuf->size);
}
strftime(date_str, DATESTR_SIZE, "%b %d %Y %H:%M ", &p_statbuf->tm);
printf (" %s %s\n", date_str,
yep == p_statbuf->b_rock ? iso_name : translated_name);
print_fs_attrs(p_statbuf,
0 == opts.no_rock_ridge,
iso9660_ifs_is_xa(p_iso) && 0 == opts.no_xa,
iso_name, translated_name);
} else
if ( strcmp (iso_name, ".") && strcmp (iso_name, ".."))
printf("%9u %s%s\n", p_statbuf->size, pathname,

View File

@@ -1,5 +1,5 @@
/*
$Id: util.c,v 1.36 2005/02/09 01:31:10 rocky Exp $
$Id: util.c,v 1.37 2005/02/20 10:21:01 rocky Exp $
Copyright (C) 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com>
@@ -22,6 +22,7 @@
#include "util.h"
#include <cdio/mmc.h>
#include <cdio/bytesex.h>
cdio_log_handler_t gl_default_cdio_log_handler = NULL;
char *source_name = NULL;
@@ -450,3 +451,43 @@ report (FILE *stream, const char *psz_format, ...)
va_end(args);
}
/* Prints "ls"-like file attributes */
void
print_fs_attrs(iso9660_stat_t *p_statbuf, bool b_rock, bool b_xa,
const char *psz_name_untranslated,
const char *psz_name_translated)
{
char date_str[30];
if (yep == p_statbuf->b_rock && b_rock) {
printf ( " %s %d %d [LSN %6lu] ",
iso9660_get_rock_attr_str (p_statbuf->st_mode),
p_statbuf->st_uid,
p_statbuf->st_gid,
(long unsigned int) p_statbuf->lsn);
} else if (b_xa) {
printf ( " %s %d %d [fn %.2d] [LSN %6lu] ",
iso9660_get_xa_attr_str (p_statbuf->xa.attributes),
uint16_from_be (p_statbuf->xa.user_id),
uint16_from_be (p_statbuf->xa.group_id),
p_statbuf->xa.filenum,
(long unsigned int) p_statbuf->lsn);
if (uint16_from_be(p_statbuf->xa.attributes) & XA_ATTR_MODE2FORM2) {
printf ("%9u (%9u)",
(unsigned int) p_statbuf->secsize * M2F2_SECTOR_SIZE,
(unsigned int) p_statbuf->size);
} else
printf ("%9u", (unsigned int) p_statbuf->size);
} else {
printf (" %c %9u",
(p_statbuf->type == _STAT_DIR) ? 'd' : '-',
(unsigned int) p_statbuf->size);
}
strftime(date_str, sizeof(date_str), "%b %d %Y %H:%M ", &p_statbuf->tm);
printf (" %s %s\n", date_str,
yep == p_statbuf->b_rock && b_rock
? psz_name_untranslated : psz_name_translated);
}

View File

@@ -1,7 +1,7 @@
/*
$Id: util.h,v 1.10 2005/01/09 00:10:49 rocky Exp $
$Id: util.h,v 1.11 2005/02/20 10:21:01 rocky Exp $
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
Copyright (C) 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -30,6 +30,7 @@
#include <sys/types.h>
#include <cdio/cdio.h>
#include <cdio/logging.h>
#include <cdio/iso9660.h>
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
@@ -131,4 +132,9 @@ void print_drive_capabilities(cdio_drive_read_cap_t p_read_cap,
it may not be desireable to send output to stdout and stderr. */
void report (FILE *stream, const char *psz_format, ...);
/* Prints "ls"-like file attributes */
void print_fs_attrs(iso9660_stat_t *p_statbuf, bool b_rock, bool b_xa,
const char *psz_name_untranslated,
const char *psz_name_translated);
#endif /* UTIL_H */