Skip to content

Commit d309029

Browse files
committed
For consistency, NVME should always be NVMe.
1 parent e3f06ce commit d309029

File tree

8 files changed

+40
-40
lines changed

8 files changed

+40
-40
lines changed

docs/guide/discovery.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ For our example system, this would give us:
2424

2525
.. code-block:: python
2626
27-
LinuxNVMEDevice(path="/dev/nvme0n1")
27+
LinuxNVMeDevice(path="/dev/nvme0n1")
2828
LinuxSCSIDevice(path="/dev/sdb")
2929
LinuxSCSIDevice(path="/dev/sdc")
30-
LinuxNVMEDevice(path="/dev/nvme1n1")
30+
LinuxNVMeDevice(path="/dev/nvme1n1")
3131
LinuxSCSIDevice(path="/dev/sda")
3232
3333

docs/guide/low_level.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ type of device you have:
2121
2222
from smartie.device import get_device
2323
from smartie.scsi import SCSIDevice
24-
from smartie.nvme import NVMEDevice
24+
from smartie.nvme import NVMeDevice
2525
2626
with get_device('\\\\.\\PhysicalDrive0') as device:
2727
if isinstance(device, SCSIDevice):
2828
print('SCSI device')
29-
elif isinstance(device, NVMEDevice):
29+
elif isinstance(device, NVMeDevice):
3030
print('NVMe device')
3131
else:
3232
print('Unknown device type')
@@ -83,10 +83,10 @@ To send an NVMe IDENTIFY command to a device:
8383
8484
with get_device('/dev/nvme0') as device:
8585
# The structure that will be populated with the response.
86-
data = structures.NVMEIdentifyResponse()
86+
data = structures.NVMeIdentifyResponse()
8787
device.issue_admin_command(
88-
structures.NVMEAdminCommand(
89-
opcode=structures.NVMEAdminCommands.IDENTIFY,
88+
structures.NVMeAdminCommand(
89+
opcode=structures.NVMeAdminCommands.IDENTIFY,
9090
addr=ctypes.addressof(data),
9191
data_len=ctypes.sizeof(data),
9292
cdw10=1

docs/index.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,10 @@ from a device:
8585
8686
with get_device('/dev/nvme0') as device:
8787
# The structure that will be populated with the response.
88-
data = structures.NVMEIdentifyResponse()
88+
data = structures.NVMeIdentifyResponse()
8989
device.issue_admin_command(
90-
structures.NVMEAdminCommand(
91-
opcode=structures.NVMEAdminCommands.IDENTIFY,
90+
structures.NVMeAdminCommand(
91+
opcode=structures.NVMeAdminCommands.IDENTIFY,
9292
addr=ctypes.addressof(data),
9393
data_len=ctypes.sizeof(data),
9494
cdw10=1
@@ -108,7 +108,7 @@ Supported Platforms
108108
* - OS
109109
- Device Discovery
110110
- SCSI/ATA Supported
111-
- NVME Supported
111+
- NVMe Supported
112112
* - Linux
113113
- Yes
114114
- Yes

smartie/cli.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
from smartie.database import DRIVE_DATABASE, get_matching_drive_entries
1111
from smartie.device import get_all_devices, get_device
12-
from smartie.nvme import NVMEDevice
12+
from smartie.nvme import NVMeDevice
1313
from smartie.scsi import SCSIDevice
1414
from smartie.structures import c_uint128, embed_bytes
1515
from smartie.util import grouper_it
@@ -155,11 +155,11 @@ def blocks_to_gb(blocks: int) -> float:
155155
str(entry.threshold),
156156
entry.unit.name,
157157
)
158-
elif isinstance(device, NVMEDevice):
158+
elif isinstance(device, NVMeDevice):
159159
smart_table.add_column("Name", style="magenta")
160160
smart_table.add_column("Value", style="green", justify="right")
161161

162-
smart,_ = device.smart()
162+
smart, _ = device.smart()
163163

164164
# We only show a selection of attributes, as the full list is
165165
# not terribly useful.
@@ -254,7 +254,7 @@ def dump_command(path: str, command: str, display: str = "pretty"):
254254
return
255255

256256
structure = result()[0]
257-
elif isinstance(device, NVMEDevice):
257+
elif isinstance(device, NVMeDevice):
258258
result = {"identify": device.identify, "smart": device.smart}.get(
259259
command
260260
)
@@ -396,7 +396,7 @@ def api_get_command(path: str):
396396
"unit": entry.unit.name,
397397
"flags": entry.flags,
398398
}
399-
elif isinstance(device, NVMEDevice):
399+
elif isinstance(device, NVMeDevice):
400400
result["smart"] = device.smart_table
401401

402402
print(json.dumps(result, indent=4, sort_keys=True))

smartie/device.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,11 @@ def get_device(path: Union[Path, str]) -> Device:
103103

104104
return WindowsSCSIDevice(path)
105105
elif system == "Linux":
106-
from smartie.nvme.linux import LinuxNVMEDevice
106+
from smartie.nvme.linux import LinuxNVMeDevice
107107
from smartie.scsi.linux import LinuxSCSIDevice
108108

109109
if "nvme" in str(path):
110-
return LinuxNVMEDevice(path)
110+
return LinuxNVMeDevice(path)
111111
return LinuxSCSIDevice(path)
112112
else:
113113
raise NotImplementedError("Device not implemented for this platform.")

smartie/nvme/__init__.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__all__ = ("NVMEDevice",)
1+
__all__ = ("NVMeDevice",)
22
import abc
33
import sys
44
import ctypes
@@ -9,9 +9,9 @@
99
from smartie.device import Device
1010
from smartie.nvme.errors import NVMeStatusFieldError
1111
from smartie.nvme.structures import (
12-
NVMEAdminCommand,
13-
NVMEAdminCommands,
14-
NVMEIdentifyResponse,
12+
NVMeAdminCommand,
13+
NVMeAdminCommands,
14+
NVMeIdentifyResponse,
1515
NVMeCQEStatusField,
1616
SMARTPageResponse,
1717
)
@@ -43,7 +43,7 @@ class NVMeResponse:
4343
#: The status field data returned by the device.
4444
status_field: Optional[NVMeCQEStatusField]
4545
#: The command issued to the device.
46-
command: Union[NVMEAdminCommand,]
46+
command: Union[NVMeAdminCommand,]
4747
#: Keep aligned with SCSIResponse. Not used for now.
4848
#: The actual number of bytes transferred.
4949
bytes_transferred: Optional[int]
@@ -58,7 +58,7 @@ def __bool__(self):
5858
return self.succeeded
5959

6060

61-
class NVMEDevice(Device, abc.ABC):
61+
class NVMeDevice(Device, abc.ABC):
6262
@classmethod
6363
def parse_status_field(cls, status_blob) -> Optional[NVMeCQEStatusField]:
6464
"""
@@ -81,15 +81,15 @@ def parse_status_field(cls, status_blob) -> Optional[NVMeCQEStatusField]:
8181
def issue_admin_command(self, command):
8282
pass
8383

84-
def identify(self) -> Tuple[NVMEIdentifyResponse, NVMeResponse]:
84+
def identify(self) -> Tuple[NVMeIdentifyResponse, NVMeResponse]:
8585
"""
8686
Returns the parsed IDENTIFY results for CNS 01h, which contains
8787
the controller information.
8888
"""
89-
data = NVMEIdentifyResponse()
89+
data = NVMeIdentifyResponse()
9090
response = self.issue_admin_command(
91-
NVMEAdminCommand(
92-
opcode=NVMEAdminCommands.IDENTIFY,
91+
NVMeAdminCommand(
92+
opcode=NVMeAdminCommands.IDENTIFY,
9393
addr=ctypes.addressof(data),
9494
data_len=ctypes.sizeof(data),
9595
cdw10=1,
@@ -116,8 +116,8 @@ def read_log_page(
116116
self, log_page_id: int, data: ctypes.Structure
117117
) -> tuple[ctypes.Structure, NVMeResponse]:
118118
response = self.issue_admin_command(
119-
NVMEAdminCommand(
120-
opcode=NVMEAdminCommands.GET_LOG_PAGE,
119+
NVMeAdminCommand(
120+
opcode=NVMeAdminCommands.GET_LOG_PAGE,
121121
addr=ctypes.addressof(data),
122122
data_len=ctypes.sizeof(data),
123123
nsid=0xFFFFFFFF,

smartie/nvme/linux.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
import os
33

44
from smartie.nvme import (
5-
NVMEDevice,
5+
NVMeDevice,
66
NVMeResponse,
77
local_byteorder,
88
)
99
from smartie.platforms.linux import get_libc
10-
from smartie.nvme.structures import IOCTL_NVME_ADMIN_CMD, NVMEAdminCommand
10+
from smartie.nvme.structures import IOCTL_NVMe_ADMIN_CMD, NVMeAdminCommand
1111

1212

13-
class LinuxNVMEDevice(NVMEDevice):
13+
class LinuxNVMeDevice(NVMeDevice):
1414
"""
1515
Represents an NVMe device on a Linux system.
1616
"""
@@ -28,9 +28,9 @@ def __exit__(self, exc_type, exc_val, exc_tb):
2828
self.fd = None
2929
return False
3030

31-
def issue_admin_command(self, command: NVMEAdminCommand) -> NVMeResponse:
31+
def issue_admin_command(self, command: NVMeAdminCommand) -> NVMeResponse:
3232
result = get_libc().ioctl(
33-
self.fd, IOCTL_NVME_ADMIN_CMD, ctypes.byref(command)
33+
self.fd, IOCTL_NVMe_ADMIN_CMD, ctypes.byref(command)
3434
)
3535

3636
return NVMeResponse(

smartie/nvme/structures.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""
22
This file contains the various low-level structure definitions used for sending
3-
and receiving NVME commands, as well as the structures required for
3+
and receiving NVMe commands, as well as the structures required for
44
platform-specific APIs.
55
"""
66
import ctypes
@@ -9,15 +9,15 @@
99
from smartie.structures import c_uint128
1010

1111
#: IOCTL for NVMe Admin commands on Linux.
12-
IOCTL_NVME_ADMIN_CMD = 0xC0484E41
12+
IOCTL_NVMe_ADMIN_CMD = 0xC0484E41
1313

1414

15-
class NVMEAdminCommands(enum.IntEnum):
15+
class NVMeAdminCommands(enum.IntEnum):
1616
GET_LOG_PAGE = 0x02
1717
IDENTIFY = 0x06
1818

1919

20-
class NVMEAdminCommand(ctypes.Structure):
20+
class NVMeAdminCommand(ctypes.Structure):
2121
_pack_ = 1
2222
_fields_ = [
2323
("opcode", ctypes.c_ubyte),
@@ -55,7 +55,7 @@ class NVMeCQEStatusField(ctypes.Structure):
5555
]
5656

5757

58-
class NVMEIdentifyResponse(ctypes.Structure):
58+
class NVMeIdentifyResponse(ctypes.Structure):
5959
_fields_ = [
6060
("vendor_id", ctypes.c_uint16),
6161
("ssvid", ctypes.c_uint16),

0 commit comments

Comments
 (0)