요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
2. 영어 원문 전체
번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
# install the aoe-specific udev rules from udev.txt into
# the system's udev configuration
#
me="`basename $0`"
# find udev.conf, often /etc/udev/udev.conf
# (or environment can specify where to find udev.conf)
#
if test -z "$conf"; then
if test -r /etc/udev/udev.conf; then
conf=/etc/udev/udev.conf
else
conf="`find /etc -type f -name udev.conf 2> /dev/null`"
if test -z "$conf" || test ! -r "$conf"; then
echo "$me Error: no udev.conf found" 1>&2
exit 1
fi
fi
fi
# find the directory where udev rules are stored, often
# /etc/udev/rules.d
#
rules_d="`sed -n '/^udev_rules=/{ s!udev_rules=!!; s!\"!!g; p; }' $conf`"
if test -z "$rules_d" ; then
rules_d=/etc/udev/rules.d
fi
if test ! -d "$rules_d"; then
echo "$me Error: cannot find udev rules directory" 1>&2
exit 1
fi
sh -xc "cp `dirname $0`/udev.txt $rules_d/60-aoe.rules"
3. 한국어 전문 번역
영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.
목적과 설정 탐색 준비
1-9이 스크립트는 `udev.txt`에 들어 있는 AoE 전용 udev 규칙을 시스템의 udev 설정에 설치합니다. `me`에는 실행 파일의 기본 이름을 저장해 오류 메시지 앞에 붙입니다. 먼저 대개 `/etc/udev/udev.conf`에 있는 `udev.conf`의 위치를 찾되, 환경에서 `conf` 변수를 지정하면 그 위치를 우선 사용합니다.
# install the aoe-specific udev rules from udev.txt into
# the system's udev configuration
#
me="`basename $0`"
# find udev.conf, often /etc/udev/udev.conf
# (or environment can specify where to find udev.conf)
#
udev.conf 찾기
10-20`conf`가 비어 있으면 `/etc/udev/udev.conf`를 읽을 수 있는지 검사하고, 가능하면 그 경로를 사용합니다. 읽을 수 없다면 `/etc` 아래에서 이름이 `udev.conf`인 일반 파일을 찾아 `conf`에 저장하며 검색 오류 출력은 `/dev/null`로 버립니다.
검색 뒤에도 `conf`가 비어 있거나 찾은 파일을 읽을 수 없으면 표준 오류에 `no udev.conf found`를 출력하고 종료 상태 1로 끝냅니다. 환경에서 `conf`가 미리 지정된 경우에는 이 블록을 건너뛰며, 이 스크립트 구간 자체에서는 그 경로의 가독성을 다시 검사하지 않습니다.
환경 지정값을 우선하고, 없을 때 표준 위치와 /etc 검색을 차례로 시도합니다.
if test -z "$conf"; then
if test -r /etc/udev/udev.conf; then
conf=/etc/udev/udev.conf
else
conf="`find /etc -type f -name udev.conf 2> /dev/null`"
if test -z "$conf" || test ! -r "$conf"; then
echo "$me Error: no udev.conf found" 1>&2
exit 1
fi
fi
fi
규칙 디렉터리 결정과 설치
21-33선택한 설정 파일에서 줄 시작이 `udev_rules=`인 항목을 `sed`로 찾고, 변수 이름과 큰따옴표를 제거하여 `rules_d`를 얻습니다. 값이 비어 있으면 기본 경로 `/etc/udev/rules.d`를 사용합니다.
결정된 규칙 경로가 디렉터리가 아니면 표준 오류에 udev 규칙 디렉터리를 찾을 수 없다는 메시지를 출력하고 종료 상태 1로 끝냅니다. 유효한 디렉터리이면 현재 스크립트가 있는 디렉터리의 `udev.txt`를 `$rules_d/60-aoe.rules`로 복사합니다. `sh -x`가 실행 명령을 표시하고 `-c`가 문자열 명령을 수행합니다.
설정값이 없을 때의 기본값과 최종 복사 대상을 보존합니다.
# find the directory where udev rules are stored, often
# /etc/udev/rules.d
#
rules_d="`sed -n '/^udev_rules=/{ s!udev_rules=!!; s!\"!!g; p; }' $conf`"
if test -z "$rules_d" ; then
rules_d=/etc/udev/rules.d
fi
if test ! -d "$rules_d"; then
echo "$me Error: cannot find udev rules directory" 1>&2
exit 1
fi
sh -xc "cp `dirname $0`/udev.txt $rules_d/60-aoe.rules"
요약·해설
udev-install.sh:1-33udev 설정에서 규칙 디렉터리를 찾고 AoE용 `udev.txt`를 `60-aoe.rules`로 설치합니다.