#!/usr/local/bin/scripts/sh # #.YT 3 2 0 0 3 3 1 / / / #.H!a!0:linux//io/disk_/mediaAccess_/mediaHandlers.d/A8A2BB42_78F0_11E6_B6F3_0000C00A45A9!0.!c # #/******************************************************************************* # io disk_ mediaAccess_ mediaHandlers.d/A8A2BB42_78F0_11E6_B6F3_0000C00A45A9 # +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # # purpose : media handler for a container that contains only # thin devices. # # begin : Sat Oct 3 17:10:47 CEST 2020 # # changes : # # copyright : (C) 2020 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("A8A2BB42_78F0_11E6_B6F3_0000C00A45A9" = 0x088C_42 # # * for every function: # * if returned result is not commented, the function returns 0 on no-error. . "/${SCRIPTS}/memory/THIS" Xdisk_mediaAccess_0x088C_42_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_0x088C_42_col___ \ "$MediaHandlerUuid" "$SIZE" "$UUID" "$PREFIX" } Xdisk_mediaAccess_0x088C_42_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_A8A2BB42_78F0_11E6_B6F3_0000C00A45A9() { # handles a container that contains only thin devices; # $1: command, in { # "CHECK", "ContainerCommand", "DESTROY", "GetComponentMediaInfo", # "GetComponentMediaInfoOffsetPathPair", "numComponents", "REPAIR", # "SIZE", "SYNC", "VERIFY", "WAIT" # }, # * $1 in { "DESTROY", "SIZE", "VERIFY", "WAIT" }: see # "../CommonCommandsSpecification.TXT"; # * "ContainerCommand": # execute a command 'for the container'; # $2: , # $3: , # $4: , # $5: , # $6: command, in { # "CHECK", "DESTROY", "GetComponentMediaInfo", # "GetComponentMediaInfoOffsetPathPair", "numComponents", # "REPAIR", "SIZE", "SYNC", "VERIFY", "WAIT" # }, # $7: ; # * "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"; # * "numComponents": # * #components; # * writes the number of component medias in the container to "stdout", # $1: ; # * "_:": ^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 # quick, for verifying and 'wait': disk_mediaAccess__VerifyNoWait "$COMMAND" && return 0 # if ok, return 0; no # waiting for component # medias at all. case "$COMMAND" in CHECK|REPAIR) return 0 ;; ContainerCommand) COMMAND="$6" INDEX="$7" shift 7 disk_mediaAccess__0x088C_42_ContainerCommand \ "$COMMAND" \ "$INDEX" "$MediaInfo" "$ParentMedia" "$ParentMediaPath" "$@" ;; DESTROY) return 0; ;; GetComponentMediaInfo) disk_mediaAccess__0x088C_42_GetComponentMediaInfo \ "$INDEX" "$MediaInfo" "$ParentMedia" ;; GetComponentMediaInfoOffsetPathPair) disk_mediaAccess__0x088C_42_GetComponentMediaInfoOffsetPathPair ;; numComponents) disk_mediaAccess__0x088C_42_numComponents \ "$MediaInfo" ;; # #components. SIZE) disk_mediaAccess__Size0 '0' "$MediaInfo" ;; SYNC) disk_mediaAccess__0x088C_42_SYNC ;; # _:) # shift 1 # disk_mediaAccess_0x088C_42_col__ "$@" # ;; # ^ # __:) # shift 1 # disk_mediaAccess_0x088C_42_col___ "$@" # ;; # ^ # ok. *) disk_mediaAccess__InvalidCommandError \ "$COMMAND" "$INDEX" \ 'A8A2BB42_78F0_11E6_B6F3_0000C00A45A9' \ "$ParentMedia" ;; esac # return result of previous } # command. disk_mediaAccess__0x088C_42_ContainerCommand() { # execute a command 'for the container'; # $1: command, in { # "CHECK", "DESTROY", "GetComponentMediaInfo", # "GetComponentMediaInfoOffsetPathPair", "numComponents", "REPAIR", # "SIZE", "SYNC", "VERIFY", "WAIT" # }, # $2: , # $3: , # $4: , # $5: , # $@: ... . local COMMAND INDEX MediaInfo ParentMedia ParentMediaPath 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 disk_mediaAccess_A8A2BB42_78F0_11E6_B6F3_0000C00A45A9 \ "$COMMAND" "$INDEX" "$MediaInfo" "$ParentMedia" "$ParentMediaPath" "$@" } disk_mediaAccess__0x088C_42_GetComponentMediaInfo() { # * gets the raw 4096 bytes media-info at the begin of the component media # that corresponds to the and writes it to "stdout", # * returns "0" (true) if the media info is available; # $1: , # $2: , # $3: . # global: DisksByUuidMountPath0x10B8 local INDEX MediaInfo MediaInfoName MediaInfoPath ParametersFile local ParentMedia # parameters: local UUID INDEX="$1" MediaInfo="$2" ParentMedia="$3" # echo $INDEX >>/dev/stderr # echo $MediaInfo >>/dev/stderr # echo $ParentMedia >>/dev/stderr ParametersFile="$(disk_mediaAccess__Parameters2File "$MediaInfo")" \ || return # return on error. . "$ParametersFile" || return # return on error. # echo $BaseUuid >>/dev/stderr # echo $PoolMedia >>/dev/stderr # echo ${NOTES[@]} >>/dev/stderr # echo ${RealizationOptions[@]} >>/dev/stderr # echo ${SIZES[@]} >>/dev/stderr if [ "$INDEX" -gt "$numComponents" ] || [ -z "${SIZES[$INDEX]}" ]; then echo -en "\nError: \"$ParentMedia\" " >>/dev/stderr echo -e "Has Invalid Media Info at Index \"$INDEX\".\n" >>/dev/stderr return 127 fi echo '{A8A2BB31-78F0-11E6-B6F3-0000C00A45A9}(' echo " COPYRIGHT='(C) 2020 by Thomas Bruecker; '" echo " CopyrightDetails='http://www.storage-media-access.ch/.licenses/MediaInfo.html'" [ -z "${NOTES[$INDEX]}" ] || \ echo " NOTES='${NOTES[$INDEX]}'" echo " PoolMedia='$PoolMedia'" [ -z "${RealizationOptions[$INDEX]}" ] || \ echo " RealizationOptions='${RealizationOptions[$INDEX]}'" echo " SIZE='${SIZES[$INDEX]}'" echo " ThinId='$INDEX'" echo " URL='http://www.storage-media-access.ch/{a8a2bb31-78f0-11e6-b6f3-0000c00a45a9}'" echo " UUID='$BaseUuid.$INDEX'" echo ')' } disk_mediaAccess__0x088C_42_GetComponentMediaInfoOffsetPathPair() { # * gets the offset and the path to the raw 4096 bytes media info at the # begin of the component media that corresponds to the and writes # them to "stdout", # * here we do not have an offset etc. so it returns # "". # global: HasNoGetComponentMediaInfoOffsetPathPair0x0EAA return "$HasNoGetComponentMediaInfoOffsetPathPair0x0EAA" } disk_mediaAccess__0x088C_42_numComponents() { # writes the number of component medias in the container to "stdout"; # $1: . local MediaInof ParametersFile # parameters: local numComponents MediaInfo="$1" # echo $MediaInfo >>/dev/stderr ParametersFile="$(disk_mediaAccess__Parameters2File "$MediaInfo")" \ || return # return on error. . "$ParametersFile" || return # return on error. echo "$numComponents" } disk_mediaAccess__0x088C_42_SYNC() { # synchronize block-device with device-mapper-tables. disk_mediaAccess__DeleteCaches }