#!/usr/local/bin/scripts/sh # # ^^^ pen: # * handle a delegated media, that is not there. # * delegated media aufteilen mit / ohne METHOD ? # #.Y / 70 83 / / / / 105 / / / / / / ;A4_QUER.Y #.YT 3 2 0 0 3 3 1 / / / #.H!a!0:linux//io/disk/mediaAccess/mediaHandlers.d/A8A2BB34_78F0_11E6_B6F3_0000C00A45A9!0.!c # #/******************************************************************************* # io disk mediaAccess mediaHandlers.d/A8A2BB34_78F0_11E6_B6F3_0000C00A45A9 # ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # # purpose : media handler for a delegated media # # begin : Thu Jan 11 21:02:40 CEST 2018 # # changes : # # copyright : (C) 2018 by Thomas Bruecker # # email : public@thomas-r-bruecker.ch # # version : -0.0.0 # #*******************************************************************************/ #/*************************************************************************** # * * # * 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 * # * the Free Software Foundation; either version 2 of the License, or * # * (at your option) any later version. * # * * # * 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. See the GNU * # * General Public License for more details. * # * * # * You should have received a copy of the GNU General Public License * # * along with this program; if not, write to the Free Software * # * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * # * MA 02110-1301 USA. * # * * # ***************************************************************************/ # ***************************************************************************/ # MyHash("A8A2BB34_78F0_11E6_B6F3_0000C00A45A9" = 0x088D_34 # # * for every function: # * if returned result is not commented, the function returns 0 on no-error. Xdisk_mediaAccess_0x088D_34_col__() { # $1: size, # $2: uuid, # $3: prefix; most often: indent, # * writes the size-parameter to "stdout". local MediaHandlerUuid PREFIX SIZE UUID PREFIX="$3" PREFIX1=" $PREFIX0" SIZE="$1" UUID="$2" MediaHandlerUuid="$( echo "${FUNCNAME[1]}" \ | string__SearchAndReplace '^disk_mediaAccess_*' '' \ | string_SearchAndReplace '_' '-' \ )" disk_mediaAccess_0x088D_34_col___ \ "$MediaHandlerUuid" "$SIZE" "$UUID" "$PREFIX" } Xdisk_mediaAccess_0x088D_34_col___() { # $1: media-handler-uuid, # $2: size, # $3: uuid, # $4: prefix; most often: indent, # ^* writes the size-parameter to "stdout". local MediaHandlerUuid PREFIX SIZE UUID MediaHandlerUuid="$1" PREFIX0="$4" PREFIX1=" $PREFIX0" SIZE="$2" UUID="$3" START='8' # ^ # ^ sort parameters. disk_mediaAccess_col__METHOD "$MediaHandlerUuid" "$PREFIX0" disk_mediaAccess_col__CommonParameters "$MediaHandlerUuid" "$PREFIX1" disk_mediaAccess_col__SIZE "$SIZE" "$PREFIX1" disk_mediaAccess_col__START "$START" "$PREFIX1" disk_mediaAccess_col__UUID "$UUID" "$PREFIX1" disk_mediaAccess_col__MethodEnd "$PREFIX0" } disk_mediaAccess_A8A2BB34_78F0_11E6_B6F3_0000C00A45A9() { # handles a general container; # $1: command, in { # "ContainerCommand", "DESTROY", "DestroyMediaInfo", # "DestroyNewComponentMedia", "GetComponentMediaInfo", "Index2Offset", # "2ChildMedia", "NewOffset", "numComponents", "RealizeMediaInfo", # "RealizeNewComponentMedia", "SIZE", "StartOfComponentMedia", # "VERIFY", "WAIT" # }, # * $1 in { "DESTROY", "2ChildMedia", "SIZE", "VERIFY", "WAIT" }: see # "../CommonCommandsSpecification.TXT", # * "ContainerCommand": # execute a command 'for the container'; # $1: , # $2: command, in { # "DestroyMediaInfo", "DestroyNewComponentMedia", # "GetComponentMediaInfo", "Index2Offset", "NewOffset", # "numComponents", "RealizeMediaInfo", # "RealizeNewComponentMedia", "SIZE", "StartOfComponentMedia", # "VERIFY", "WAIT" # }, # $3: ; # * "DestroyMediaInfo": # destroy media info of component media; # $1: , # $2: ; # * "DestroyNewComponentMedia": # destroy the new media immediately after the latest valid component # media; # $1: ; # * "GetComponentMediaInfo": # get media info of a container component, # $2: path to the media (device, file, rootFolder of a filsystem), # $3: index into container, # * writes the media info of the indexed container component to # "stdout"; # * "Index2Offset": # * index to offset; # * gets the offset from the begin of of the component # media that corresponds to the and writes it to "stdout"; # $1: , # $2: ; # * "MaxContainerSize" # writes the maximum possible size of the container, the media-info- # sectors not included, to "stdout"; # $1: ; # * "MaxNewComponentMediaSize": # writes the maximum possible size of a new media immediately after the # latest valid component media, the media-info-sectors not included, to # "stdout"; # $1: ; # * "NewOffset": # gets the offset from the begin of of a possible # component media immediately after the latest valid component media # and writes it to "stdout"; # $1: ; # * "numComponents": # * #components; # * writes the number of component medias in the container to "stdout"; # $1: ; # * "RealizeMediaInfo": # realize media info of component media; # $1: , # $2: ; # * "RealizeNewComponentMedia": # * realize a new media immediately after the latest valid component # media and writes it to "stdout", # * the new media is realized including the media-info-sectors; # $1: ; # * "StartOfComponentMedia": # writes the start offset of the component media to "stdout"; # $1: , # $2: ; # * "_:": ^verify command, # ^$2: path to the media (device, file, rootFolder of a filsystem), # ^$3: index into container, # * "__:": ^verify command, # $2: media-handler-uuid, # $3: size, # $4: uuid, # $5: prefix, most often: indent; # ^* writes the size-parameter to "stdout". local COMMAND INDEX MediaInfo ParentMedia ParentMediaPath COMMAND="$1" INDEX="$2" MediaInfo="$3" ParentMedia="$4" ParentMediaPath="$5" # echo $COMMAND >>/dev/stderr # echo $INDEX >>/dev/stderr # echo "$MediaInfo" >>/dev/stderr # echo $ParentMedia >>/dev/stderr # echo $ParentMediaPath >>/dev/stderr case "$COMMAND" in SIZE) disk_mediaAccess__Size1 ;; VERIFY) return 0 ;; _GetXlatedMediaInfo) disk_mediaAccess__0x088D_34_GetMediaInfoOfDelegatedMedia \ "$INDEX" "$MediaInfo" "$ParentMedia" "$ParentMediaPath" ;; # _:) # shift 1 # disk_mediaAccess_0x088D_34_col__ "$@" ;; # ^ # __:) # shift 1 # disk_mediaAccess_0x088D_34_col___ "$@" ;; # ^ *) shift 5 disk_mediaAccess__0x088D_34_PassCommand2DelegatedMedia \ "$COMMAND" \ "$INDEX" "$MediaInfo" "$ParentMedia" "$ParentMediaPath" "$@" ;; # "disk_mediaAccess__InvalidCommandError" is handled by the # delegated media(-handler). esac # return result of previous } # command. Xdisk_mediaAccess_col__LINEAR() { # ': _LINEAR' # $1: size, # $2: uuid, # $3: prefix; most often: indent, # * writes the size-parameter to "stdout". disk_mediaAccess__A8A2BB34_78F0_11E6_B6F3_0000C00A45A9 "_:" "$@" } Xdisk_mediaAccess_col___LINEAR() { # ': __LINEAR' # $1: media-handler-uuid, # $2: size, # $3: uuid, # $4: prefix; most often: indent, # ^* writes the size-parameter to "stdout". disk_mediaAccess__A8A2BB34_78F0_11E6_B6F3_0000C00A45A9 "__:" "$@" } disk_mediaAccess__0x088D_34_GetMediaInfoOfDelegatedMedia() { #^ * realize a new media immediately after the latest valid component media # and writes it to "stdout", # * the new media is realized including the media-info-sectors; # $1: , # $2: , # $3: , # $4: . # global: MediaInfoCommand0x0EAA local INDEX MediaInfo ParametersFile ParentMedia ParentMediaPath local TargetMediaHandlerUuid TargetMediaInfo # parameters: local TargetMedia INDEX="$1" MediaInfo="$2" ParentMedia="$3" ParentMediaPath="$4" # echo $INDEX >>/dev/stderr # echo "$MediaInfo" >>/dev/stderr # echo $ParentMedia >>/dev/stderr # echo $ParentMediaPath >>/dev/stderr ParametersFile="$(disk_mediaAccess__Parameters2File "$MediaInfo")" \ || return # return on error. . "$ParametersFile" || return # return on error. TargetMediaHandlerUuid="$( disk_mediaAccess____GetMediaHandlerUuid \ "$INDEX" "$MediaInfo" "$ParentMediaPath" 'Method' )" || return # return on error. TargetMediaInfo="$( echo -n "$MediaInfo" | "$MediaInfoCommand0x0EAA" 'MediaInfo' 'Method' )" || return # return on error. # echo $TargetMedia >>/dev/stderr # echo $TargetMediaHandlerUuid >>/dev/stderr # echo "$TargetMediaInfo" >>/dev/stderr disk_mediaAccess___VerifyMediaHandlerUuid \ "$INDEX" \ "$TargetMediaHandlerUuid" "$ParentMedia" "$ParentMediaPath" 'Method' \ || return # return on error. echo "$TargetMediaInfo" } disk_mediaAccess__0x088D_34_PassCommand2DelegatedMedia() { #^ * realize a new media immediately after the latest valid component media # and writes it to "stdout", # * the new media is realized including the media-info-sectors; # $1: command, # $2: , # $3: , # $4: , # $5: . local COMMAND ChildDevPath ChildMedia INDEX MediaInfo ParametersFile local ParentMedia ParentMediaPath RESULT TargetMediaHandlerUuid local TargetMediaInfo TargetMediaPath # parameters: local TargetMedia COMMAND="$1" INDEX="$2" MediaInfo="$3" ParentMedia="$4" ParentMediaPath="$5" shift 5 # echo $COMMAND >>/dev/stderr # echo $INDEX >>/dev/stderr # echo "$MediaInfo" >>/dev/stderr # echo $ParentMedia >>/dev/stderr # echo $ParentMediaPath >>/dev/stderr ParametersFile="$(disk_mediaAccess__Parameters2File "$MediaInfo")" \ || return # return on error. . "$ParametersFile" || return # return on error. TargetMediaHandlerUuid="$( disk_mediaAccess____GetMediaHandlerUuid \ "$INDEX" "$MediaInfo" "$ParentMediaPath" 'Method' )" || return # return on error. # echo $TargetMediaHandlerUuid >>/dev/stderr TargetMediaInfo="$( disk_mediaAccess__0x088D_34_GetMediaInfoOfDelegatedMedia \ "$INDEX" "$MediaInfo" "$ParentMedia" "$ParentMediaPath" )" || return # return on error. # the "TargetMediaHandlerUuid" is verified by the above command. # echo "$TargetMediaInfo" >>/dev/stderr # echo $TargetMedia >>/dev/stderr TargetMediaPath="$(disk_mediaAccess___Media2AbsolutePath "$TargetMedia")" \ || return # return on error. # echo $TargetMediaPath >>/dev/stderr ChildMedia="$( disk_mediaAccess_${TargetMediaHandlerUuid} \ "$COMMAND" \ "$INDEX" "$TargetMediaInfo" "$TargetMedia" "$TargetMediaPath" "$@" )" || return # return on error. RESULT="$?" case "$COMMAND" in REALIZE|RealizeForced) ChildDevPath="$( disk_mediaAccess___Media2AbsolutePath "$ChildMedia" )" || return # return on error. # echo $ChildDevPath >>/dev/stderr disk_mediaAccess___WriteReverseMapEntry \ "$ChildDevPath" "$INDEX" "$ParentMediaPath" ;; esac echo "$ChildMedia" return "$RESULT" }