Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix large LBA returned in form of string lead to #37 #43

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions .github/workflows/TCGstorageAPI-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- master
- develop
pull_request:
branches:
- master
Expand All @@ -12,13 +13,13 @@ jobs:
build:
name: TCGstorageAPI_build
# This job runs on Linux
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Checkout git submodules
run: git submodule update --init --recursive
- name: Install dependencies
run: git submodule update --init --recursive
- name: Install dependencies
run: |
sudo apt-get update
sudo apt install python3
Expand All @@ -30,14 +31,14 @@ jobs:
run: |
sudo apt-get install python3-setuptools
pip3 install --no-cache-dir -r requirements.txt
- name: Link gmake to make
run: sudo ln -s /usr/bin/make /usr/bin/gmake
- name: Link libboost_python3 to libboost_python38.so
run: sudo ln -s /usr/lib/x86_64-linux-gnu/libboost_python38.so /usr/lib/libboost_python3.so
- name: Build opensea
run: python3 setup.py opensea
- name: Build TCGstorageAPI package
run: python3 setup.py build
- name: Run unit tests
run: |
sudo cp -R build/lib.linux-x86_64-3.6/TCGstorageAPI /home/runner/work/TCGstorageAPI/TCGstorageAPI
export PYTHONPATH=$PYTHONPATH:/usr/local/lib/python3.6/site-packages/
sudo cp -R build/lib.linux-x86_64-3.8/TCGstorageAPI /home/runner/work/TCGstorageAPI/TCGstorageAPI
export PYTHONPATH=$PYTHONPATH:/usr/local/lib/python3.8/site-packages/
python3 TCGstorageAPI/tcgapi_test.py
18 changes: 8 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,23 +56,21 @@ Note that cloning **_recursively_** is **_important_** as it clones all the nece

Start by updating the package index:

`sudo yum update`
`sudo yum -y update`

Install python3:

`sudo yum install python3`
`sudo yum -y install python3`

Install gcc and g++:

`sudo yum -y install gcc`

`sudo yum -y install gcc-c++`
`sudo yum -y install gcc gcc-c++`

Install boost:

`sudo yum install epel-release`
`sudo yum -y install epel-release`

`sudo yum install boost-python36-devel.x86_64`
`sudo yum -y install boost-python36-devel`

Install gnutls:

Expand All @@ -83,13 +81,13 @@ Install python3-extensions:
`sudo yum -y install python3-devel`

Install rpm build package
`sudo yum install rpm-build`

`sudo yum -y install rpm-build`

Change directory to tcgstorageapi and download the package dependencies:

`pip3 install -r requirements.txt`

##### Ubuntu 18.04

Start by updating package index
Expand Down
19 changes: 10 additions & 9 deletions TCGstorageAPI/tcgapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,19 @@
#-----------------------------------------------------------------------------

import sys
import logging
from . import pysed
import struct
from . import pysedSupport
import warnings
from .pysedSupport import *
from . import tcgSupport
from .tcgSupport import locking_table as locking_table
from .tcgSupport import portlocking_table as portlocking_table
from .tcgSupport import c_tls_psk_table as c_tls_psk_table
import io
import os
import re
import warnings

from . import pysed
from . import pysedSupport
from .pysedSupport import baseObjectIds
from . import tcgSupport
from .tcgSupport import locking_table
from .tcgSupport import portlocking_table
from .tcgSupport import c_tls_psk_table

StatusCode = pysed.StatusCode

Expand Down
2 changes: 1 addition & 1 deletion pysed/TcgDrive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ void Session::dumpPacket(const char * desc, void * buf, size_t size) {

void PacketHeaders::fill(Drive * const drive, Session * const session,
uint32_t dataLength) {
memset(this, 0, sizeof(PacketHeaders));
*this = {};
subPacket.length = dataLength;
dataLength += sizeof(SubPacketHeader);
if (dataLength % 4)
Expand Down
4 changes: 2 additions & 2 deletions pysed/TcgScanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,11 +242,11 @@ const char * Results::namedString(const uint64_t name)
{

PyObject* v = ob.ptr();

if (PyBytes_Check(v)) {
//cout << "Object is PyBytes type\n";
char *pbuf = PyBytes_AsString(v);
Py_ssize_t len = PyBytes_Size(v);
//Py_ssize_t len = PyBytes_Size(v);
//cout << "Value is '" << pbuf << "' length " << (long) len << "\n";
return pbuf;
}
Expand Down
3 changes: 1 addition & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
boost
cryptography==3.3.2
passlib==1.7.4
pycparser==2.20
pyopenssl==20.0.1
pyopenssl==20.0.1
11 changes: 7 additions & 4 deletions sed_cli/sed_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@
from keymanager import keymanager_json

def auto_int(x):
return int(x, 0)
try:
return int(x, 0)
except TypeError: # x may be just an int
return int(x)

def str2bool(v):
if isinstance(v, bool):
Expand Down Expand Up @@ -698,9 +701,9 @@ def printBandInfo(self, bandNumber):

info, rc = self.SED.getRange(bandNumber, user, auth)
if bandNumber != 0:
print('Band{} RangeStart = 0x{:x}'.format(bandNumber, info.RangeStart))
print('Band{} RangeEnd = 0x{:x}'.format(bandNumber, info.RangeStart + info.RangeLength))
print('Band{} RangeLength = 0x{:x}'.format(bandNumber, info.RangeLength))
print('Band{} RangeStart = 0x{:x}'.format(bandNumber, auto_int(info.RangeStart)))
print('Band{} RangeEnd = 0x{:x}'.format(bandNumber, auto_int(info.RangeStart) + auto_int(info.RangeLength)))
print('Band{} RangeLength = 0x{:x}'.format(bandNumber, auto_int(info.RangeLength)))
print('Band{} ReadLocked = {}'.format(bandNumber, ('unlocked','locked')[info.ReadLocked]))
print('Band{} WriteLocked = {}'.format(bandNumber, ('unlocked','locked')[info.WriteLocked]))
print('Band{} LockOnReset = {}'.format(bandNumber, info.LockOnReset))
Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ def finalize_options(self):
"""Abstract method that is required to be overwritten"""
def run(self):
print(" => Building OpenSea Static Libraries ...")
subprocess.call(['gmake', '-C', 'opensea-transport/Make/gcc'])
subprocess.call(['gmake', '-C', 'opensea-operations/Make/gcc'])
subprocess.call(['gmake', '-C', 'opensea-common/Make/gcc'])
subprocess.call(['make', '-C', 'opensea-transport/Make/gcc'])
subprocess.call(['make', '-C', 'opensea-operations/Make/gcc'])
subprocess.call(['make', '-C', 'opensea-common/Make/gcc'])

pysed = Extension('TCGstorageAPI.pysed', [
'pysed/pysed.cpp',
Expand Down