Skip to content

Commit

Permalink
mkltfs cli
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaoyangwx committed Nov 1, 2023
1 parent 9c4a429 commit 82501a7
Show file tree
Hide file tree
Showing 5 changed files with 150 additions and 8 deletions.
68 changes: 68 additions & 0 deletions LTFSCopyGUI/ApplicationEvents.vb
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,74 @@ dataDir:{dataDir}
{Resources.StrSCSIFail}")
End If

CloseConsole()
End
End If
Case "-mkltfs"
CheckUAC(e)
InitConsole()
If i < param.Count - 7 Then
Dim TapeDrive As String = param(i + 1)
If TapeDrive.StartsWith("TAPE") Then
TapeDrive = "\\.\" & TapeDrive
ElseIf TapeDrive.StartsWith("\\.\") Then
'Do Nothing
ElseIf TapeDrive = Val(TapeDrive).ToString Then
TapeDrive = "\\.\TAPE" & TapeDrive
Else

End If
Dim Barcode As String = ""
If i + 4 <= param.Length - 1 Then
Barcode = param(i + 2).Replace("""", "")
If Barcode.Length > 20 Then Barcode = Barcode.Substring(0, 20)
End If

Dim VolLabel As String = ""
If i + 4 <= param.Length - 1 Then
VolLabel = param(i + 3).Replace("""", "")
End If

Dim Partition As Byte = 1
If i + 4 <= param.Length - 1 Then
Partition = Partition And Val(param(i + 4))
End If

Dim Capacity As UInt16 = &HFFFF
If i + 5 <= param.Length - 1 Then
Capacity = Capacity And Val(param(i + 5))
End If
Dim BlockLen As Integer = 524288
If i + 6 <= param.Length - 1 Then
BlockLen = Val(param(i + 6))
End If
Dim P0Size As UInt16 = 1
If i + 7 <= param.Length - 1 Then
P0Size = P0Size And Val(param(i + 7))
End If
Dim P1Size As UInt16 = &HFFFF
If i + 8 <= param.Length - 1 Then
P1Size = P1Size And Val(param(i + 8))
End If

Dim sense As Byte() = {}
If TapeUtils.mkltfs(TapeDrive, Barcode, VolLabel, Partition, BlockLen, True,
Sub(s As String)
'ProgReport
Console.WriteLine(s)
End Sub,
Sub(s As String)
'OnFin
Console.WriteLine(s)
End Sub,
Sub(s As String)
'OnErr
Console.WriteLine(s)
End Sub, Capacity, P0Size, P1Size) Then
Console.WriteLine(Resources.StrFormatFin)
Else
Console.WriteLine(Resources.StrFormatError)
End If
CloseConsole()
End
End If
Expand Down
22 changes: 20 additions & 2 deletions LTFSCopyGUI/My Project/Resources.Designer.vb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 27 additions & 1 deletion LTFSCopyGUI/My Project/Resources.en.resx
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
<value>Barcode write fail</value>
</data>
<data name="StrCMDHelpText" xml:space="preserve">
<value> -s Disable index reading
<value>-s Disable index reading
-t &lt;drive&gt; LTFSWriter
├ -t 0
├ -t TAPE0
Expand All @@ -146,9 +146,35 @@
-wb &lt;drive&gt; &lt;barcode&gt; Barcode write
└ -wb TAPE0 A00123L5

-mkltfs &lt;drive&gt; [&lt;Barcode&gt; &lt;Volume Label&gt; &lt;Partition&gt; &lt;Capacity&gt; &lt;BlockLen&gt; &lt;P0Size&gt; &lt;P1Size&gt;]
Format LTFS Volume
* Optional Parameters
* Barcode: 0-20 ASCII characters. Default=empty
* Volume Label: Unicode string. Default=empty
* Partition: 0 or 1. Default=1 (partitioned)
* Capacity: 0-65535. Default=65535 (Full length)
* BlockLen:1-2097152. Default=524288
* P0Size:Partition 0 Size in GB, will round up to nearest multiple-of-two wraps. Default=1
* P1Size:Partition 1 Size in GB, will round up to nearest multiple-of-two wraps. Default=65535
* If one Partition Size field is set to 65535, the corresponding partition will occupy whatever capacity remains after satisfying the specified size for the other partitions. At most one partition size may be set to 65535.
* If no Partition Size field is set to 65535, the sum of the specified partition sizes must not exceed the total available capacity
├ -mkltfs TAPE0 (= -mkltfs TAPE0 "" "" 1 65535 524288 1 65535)
├ -mkltfs TAPE0
├ -mkltfs TAPE0 C01234L5 "Tape 1234"
├ -mkltfs TAPE0 "" "" 1 48000
├ -mkltfs TAPE0 C01234L5 "Tape 1234" 1 65535 65536
├ -mkltfs TAPE0 C01234L5 "Tape 1234" 0
└ -mkltfs TAPE0 C01234L5 "Tape 1234" 1 65535 524288 75 65535

-raw &lt;drive&gt; &lt;cdb&gt; &lt;param&gt; &lt;dataDir&gt; &lt;timeout, default=60000&gt; SCSI command execute
└ -raw TAPE0 ""34 00 00 00 00 00 00 00 00"" ""00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"" 1 600</value>
</data>
<data name="StrFormatError" xml:space="preserve">
<value>Format failed</value>
</data>
<data name="StrFormatFin" xml:space="preserve">
<value>Format finished</value>
</data>
<data name="StrIndexView" xml:space="preserve">
<value>Index view</value>
</data>
Expand Down
31 changes: 29 additions & 2 deletions LTFSCopyGUI/My Project/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
<value>设置Barcode失败</value>
</data>
<data name="StrCMDHelpText" xml:space="preserve">
<value> -s 不要自动读取索引
<value>-s 不要自动读取索引
-t &lt;drive&gt; 直接读写
├ -t 0
├ -t TAPE0
Expand All @@ -140,12 +140,39 @@
-wb &lt;drive&gt; &lt;barcode&gt; 写Barcode
└ -wb TAPE0 A00123L5

-raw &lt;drive&gt; &lt;cdb&gt; &lt;param&gt; &lt;dataDir&gt; &lt;timeout, default=60000&gt; SCSI命令执行
-mkltfs &lt;drive&gt; [&lt;Barcode&gt; &lt;Volume Label&gt; &lt;Partition&gt; &lt;Capacity&gt; &lt;BlockLen&gt; &lt;P0Size&gt; &lt;P1Size&gt;]
格式化LTFS
* 可选参数
* Barcode: 条码,0-20个ASCII字符,默认为空
* Volume Label: 卷标,任意长度Unicode字符,默认为空
* Partition: 是否分区,0或者1,默认为1
* Capacity: 磁带容量,0-65535,默认为65535
* BlockLen: 块大小,1-2097152,默认为524288
* P0Size: 分区0大小,单位为GB,将向上取整到偶数个wrap,默认为1
* P1Size: 分区1大小,单位为GB,将向上取整到偶数个wrap,默认为65535
* P0Size和P1Size至多一个为65535,表示取剩余空间
* P0Size和P1Size如果都不为65535,则两者总和不得超过磁带容量
├ -mkltfs TAPE0 (= -mkltfs TAPE0 "" "" 1 65535 524288 1 65535)
├ -mkltfs TAPE0
├ -mkltfs TAPE0 C01234L5 "Tape 1234"
├ -mkltfs TAPE0 "" "" 1 48000
├ -mkltfs TAPE0 C01234L5 "Tape 1234" 1 65535 65536
├ -mkltfs TAPE0 C01234L5 "Tape 1234" 0
└ -mkltfs TAPE0 C01234L5 "Tape 1234" 1 65535 524288 75 65535

-raw &lt;drive&gt; &lt;cdb&gt; &lt;param&gt; &lt;dataDir&gt; [&lt;timeout, default=60000&gt;]
SCSI命令执行
└ -raw TAPE0 ""34 00 00 00 00 00 00 00 00"" ""00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"" 1 600</value>
</data>
<data name="StrDefaultLicense" xml:space="preserve">
<value> 非商业许可</value>
</data>
<data name="StrFormatError" xml:space="preserve">
<value>格式化失败</value>
</data>
<data name="StrFormatFin" xml:space="preserve">
<value>格式化操作完成</value>
</data>
<data name="StrIndexView" xml:space="preserve">
<value>索引查看</value>
</data>
Expand Down
9 changes: 6 additions & 3 deletions LTFSCopyGUI/TapeUtils.vb
Original file line number Diff line number Diff line change
Expand Up @@ -1373,7 +1373,10 @@ Public Class TapeUtils
Optional ByVal ImmediateMode As Boolean = True,
Optional ByVal ProgressReport As Action(Of String) = Nothing,
Optional ByVal OnFinish As Action(Of String) = Nothing,
Optional ByVal OnError As Action(Of String) = Nothing) As Boolean
Optional ByVal OnError As Action(Of String) = Nothing,
Optional ByVal Capacity As UInt16 = &HFFFF,
Optional ByVal P0Size As UInt16 = 1,
Optional ByVal P1Size As UInt16 = &HFFFF) As Boolean
Dim mkltfs_op As Func(Of Boolean) =
Function()

Expand All @@ -1392,7 +1395,7 @@ Public Class TapeUtils

'Set Capacity
ProgressReport("Set Capacity..")
If TapeUtils.SendSCSICommand(TapeDrive, {&HB, 0, 0, &HFF, &HFF, 0}) Then
If TapeUtils.SendSCSICommand(TapeDrive, {&HB, 0, 0, (Capacity >> 8) And &HFF, Capacity And &HFF, 0}) Then
ProgressReport("Load OK" & vbCrLf)
Else
OnError("Load Fail" & vbCrLf)
Expand All @@ -1410,7 +1413,7 @@ Public Class TapeUtils
If ExtraPartitionCount > 0 Then
'Mode Select:1st Partition to Minimum
ProgressReport("MODE SELECT - Partition mode page..")
If TapeUtils.SendSCSICommand(TapeDrive, {&H15, &H10, 0, 0, &H10, 0}, {0, 0, &H10, 0, &H11, &HA, MaxExtraPartitionAllowed, 1, &H3C, 3, 9, 0, 0, 1, &HFF, &HFF}, 0) Then
If TapeUtils.SendSCSICommand(TapeDrive, {&H15, &H10, 0, 0, &H10, 0}, {0, 0, &H10, 0, &H11, &HA, MaxExtraPartitionAllowed, 1, &H3C, 3, 9, 0, (P0Size >> 8) And &HFF, P0Size And &HFF, (P1Size >> 8) And &HFF, P1Size And &HFF}, 0) Then
ProgressReport("MODE SELECT 11h OK" & vbCrLf)
Else
OnError("MODE SELECT 11h Fail" & vbCrLf)
Expand Down

0 comments on commit 82501a7

Please sign in to comment.