libblkid는 블록장치를 식별하고 정보를 제공하는 유틸리티이다. 이 라이브러리를 이용하여 USB 메모리의 파티션 파일시스템 타입이나 레이블정보를 얻을 수 있다. 아래 소스코드를 참고하자.
#include <stdio.h> #include <stdlib.h> #include <err.h> #include <blkid/blkid.h> int main (int argc, char *argv[]) { blkid_probe pr; const char *uuid; const char *label; const char *type; if (argc != 2) { fprintf(stderr, "Usage: %s devname\n", argv[0]); exit(1); } pr = blkid_new_probe_from_filename(argv[1]); if (!pr) { err(2, "Failed to open %s", argv[1]); } blkid_do_probe(pr); blkid_probe_lookup_value(pr, "UUID", &uuid, nullptr); blkid_probe_lookup_value(pr, "LABEL", &label, nullptr); blkid_probe_lookup_value(pr, "TYPE", &type, nullptr); printf("UUID=%s\n", uuid); printf("LABEL=%s\n", label); printf("TYPE=%s\n", type); blkid_free_probe(pr); return 0; }
include 와 -lblkid 경로를 정의하고 컴파일하여 실행하면 아래와 같은 결과가 출력된다.
root@imx6qsabresd:~# ./blkidApp /dev/sda1
UUID=D6CA-3F90
LABEL=ESD-USB
TYPE=vfat
번호 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|
5 | 시스템에서 사용 가능한 D-Bus 서비스를 보려면? | makersweb | 2022.12.29 | 1396 |
4 | lubuntu 22.04 LTS 설치 | makersweb | 2023.01.23 | 1608 |
3 | GRUB의 timeout 설정 | makersweb | 2023.11.07 | 689 |
2 | 리눅스 Qt 응용프로그램 AppImage 로 구축 | makersweb | 2024.01.07 | 636 |
1 | 리눅스에서 시리얼 포트 사용 및 접근 권한 | makersweb | 2024.05.21 | 224 |