#!/usr/local/bin/scripts/sh # # pen: Index2Offset should be "start of media-info"?; wrong: StartOfComponentMedia; # * ^^^ commands. # * '33: specify offset etc. more accurate, mediaInfo, media ... # * preambels to grammar stuff. # #.Y / 70 83 / / / / 105 / / / / / / ;A4_QUER.Y #.YT 3 2 0 0 3 3 1 / / / #.H!a!0:linux//io/disk/mediaAccess/mediaHandlers.d/A8A2BB32_78F0_11E6_B6F3_0000C00A45A9!0.!c # #/******************************************************************************* # io disk mediaAccess mediaHandlers.d/A8A2BB32_78F0_11E6_B6F3_0000C00A45A9 # ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # # purpose : media handler for a general container # # begin : Sat Dec 30 12:32:47 CEST 2017 # # changes : # # copyright : (C) 2017 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("A8A2BB32_78F0_11E6_B6F3_0000C00A45A9" = 0x088B_32 # # * for every function: # * if returned result is not commented, the function returns 0 on no-error. . "/${SCRIPTS}/memory/THIS" Xdisk_mediaAccess_0x088B_32_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_0x088B_32_col___ \ "$MediaHandlerUuid" "$SIZE" "$UUID" "$PREFIX" } Xdisk_mediaAccess_0x088B_32_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_A8A2BB32_78F0_11E6_B6F3_0000C00A45A9() { # handles a general container; # $1: command, in { # "CHECK", "CheckForced", "ContainerCommand", "GetComponentMediaInfo", # "numComponents", "REPAIR", "RepairForced", "SIZE", "VERIFY", "WAIT", # "_:", "__:" # }, # * $1 in { # "CHECK", "CheckForced", "REPAIR", "RepairForced", "SIZE", "VERIFY", # "WAIT" # }: see "../CommonCommandsSpecification.TXT"; # * "ContainerCommand": # executes a command 'for a media in the container'; # $2: index into the container (the "ContainerCommand" may only be used # for a container, so "$2 == 0" is mostly required.), # $3: , # $4: , # $5: , # $6: command for the (by "$7") indexed container component media in { # ^^^ # }; only necessary for the commands in { # ^^^ # }, # $7: index for the container component media in the container; # * "GetComponentMediaInfo": # * gets the media info of the (by "$2") indexed container component # media, # * writes the media info of the (by "$2") indexed container component # media to "stdout"; # $2: index into the container, # $3: , # $4: , # $5: ; # * "numComponents": # * #components, # * writes the number of component medias in the container to "stdout"; # $2: index into the container, # $3: , # $4: , # $5: ; # * "_:": # ^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. 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 | CheckForced | REPAIR | RepairForced) return 0 ;; ContainerCommand) COMMAND="$6" INDEX="$7" shift 7 disk_mediaAccess__0x088B_32_ContainerCommand \ "$COMMAND" \ "$INDEX" "$MediaInfo" "$ParentMedia" "$ParentMediaPath" "$@" ;; GetComponentMediaInfo) disk_mediaAccess__0x088B_32_GetComponentMediaInfo \ "$INDEX" "$MediaInfo" "$ParentMedia" ;; numComponents) disk_mediaAccess__0x088B_32_numComponents \ "$MediaInfo" ;; # #components. SIZE) disk_mediaAccess__Size0 '0' "$MediaInfo" ;; # _:) # shift 1 # disk_mediaAccess_0x088B_32_col__ "$@" # ;; # ^ # __:) # shift 1 # disk_mediaAccess_0x088B_32_col___ "$@" # ;; # ^ *) disk_mediaAccess__InvalidCommandError \ "$COMMAND" "$INDEX" \ 'A8A2BB32_78F0_11E6_B6F3_0000C00A45A9' \ "$ParentMedia" ;; 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__A8A2BB32_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__A8A2BB32_78F0_11E6_B6F3_0000C00A45A9 "__:" "$@" } disk_mediaAccess__0x088B_32_ContainerCommand() { # execute a command 'for the container'; # $1: command, in { # "DestroyMediaInfo", "DestroyNewComponentMedia", # "GetComponentMediaInfo", "Index2Offset", "NewOffset", # "numComponents", "RealizeMediaInfo", "RealizeNewComponentMedia", "SIZE", # "StartOfComponentMedia", "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_A8A2BB32_78F0_11E6_B6F3_0000C00A45A9 \ "$COMMAND" "$INDEX" "$MediaInfo" "$ParentMedia" "$ParentMediaParth" "$@" } disk_mediaAccess__0x088B_32_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: MediaInfoCommand0x0EAA local INDEX MediaInfo numComponents ParentMedia INDEX="$1" MediaInfo="$2" ParentMedia="$3" # echo "$INDEX" >>/dev/stderr # echo "$MediaInfo" >>/dev/stderr # echo "$ParentMedia" >>/dev/stderr numComponents="$( disk_mediaAccess__0x088B_32_numComponents "$MediaInfo" )" || return # return on error. # echo "$numComponents" >>/dev/stderr [ "$numComponents" -lt "$INDEX" ] && { disk_mediaAccess__InvalidIndexError "$INDEX" "$ParentMedia" || return } # return on error. [ '0' = "$INDEX" ] && { echo "$MediaInfo" return } echo -n "$MediaInfo" \ | "$MediaInfoCommand0x0EAA" 'MediaInfo' "ComponentMedia[$INDEX]" } disk_mediaAccess__0x088B_32_numComponents() { # writes the number of component medias in the container to "stdout"; # $1: . # global: MediaInfoCommand0x0EAA local MediaInfo MediaInfo="$1" echo -n "$MediaInfo" | "$MediaInfoCommand0x0EAA" 'LS' | wc -l } disk_mediaAccess___isGeneralContainer() { # ^ * returns "0" (true) if the media handler uuid may be handled. # $1: , # $2: , # $3: . local INDEX ParentMedia ParentMediaPath INDEX="$1" ParentMedia="$2" ParentMediaPath="$3" # echo "$INDEX" >>/dev/stderr # echo "$ParentMedia" >>/dev/stderr # echo "$ParentMediaPath" >>/dev/stderr disk_mediaAccess__isMediaHandlerUuid \ "$INDEX" "$ParentMedia" "$ParentMediaPath" \ 'A8A2BB32_78F0_11E6_B6F3_0000C00A45A9' # return result of last } # command.