{
    "content": [
        {
            "type": "text",
            "text": "# sg_map26 (man)\n\n## NAME\n\nsgmap26 - map SCSI generic (sg) device to corresponding device names\n\n## SYNOPSIS\n\nsgmap26 [--devdir=DIR] [--givenis=0|1] [--help] [--result=0|1|2|3] [--symlink] [--verbose]\n[--version] DEVICE\n\n## DESCRIPTION\n\nMaps a special file (block or char) associated with a SCSI device to the  corresponding  SCSI\ngeneric  (sg)  device,  or  vice  versa.   Can  also  be  given  a  sysfs  file,  for example\n'/sys/block/sda' or '/sys/block/sda/dev'.\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION**\n- **OPTIONS** (7 subsections)\n- **NOTES**\n- **EXAMPLES**\n- **EXIT STATUS**\n- **AUTHORS**\n- **REPORTING BUGS**\n- **COPYRIGHT**\n- **SEE ALSO** (1 subsections)\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "sg_map26",
        "section": "",
        "mode": "man",
        "summary": "sgmap26 - map SCSI generic (sg) device to corresponding device names",
        "synopsis": "sgmap26 [--devdir=DIR] [--givenis=0|1] [--help] [--result=0|1|2|3] [--symlink] [--verbose]\n[--version] DEVICE",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [
            {
                "flag": "-d",
                "long": "--dev",
                "arg": null,
                "description": "where DIR is the directory to search for resultant device special files in (or sym‐ links to same). Only active when '--result=0' (the default) or '--result=2'. If this option is not given and DEVICE is a device special file then the directory part of DE‐ VICE is assumed. If this option is not given and DEVICE is a sysfs name, then if nec‐ essary '/dev' is assumed as the directory."
            },
            {
                "flag": "-g",
                "long": "--given",
                "arg": null,
                "description": "specifies the DEVICE is either a device special file (when the argument is 0), or a sysfs 'dev' file (when the argument is 1). The parent directory of a sysfs 'dev' file is also accepted (e.g. either '/sys/block/sda/dev' or '/sys/block/sda' are accepted). Usually there is no need to give this option since this utility first checks for spe‐ cial files (or symlinks to special files) and if not, assumes it has been given a sysfs 'dev' file (or its parent). Generates an error if given and disagrees with vari‐ ety of DEVICE."
            },
            {
                "flag": "-h",
                "long": "--help",
                "arg": null,
                "description": "output the usage message then exit."
            },
            {
                "flag": "-r",
                "long": "--result",
                "arg": null,
                "description": "specifies what variety of file (or files) that this utility tries to find. The de‐ fault is a \"mapped\" device special file, when the argument is 0. When the argument is 1, this utility tries to find the \"mapped\" sysfs node name. When the argument is 2, this utility tries to find the \"matching\" device special file. When the argument is 3, this utility tries to find the \"matching\" sysfs node name."
            },
            {
                "flag": "-s",
                "long": "--symlink",
                "arg": null,
                "description": "when a device special file is being sought (i.e. when '--result=0' (the default) or '--result=2') then also look for symlinks to that device special file in the same di‐ rectory."
            },
            {
                "flag": "-v",
                "long": "--verbose",
                "arg": null,
                "description": "increase the level of verbosity, (i.e. debug output)."
            },
            {
                "flag": "-V",
                "long": "--version",
                "arg": null,
                "description": "print the version string and then exit."
            }
        ],
        "examples": [
            "Assume sg2 maps to sdb while dvd, cdrom and hdc are all matching.",
            "# sgmap26 /dev/sg2",
            "/dev/sdb",
            "# sgmap26 /dev/sdb",
            "/dev/sg2",
            "# sgmap26 --result=0 /dev/sdb",
            "/dev/sg2",
            "# sgmap26 --result=3 /dev/sdb",
            "/sys/block/sda",
            "# sgmap26 --result=1 /dev/sdb",
            "/sys/class/scsigeneric/sg0",
            "Now look at '/dev/hdc' and friends",
            "# sgmap26 /dev/hdc",
            "<error: a hd device does not map to a sg device>",
            "# sgmap26 --result=3 /dev/hdc",
            "/sys/block/hdc",
            "# sgmap26 --result=2 /dev/hdc",
            "/dev/hdc",
            "# sgmap26 --result=2 --symlink /dev/hdc",
            "/dev/cdrom",
            "/dev/dvd",
            "/dev/hdc",
            "# sgmap26 --result=2 --symlink /sys/block/hdc",
            "/dev/cdrom",
            "/dev/dvd",
            "/dev/hdc"
        ],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 19,
                "subsections": []
            },
            {
                "name": "OPTIONS",
                "lines": 2,
                "subsections": [
                    {
                        "name": "-d --dev",
                        "lines": 6,
                        "flag": "-d",
                        "long": "--dev"
                    },
                    {
                        "name": "-g --given",
                        "lines": 8,
                        "flag": "-g",
                        "long": "--given"
                    },
                    {
                        "name": "-h --help",
                        "lines": 2,
                        "flag": "-h",
                        "long": "--help"
                    },
                    {
                        "name": "-r --result",
                        "lines": 6,
                        "flag": "-r",
                        "long": "--result"
                    },
                    {
                        "name": "-s --symlink",
                        "lines": 4,
                        "flag": "-s",
                        "long": "--symlink"
                    },
                    {
                        "name": "-v --verbose",
                        "lines": 2,
                        "flag": "-v",
                        "long": "--verbose"
                    },
                    {
                        "name": "-V --version",
                        "lines": 2,
                        "flag": "-V",
                        "long": "--version"
                    }
                ]
            },
            {
                "name": "NOTES",
                "lines": 13,
                "subsections": []
            },
            {
                "name": "EXAMPLES",
                "lines": 38,
                "subsections": []
            },
            {
                "name": "EXIT STATUS",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "AUTHORS",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "REPORTING BUGS",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "COPYRIGHT",
                "lines": 4,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 1,
                "subsections": [
                    {
                        "name": "udev(7), lsscsi(lsscsi)",
                        "lines": 1
                    }
                ]
            }
        ],
        "sections": {
            "NAME": {
                "content": "sgmap26 - map SCSI generic (sg) device to corresponding device names\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "sgmap26 [--devdir=DIR] [--givenis=0|1] [--help] [--result=0|1|2|3] [--symlink] [--verbose]\n[--version] DEVICE\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "Maps a special file (block or char) associated with a SCSI device to the  corresponding  SCSI\ngeneric  (sg)  device,  or  vice  versa.   Can  also  be  given  a  sysfs  file,  for example\n'/sys/block/sda' or '/sys/block/sda/dev'.\n\nRather than map to or from a sg device, the sysfs file name matching a given  device  special\nfile (or vice versa) can be requested. This is done with '--result=2' and '--result=3'.  This\nfeature works on ATA devices (e.g. 'dev/hdc') as well as SCSI devices.\n\nIn this utility, \"mapped\" refers to finding the relationship between a SCSI generic (sg) node\nand  the  higher  level  SCSI device name; or vice versa. For example '/dev/sg0' may \"map\" to\n'/dev/sda'.  Mappings may not exist, if a relevant module is not loaded,  for  example.  Also\nthere  are SCSI devices that can only be accessed via a sg node (e.g. SAF-TE and some SES de‐\nvices).\n\nIn this utility, \"matching\" refers to different representations of the same  device  accessed\nvia  the  same driver. For example, '/dev/hdc' and '/sys/block/hdc' usually refer to the same\ndevice and thus would be considered matching. A related  example  is  that  '/dev/cdrom'  and\n'/dev/hdc' are also considered matching if '/dev/cdrom' is a symlink to '/dev/hdc'.\n",
                "subsections": []
            },
            "OPTIONS": {
                "content": "Arguments to long options are mandatory for short options as well.\n",
                "subsections": [
                    {
                        "name": "-d --dev",
                        "content": "where  DIR  is  the directory to search for resultant device special files in (or sym‐\nlinks to same). Only active when '--result=0' (the default) or '--result=2'.  If  this\noption is not given and DEVICE is a device special file then the directory part of DE‐\nVICE is assumed.  If this option is not given and DEVICE is a sysfs name, then if nec‐\nessary '/dev' is assumed as the directory.\n",
                        "flag": "-d",
                        "long": "--dev"
                    },
                    {
                        "name": "-g --given",
                        "content": "specifies  the  DEVICE  is either a device special file (when the argument is 0), or a\nsysfs 'dev' file (when the argument is 1). The parent directory of a sysfs 'dev'  file\nis also accepted (e.g.  either '/sys/block/sda/dev' or '/sys/block/sda' are accepted).\nUsually there is no need to give this option since this utility first checks for  spe‐\ncial  files  (or  symlinks  to  special files) and if not, assumes it has been given a\nsysfs 'dev' file (or its parent). Generates an error if given and disagrees with vari‐\nety of DEVICE.\n",
                        "flag": "-g",
                        "long": "--given"
                    },
                    {
                        "name": "-h --help",
                        "content": "output the usage message then exit.\n",
                        "flag": "-h",
                        "long": "--help"
                    },
                    {
                        "name": "-r --result",
                        "content": "specifies  what  variety  of file (or files) that this utility tries to find.  The de‐\nfault is a \"mapped\" device special file, when the argument is 0.  When the argument is\n1,  this  utility  tries to find the \"mapped\" sysfs node name. When the argument is 2,\nthis utility tries to find the \"matching\" device special file. When the argument is 3,\nthis utility tries to find the \"matching\" sysfs node name.\n",
                        "flag": "-r",
                        "long": "--result"
                    },
                    {
                        "name": "-s --symlink",
                        "content": "when  a  device  special file is being sought (i.e. when '--result=0' (the default) or\n'--result=2') then also look for symlinks to that device special file in the same  di‐\nrectory.\n",
                        "flag": "-s",
                        "long": "--symlink"
                    },
                    {
                        "name": "-v --verbose",
                        "content": "increase the level of verbosity, (i.e. debug output).\n",
                        "flag": "-v",
                        "long": "--verbose"
                    },
                    {
                        "name": "-V --version",
                        "content": "print the version string and then exit.\n",
                        "flag": "-V",
                        "long": "--version"
                    }
                ]
            },
            "NOTES": {
                "content": "This  utility  is designed for the Linux 2.6 (and later) kernel series.  It uses special file\nmajor and minor numbers (and whether the special is block or character) together  with  sysfs\nto  do its mapping or matching. In the absence of any other information, device special files\nare assumed to be in the '/dev' directory while sysfs is assumed to be mounted at '/sys'. De‐\nvice  names  in  sysfs are predictable, given the corresponding major and minor number of the\ndevice. However, due to udev rules, the name of device special files can be anything the user\ndesires (e.g. '/dev/sda' could be named '/dev/mybootdisk'). When trying to find a resultant\ndevice special file, this utility uses the major and minor numbers (and whether  a  block  or\nchar device is sought) to search the device directory.\n\nThis  utility  only shows one relationship at a time. To get an overview of all SCSI devices,\nwith special file names and optionally the \"mapped\" sg device name, see the lsscsi utility.\n",
                "subsections": []
            },
            "EXAMPLES": {
                "content": "Assume sg2 maps to sdb while dvd, cdrom and hdc are all matching.\n\n# sgmap26 /dev/sg2\n/dev/sdb\n\n# sgmap26 /dev/sdb\n/dev/sg2\n\n# sgmap26 --result=0 /dev/sdb\n/dev/sg2\n\n# sgmap26 --result=3 /dev/sdb\n/sys/block/sda\n\n# sgmap26 --result=1 /dev/sdb\n/sys/class/scsigeneric/sg0\n\nNow look at '/dev/hdc' and friends\n\n# sgmap26 /dev/hdc\n<error: a hd device does not map to a sg device>\n\n# sgmap26 --result=3 /dev/hdc\n/sys/block/hdc\n\n# sgmap26 --result=2 /dev/hdc\n/dev/hdc\n\n# sgmap26 --result=2 --symlink /dev/hdc\n/dev/cdrom\n/dev/dvd\n/dev/hdc\n\n# sgmap26 --result=2 --symlink /sys/block/hdc\n/dev/cdrom\n/dev/dvd\n/dev/hdc\n",
                "subsections": []
            },
            "EXIT STATUS": {
                "content": "The exit status of sgmap26 is 0 when it is successful. Otherwise see  the  sg3utils(8)  man\npage.\n",
                "subsections": []
            },
            "AUTHORS": {
                "content": "Written by Douglas Gilbert.\n",
                "subsections": []
            },
            "REPORTING BUGS": {
                "content": "Report bugs to <dgilbert at interlog dot com>.\n",
                "subsections": []
            },
            "COPYRIGHT": {
                "content": "Copyright © 2005-2012 Douglas Gilbert\nThis software is distributed under a FreeBSD license. There is NO warranty; not even for MER‐\nCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n",
                "subsections": []
            },
            "SEE ALSO": {
                "content": "",
                "subsections": [
                    {
                        "name": "udev(7), lsscsi(lsscsi)",
                        "content": "sg3utils-1.35                              November 2012                                SGMAP26(8)"
                    }
                ]
            }
        }
    }
}