This file is indexed.

/usr/share/pyshared/CedarBackup2/writers/util.py is in cedar-backup2 2.27.0-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
# -*- coding: iso-8859-1 -*-
# vim: set ft=python ts=3 sw=3 expandtab:
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
#              C E D A R
#          S O L U T I O N S       "Software done right."
#           S O F T W A R E
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# Copyright (c) 2004-2007,2010 Kenneth J. Pronovici.
# All rights reserved.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License,
# Version 2, as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# Copies of the GNU General Public License are available from
# the Free Software Foundation website, http://www.gnu.org/.
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# Author   : Kenneth J. Pronovici <pronovic@ieee.org>
# Language : Python 2 (>= 2.7)
# Project  : Cedar Backup, release 2
# Purpose  : Provides utilities related to image writers.
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

########################################################################
# Module documentation
########################################################################

"""
Provides utilities related to image writers.
@author: Kenneth J. Pronovici <pronovic@ieee.org>
"""


########################################################################
# Imported modules
########################################################################

# System modules
import os
import re
import logging

# Cedar Backup modules
from CedarBackup2.util import resolveCommand, executeCommand
from CedarBackup2.util import convertSize, UNIT_BYTES, UNIT_SECTORS, encodePath


########################################################################
# Module-wide constants and variables
########################################################################

logger = logging.getLogger("CedarBackup2.log.writers.util")

MKISOFS_COMMAND      = [ "mkisofs", ]
VOLNAME_COMMAND      = [ "volname", ]


########################################################################
# Functions used to portably validate certain kinds of values
########################################################################

############################
# validateDevice() function
############################

def validateDevice(device, unittest=False):
   """
   Validates a configured device.
   The device must be an absolute path, must exist, and must be writable.
   The unittest flag turns off validation of the device on disk.
   @param device: Filesystem device path.
   @param unittest: Indicates whether we're unit testing.
   @return: Device as a string, for instance C{"/dev/cdrw"}
   @raise ValueError: If the device value is invalid.
   @raise ValueError: If some path cannot be encoded properly.
   """
   if device is None:
      raise ValueError("Device must be filled in.")
   device = encodePath(device)
   if not os.path.isabs(device):
      raise ValueError("Backup device must be an absolute path.")
   if not unittest and not os.path.exists(device):
      raise ValueError("Backup device must exist on disk.")
   if not unittest and not os.access(device, os.W_OK):
      raise ValueError("Backup device is not writable by the current user.")
   return device


############################
# validateScsiId() function
############################

def validateScsiId(scsiId):
   """
   Validates a SCSI id string.
   SCSI id must be a string in the form C{[<method>:]scsibus,target,lun}.
   For Mac OS X (Darwin), we also accept the form C{IO.*Services[/N]}.
   @note: For consistency, if C{None} is passed in, C{None} will be returned.
   @param scsiId: SCSI id for the device.
   @return: SCSI id as a string, for instance C{"ATA:1,0,0"}
   @raise ValueError: If the SCSI id string is invalid.
   """
   if scsiId is not None:
      pattern = re.compile(r"^\s*(.*:)?\s*[0-9][0-9]*\s*,\s*[0-9][0-9]*\s*,\s*[0-9][0-9]*\s*$")
      if not pattern.search(scsiId):
         pattern = re.compile(r"^\s*IO.*Services(\/[0-9][0-9]*)?\s*$")
         if not pattern.search(scsiId):
            raise ValueError("SCSI id is not in a valid form.")
   return scsiId


################################
# validateDriveSpeed() function
################################

def validateDriveSpeed(driveSpeed):
   """
   Validates a drive speed value.
   Drive speed must be an integer which is >= 1.
   @note: For consistency, if C{None} is passed in, C{None} will be returned.
   @param driveSpeed: Speed at which the drive writes.
   @return: Drive speed as an integer
   @raise ValueError: If the drive speed value is invalid.
   """
   if driveSpeed is None:
      return None
   try:
      intSpeed = int(driveSpeed)
   except TypeError:
      raise ValueError("Drive speed must be an integer >= 1.")
   if intSpeed < 1:
      raise ValueError("Drive speed must an integer >= 1.")
   return intSpeed


########################################################################
# General writer-related utility functions
########################################################################

############################
# readMediaLabel() function
############################

def readMediaLabel(devicePath):
   """
   Reads the media label (volume name) from the indicated device.
   The volume name is read using the C{volname} command.
   @param devicePath: Device path to read from
   @return: Media label as a string, or None if there is no name or it could not be read.
   """
   args = [ devicePath, ]
   command = resolveCommand(VOLNAME_COMMAND)
   (result, output) = executeCommand(command, args, returnOutput=True, ignoreStderr=True)
   if result != 0:
      return None
   if output is None or len(output) < 1:
      return None
   return output[0].rstrip()


########################################################################
# IsoImage class definition
########################################################################

class IsoImage(object):

   ######################
   # Class documentation
   ######################

   """
   Represents an ISO filesystem image.

   Summary
   =======

      This object represents an ISO 9660 filesystem image.  It is implemented
      in terms of the C{mkisofs} program, which has been ported to many
      operating systems and platforms.  A "sensible subset" of the C{mkisofs}
      functionality is made available through the public interface, allowing
      callers to set a variety of basic options such as publisher id,
      application id, etc. as well as specify exactly which files and
      directories they want included in their image.

      By default, the image is created using the Rock Ridge protocol (using the
      C{-r} option to C{mkisofs}) because Rock Ridge discs are generally more
      useful on UN*X filesystems than standard ISO 9660 images.  However,
      callers can fall back to the default C{mkisofs} functionality by setting
      the C{useRockRidge} instance variable to C{False}.  Note, however, that
      this option is not well-tested.

   Where Files and Directories are Placed in the Image
   ===================================================

      Although this class is implemented in terms of the C{mkisofs} program,
      its standard "image contents" semantics are slightly different than the original
      C{mkisofs} semantics.  The difference is that files and directories are
      added to the image with some additional information about their source
      directory kept intact.

      As an example, suppose you add the file C{/etc/profile} to your image and
      you do not configure a graft point.  The file C{/profile} will be created
      in the image.  The behavior for directories is similar.  For instance,
      suppose that you add C{/etc/X11} to the image and do not configure a
      graft point.  In this case, the directory C{/X11} will be created in the
      image, even if the original C{/etc/X11} directory is empty.  I{This
      behavior differs from the standard C{mkisofs} behavior!}

      If a graft point is configured, it will be used to modify the point at
      which a file or directory is added into an image.  Using the examples
      from above, let's assume you set a graft point of C{base} when adding
      C{/etc/profile} and C{/etc/X11} to your image.  In this case, the file
      C{/base/profile} and the directory C{/base/X11} would be added to the
      image.

      I feel that this behavior is more consistent than the original C{mkisofs}
      behavior.  However, to be fair, it is not quite as flexible, and some
      users might not like it.  For this reason, the C{contentsOnly} parameter
      to the L{addEntry} method can be used to revert to the original behavior
      if desired.

   @sort: __init__, addEntry, getEstimatedSize, _getEstimatedSize, writeImage,
          _buildDirEntries _buildGeneralArgs, _buildSizeArgs, _buildWriteArgs,
          device, boundaries, graftPoint, useRockRidge, applicationId,
          biblioFile, publisherId, preparerId, volumeId
   """

   ##############
   # Constructor
   ##############

   def __init__(self, device=None, boundaries=None, graftPoint=None):
      """
      Initializes an empty ISO image object.

      Only the most commonly-used configuration items can be set using this
      constructor.  If you have a need to change the others, do so immediately
      after creating your object.

      The device and boundaries values are both required in order to write
      multisession discs.  If either is missing or C{None}, a multisession disc
      will not be written.  The boundaries tuple is in terms of ISO sectors, as
      built by an image writer class and returned in a L{writer.MediaCapacity}
      object.

      @param device: Name of the device that the image will be written to
      @type device: Either be a filesystem path or a SCSI address

      @param boundaries: Session boundaries as required by C{mkisofs}
      @type boundaries: Tuple C{(last_sess_start,next_sess_start)} as returned from C{cdrecord -msinfo}, or C{None}

      @param graftPoint: Default graft point for this page.
      @type graftPoint: String representing a graft point path (see L{addEntry}).
      """
      self._device = None
      self._boundaries = None
      self._graftPoint = None
      self._useRockRidge = True
      self._applicationId = None
      self._biblioFile = None
      self._publisherId = None
      self._preparerId = None
      self._volumeId = None
      self.entries = { }
      self.device = device
      self.boundaries = boundaries
      self.graftPoint = graftPoint
      self.useRockRidge = True
      self.applicationId = None
      self.biblioFile = None
      self.publisherId = None
      self.preparerId = None
      self.volumeId = None
      logger.debug("Created new ISO image object.")


   #############
   # Properties
   #############

   def _setDevice(self, value):
      """
      Property target used to set the device value.
      If not C{None}, the value can be either an absolute path or a SCSI id.
      @raise ValueError: If the value is not valid
      """
      try:
         if value is None:
            self._device = None
         else:
            if os.path.isabs(value):
               self._device = value
            else:
               self._device = validateScsiId(value)
      except ValueError:
         raise ValueError("Device must either be an absolute path or a valid SCSI id.")

   def _getDevice(self):
      """
      Property target used to get the device value.
      """
      return self._device

   def _setBoundaries(self, value):
      """
      Property target used to set the boundaries tuple.
      If not C{None}, the value must be a tuple of two integers.
      @raise ValueError: If the tuple values are not integers.
      @raise IndexError: If the tuple does not contain enough elements.
      """
      if value is None:
         self._boundaries = None
      else:
         self._boundaries = (int(value[0]), int(value[1]))

   def _getBoundaries(self):
      """
      Property target used to get the boundaries value.
      """
      return self._boundaries

   def _setGraftPoint(self, value):
      """
      Property target used to set the graft point.
      The value must be a non-empty string if it is not C{None}.
      @raise ValueError: If the value is an empty string.
      """
      if value is not None:
         if len(value) < 1:
            raise ValueError("The graft point must be a non-empty string.")
      self._graftPoint = value

   def _getGraftPoint(self):
      """
      Property target used to get the graft point.
      """
      return self._graftPoint

   def _setUseRockRidge(self, value):
      """
      Property target used to set the use RockRidge flag.
      No validations, but we normalize the value to C{True} or C{False}.
      """
      if value:
         self._useRockRidge = True
      else:
         self._useRockRidge = False

   def _getUseRockRidge(self):
      """
      Property target used to get the use RockRidge flag.
      """
      return self._useRockRidge

   def _setApplicationId(self, value):
      """
      Property target used to set the application id.
      The value must be a non-empty string if it is not C{None}.
      @raise ValueError: If the value is an empty string.
      """
      if value is not None:
         if len(value) < 1:
            raise ValueError("The application id must be a non-empty string.")
      self._applicationId = value

   def _getApplicationId(self):
      """
      Property target used to get the application id.
      """
      return self._applicationId

   def _setBiblioFile(self, value):
      """
      Property target used to set the biblio file.
      The value must be a non-empty string if it is not C{None}.
      @raise ValueError: If the value is an empty string.
      """
      if value is not None:
         if len(value) < 1:
            raise ValueError("The biblio file must be a non-empty string.")
      self._biblioFile = value

   def _getBiblioFile(self):
      """
      Property target used to get the biblio file.
      """
      return self._biblioFile

   def _setPublisherId(self, value):
      """
      Property target used to set the publisher id.
      The value must be a non-empty string if it is not C{None}.
      @raise ValueError: If the value is an empty string.
      """
      if value is not None:
         if len(value) < 1:
            raise ValueError("The publisher id must be a non-empty string.")
      self._publisherId = value

   def _getPublisherId(self):
      """
      Property target used to get the publisher id.
      """
      return self._publisherId

   def _setPreparerId(self, value):
      """
      Property target used to set the preparer id.
      The value must be a non-empty string if it is not C{None}.
      @raise ValueError: If the value is an empty string.
      """
      if value is not None:
         if len(value) < 1:
            raise ValueError("The preparer id must be a non-empty string.")
      self._preparerId = value

   def _getPreparerId(self):
      """
      Property target used to get the preparer id.
      """
      return self._preparerId

   def _setVolumeId(self, value):
      """
      Property target used to set the volume id.
      The value must be a non-empty string if it is not C{None}.
      @raise ValueError: If the value is an empty string.
      """
      if value is not None:
         if len(value) < 1:
            raise ValueError("The volume id must be a non-empty string.")
      self._volumeId = value

   def _getVolumeId(self):
      """
      Property target used to get the volume id.
      """
      return self._volumeId

   device = property(_getDevice, _setDevice, None, "Device that image will be written to (device path or SCSI id).")
   boundaries = property(_getBoundaries, _setBoundaries, None, "Session boundaries as required by C{mkisofs}.")
   graftPoint = property(_getGraftPoint, _setGraftPoint, None, "Default image-wide graft point (see L{addEntry} for details).")
   useRockRidge = property(_getUseRockRidge, _setUseRockRidge, None, "Indicates whether to use RockRidge (default is C{True}).")
   applicationId = property(_getApplicationId, _setApplicationId, None, "Optionally specifies the ISO header application id value.")
   biblioFile = property(_getBiblioFile, _setBiblioFile, None, "Optionally specifies the ISO bibliographic file name.")
   publisherId = property(_getPublisherId, _setPublisherId, None, "Optionally specifies the ISO header publisher id value.")
   preparerId = property(_getPreparerId, _setPreparerId, None, "Optionally specifies the ISO header preparer id value.")
   volumeId = property(_getVolumeId, _setVolumeId, None, "Optionally specifies the ISO header volume id value.")


   #########################
   # General public methods
   #########################

   def addEntry(self, path, graftPoint=None, override=False, contentsOnly=False):
      """
      Adds an individual file or directory into the ISO image.

      The path must exist and must be a file or a directory.  By default, the
      entry will be placed into the image at the root directory, but this
      behavior can be overridden using the C{graftPoint} parameter or instance
      variable.

      You can use the C{contentsOnly} behavior to revert to the "original"
      C{mkisofs} behavior for adding directories, which is to add only the
      items within the directory, and not the directory itself.

      @note: Things get I{odd} if you try to add a directory to an image that
      will be written to a multisession disc, and the same directory already
      exists in an earlier session on that disc.  Not all of the data gets
      written.  You really wouldn't want to do this anyway, I guess.

      @note: An exception will be thrown if the path has already been added to
      the image, unless the C{override} parameter is set to C{True}.

      @note: The method C{graftPoints} parameter overrides the object-wide
      instance variable.  If neither the method parameter or object-wide value
      is set, the path will be written at the image root.  The graft point
      behavior is determined by the value which is in effect I{at the time this
      method is called}, so you I{must} set the object-wide value before
      calling this method for the first time, or your image may not be
      consistent.

      @note: You I{cannot} use the local C{graftPoint} parameter to "turn off"
      an object-wide instance variable by setting it to C{None}.  Python's
      default argument functionality buys us a lot, but it can't make this
      method psychic. :)

      @param path: File or directory to be added to the image
      @type path: String representing a path on disk

      @param graftPoint: Graft point to be used when adding this entry
      @type graftPoint: String representing a graft point path, as described above

      @param override: Override an existing entry with the same path.
      @type override: Boolean true/false

      @param contentsOnly: Add directory contents only (standard C{mkisofs} behavior).
      @type contentsOnly: Boolean true/false

      @raise ValueError: If path is not a file or directory, or does not exist.
      @raise ValueError: If the path has already been added, and override is not set.
      @raise ValueError: If a path cannot be encoded properly.
      """
      path = encodePath(path)
      if not override:
         if path in self.entries.keys():
            raise ValueError("Path has already been added to the image.")
      if os.path.islink(path):
         raise ValueError("Path must not be a link.")
      if os.path.isdir(path):
         if graftPoint is not None:
            if contentsOnly:
               self.entries[path] = graftPoint
            else:
               self.entries[path] = os.path.join(graftPoint, os.path.basename(path))
         elif self.graftPoint is not None:
            if contentsOnly:
               self.entries[path] = self.graftPoint
            else:
               self.entries[path] = os.path.join(self.graftPoint, os.path.basename(path))
         else:
            if contentsOnly:
               self.entries[path] = None
            else:
               self.entries[path] = os.path.basename(path)
      elif os.path.isfile(path):
         if graftPoint is not None:
            self.entries[path] = graftPoint
         elif self.graftPoint is not None:
            self.entries[path] = self.graftPoint
         else:
            self.entries[path] = None
      else:
         raise ValueError("Path must be a file or a directory.")

   def getEstimatedSize(self):
      """
      Returns the estimated size (in bytes) of the ISO image.

      This is implemented via the C{-print-size} option to C{mkisofs}, so it
      might take a bit of time to execute.  However, the result is as accurate
      as we can get, since it takes into account all of the ISO overhead, the
      true cost of directories in the structure, etc, etc.

      @return: Estimated size of the image, in bytes.

      @raise IOError: If there is a problem calling C{mkisofs}.
      @raise ValueError: If there are no filesystem entries in the image
      """
      if len(self.entries.keys()) == 0:
         raise ValueError("Image does not contain any entries.")
      return self._getEstimatedSize(self.entries)

   def _getEstimatedSize(self, entries):
      """
      Returns the estimated size (in bytes) for the passed-in entries dictionary.
      @return: Estimated size of the image, in bytes.
      @raise IOError: If there is a problem calling C{mkisofs}.
      """
      args = self._buildSizeArgs(entries)
      command = resolveCommand(MKISOFS_COMMAND)
      (result, output) = executeCommand(command, args, returnOutput=True, ignoreStderr=True)
      if result != 0:
         raise IOError("Error (%d) executing mkisofs command to estimate size." % result)
      if len(output) != 1:
         raise IOError("Unable to parse mkisofs output.")
      try:
         sectors = float(output[0])
         size = convertSize(sectors, UNIT_SECTORS, UNIT_BYTES)
         return size
      except:
         raise IOError("Unable to parse mkisofs output.")

   def writeImage(self, imagePath):
      """
      Writes this image to disk using the image path.

      @param imagePath: Path to write image out as
      @type imagePath: String representing a path on disk

      @raise IOError: If there is an error writing the image to disk.
      @raise ValueError: If there are no filesystem entries in the image
      @raise ValueError: If a path cannot be encoded properly.
      """
      imagePath = encodePath(imagePath)
      if len(self.entries.keys()) == 0:
         raise ValueError("Image does not contain any entries.")
      args = self._buildWriteArgs(self.entries, imagePath)
      command = resolveCommand(MKISOFS_COMMAND)
      (result, output) = executeCommand(command, args, returnOutput=False)
      if result != 0:
         raise IOError("Error (%d) executing mkisofs command to build image." % result)


   #########################################
   # Methods used to build mkisofs commands
   #########################################

   @staticmethod
   def _buildDirEntries(entries):
      """
      Uses an entries dictionary to build a list of directory locations for use
      by C{mkisofs}.

      We build a list of entries that can be passed to C{mkisofs}.  Each entry is
      either raw (if no graft point was configured) or in graft-point form as
      described above (if a graft point was configured).  The dictionary keys
      are the path names, and the values are the graft points, if any.

      @param entries: Dictionary of image entries (i.e. self.entries)

      @return: List of directory locations for use by C{mkisofs}
      """
      dirEntries = []
      for key in entries.keys():
         if entries[key] is None:
            dirEntries.append(key)
         else:
            dirEntries.append("%s/=%s" % (entries[key].strip("/"), key))
      return dirEntries

   def _buildGeneralArgs(self):
      """
      Builds a list of general arguments to be passed to a C{mkisofs} command.

      The various instance variables (C{applicationId}, etc.) are filled into
      the list of arguments if they are set.
      By default, we will build a RockRidge disc.  If you decide to change
      this, think hard about whether you know what you're doing.  This option
      is not well-tested.

      @return: List suitable for passing to L{util.executeCommand} as C{args}.
      """
      args = []
      if self.applicationId is not None:
         args.append("-A")
         args.append(self.applicationId)
      if self.biblioFile is not None:
         args.append("-biblio")
         args.append(self.biblioFile)
      if self.publisherId is not None:
         args.append("-publisher")
         args.append(self.publisherId)
      if self.preparerId is not None:
         args.append("-p")
         args.append(self.preparerId)
      if self.volumeId is not None:
         args.append("-V")
         args.append(self.volumeId)
      return args

   def _buildSizeArgs(self, entries):
      """
      Builds a list of arguments to be passed to a C{mkisofs} command.

      The various instance variables (C{applicationId}, etc.) are filled into
      the list of arguments if they are set.  The command will be built to just
      return size output (a simple count of sectors via the C{-print-size} option),
      rather than an image file on disk.

      By default, we will build a RockRidge disc.  If you decide to change
      this, think hard about whether you know what you're doing.  This option
      is not well-tested.

      @param entries: Dictionary of image entries (i.e. self.entries)

      @return: List suitable for passing to L{util.executeCommand} as C{args}.
      """
      args = self._buildGeneralArgs()
      args.append("-print-size")
      args.append("-graft-points")
      if self.useRockRidge:
         args.append("-r")
      if self.device is not None and self.boundaries is not None:
         args.append("-C")
         args.append("%d,%d" % (self.boundaries[0], self.boundaries[1]))
         args.append("-M")
         args.append(self.device)
      args.extend(self._buildDirEntries(entries))
      return args

   def _buildWriteArgs(self, entries, imagePath):
      """
      Builds a list of arguments to be passed to a C{mkisofs} command.

      The various instance variables (C{applicationId}, etc.) are filled into
      the list of arguments if they are set.  The command will be built to write
      an image to disk.

      By default, we will build a RockRidge disc.  If you decide to change
      this, think hard about whether you know what you're doing.  This option
      is not well-tested.

      @param entries: Dictionary of image entries (i.e. self.entries)

      @param imagePath: Path to write image out as
      @type imagePath: String representing a path on disk

      @return: List suitable for passing to L{util.executeCommand} as C{args}.
      """
      args = self._buildGeneralArgs()
      args.append("-graft-points")
      if self.useRockRidge:
         args.append("-r")
      args.append("-o")
      args.append(imagePath)
      if self.device is not None and self.boundaries is not None:
         args.append("-C")
         args.append("%d,%d" % (self.boundaries[0], self.boundaries[1]))
         args.append("-M")
         args.append(self.device)
      args.extend(self._buildDirEntries(entries))
      return args