bug-xorriso
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-xorriso] How can I calculate the max. Filesize with a given ava


From: Thomas Schmitt
Subject: Re: [Bug-xorriso] How can I calculate the max. Filesize with a given available sector count?
Date: Tue, 03 Mar 2015 18:06:50 +0100

Hi,

> Now I want to record only one file to this disc with maximum usable
> size. ISO9660 has some overhead, lead-in, lead-out,...
> How can I get the max. usable size for a file in ISO9660?

It depends on many parameters.


> Is there a parameter for xorriso that tells the programm 'look here
> we have a disc with 336073 sectors tell me the free space in an iso9660
> with rockridge extension for this sized disc'?

Terminology:
xorriso has commands which may have parameters.
E.g. command -outdev, expects a single parameter, e.g. /dev/sr0.

Among the commands are -print_size, -rollback, -tell_media_space.
-print_size makes realistic preparations for image production,
issues a line like
  Image size   : 76723s
and revokes the image production before anything gets written.
Nevertheless, xorriso would start again image production when
it ends, unless -rollback revokes the pending changes.

E.g. this run
 
  reply=$(xorriso -report_about WARNING -outdev /dev/null \
                  -map "$HOME"/my_file /my_file \
                  -print_size -rollback)

makes what is necessary to predict the size and puts
into shell variable "reply" a line like

  Image size : 76723s

This line may be further processed by shell means

  blocks_needed=$(echo "$reply" | sed -e 's/Image size   : //' -e 's/s$//')

Now the shell can decide the question whether it will fit

  if test "$blocks_needed" -gt "$blocks_offered"
  then
     echo "Will NOT fit." >&2
     ...act.somehow...
  fi

-report_about WARNING lifts the threshold for messages on
stderr, so that only warnings and error messages will
be emitted. Use -report_about SORRY to get rid of warnings,
too.

There is a similar feature with the mkisofs emulation:

  blocks_needed=$(xorriso -as mkisofs -print-size -J "$HOME"/my_file)

--------------------------------------------------------------

Both methods depend on your external assessment of free
space on the medium. But since xorriso understands optical
media, you may leave that task to it:

  reply=$(xorriso -report_about WARNING -dev /dev/sr0 \
                  -map "$HOME"/my_file /my_file \
                  -tell_media_space -rollback)

yields in "reply" two lines like

  Media space  : 736800s
  After commit : 652096s

or in case of overflow

  Media space  : 736800s
  After commit : -1406176s

So a test for insufficient space is

  if echo "$reply" | fgrep 'After commit : -' >/dev/null
  then
     echo "Will NOT fit." >&2
     ...act.somehow...
  fi

This accounts for existing sessions on the medium. Above
example was exercised with a DVD+RW with 3 sessions on it.


Have a nice day :)

Thomas




reply via email to

[Prev in Thread] Current Thread [Next in Thread]