ALT Linux Sisyphus discussions
 help / color / mirror / Atom feed
From: Arioch <the_Arioch@nm.ru>
To: sisyphus@altlinux.ru
Subject: [sisyphus] Re: hotplug и пакетная запись  cd-r - просто вопpос
Date: Fri, 12 Aug 2005 17:54:50 +0400
Message-ID: <ddia0i$k54$2@sea.gmane.org> (raw)
In-Reply-To: <20050811082918.GA10857@lks.home>

[-- Attachment #1: Type: text/plain, Size: 3215 bytes --]

Konstantin A. Lepikhov пишет:

Ни фига не понимаю. Наверноеночь потому что. Придётся приставать.

>>бага нужна? возможно один файл создает pktcdvd, а другой - UDEV ?
> багу на удефф.

done.

> pktsetup, который вы кстати неправильно вызывали, 

В каком месте ?

Почему не правильно?

Почему не виноват? Если программe просят о чем-то дурацком, то она
должна так и сказать. В консоль дураку-юзеру, и/или в логидля
администратора (на случай что ее скрипты вызывают неинтерактивно)
А если она вместо того начинает дурачкое делать - она виновата.

> Советую повнимательнее поизучать содержимое /etc/init.d/udftools
> и /etc/sysconfig/udftools.

Вряди внимательнее смогу - нет у меня старых ядер и DEVfs. :-)

...смотрю я на check_kernel() в первом файле, и думается мне, что с
апстримом мы порвали?  и хочется его как-то переписать через modinfo
как-нибудь по другому, но не так гвоздато.

А во втором файле я смотрю наDEVICES="/dev/hdc"
И тоже хочется без гвоздиков обойтись.
Например, чтобы для /dev/cdwriter автоматически создавался
/dev/pkt-cdwriter и желательно /media тоже в стороне не оставить.
Но тут придется решать, можно ли писать такой скрипт жестко под
kernel >=2.6.8, UDEV & HAL. Раз, вроде бы, скриптже жестко привязан
к AltLinux - наверное можно. И переназначить ее на /bin/bash


Непонятно, каким группам юзеров (и что это за группы?) должен даваться
доступ к дискам. Я вижу три группы:

zsh 28 % sudo /sbin/service udftools start
Starting :
/dev/pktcdvd/cdwriter=/dev/hdc
zsh 29 % ls -l /dev/pkt*
brw-rw----  1 root disk 251, 0 Авг 12 03:51 /dev/pktcdvd0

/dev/pktcdvd:
итого 0
lrwxrwxrwx  1 root root       11 Авг 12 03:51 0 -> ../pktcdvd0
brw-r-----  1 root root  251,  0 Авг 12 03:51 cdwriter
crw-rw----  1 root cdrom  10, 62 Авг 12 03:47 control

   // Кстати, init тоже от рута запускает сервисы при загрузке?

Судя по GID control и cdwriter, pktsetup должензапускаться от юзера, а
в результате запуска сервисом - юзер получит фиг с маслом (но тут UDEV
неожиданно подстилает pktcdvd0 ;)).


Кстати, скрипт сам загружает модуль pktcdvd.ko - по идее он тогда же и
выгружать его должен :-)



>>PS: хочется скрипт покорежить, как минимум чтобы не ссылался на 
>>несуществующую переменную$DESC
> 
> ага. это будет поправлено.

Заодно я бы вызывал pktcdvd черезaction, a la hotplug's *.rc, чтобы
"[ OK ]" рисовался.

См. в аттаче ;)

>>Есть простые способы определить, может ли драйв packetcdvd ?
>>cdrecord - м.б. слишком большая, даеще warning'ами кидается.
> 
> все cdr/cdrw драйвы после 1998 годадолжны поддерживать packet writing.

...и тётя Груня полезла разламывать ноутбук, чтобы узнать какого года
там резак, и сообщить это udftools :-/
Я ведь спрашивал про программный способ, правда?
Не нравится мне идея на каждый драйв запускать pktsetup.
Хочется, чтобы он запускался автоматом - но все-таки проверял, что драйв
поддерживает пакетную запись.

-------- запуск cdrtools skipped
>>Если я правильно понимаю, то чтобы можно было пакетно записывать - в 
>>посл. строчке должен присутствовать PACKET, а еще лучше MRW ?
> 
> не факт, хотя мечтать не вредно ;)

??? Что не факт? О чем мечтать ?





[-- Attachment #2: udftools --]
[-- Type: text/plain, Size: 5261 bytes --]

#! /bin/sh
#
# udftools
#     Call pktsetup to set up packet device associations
#
# chkconfig: 2345 99 01
# description: udftools packet writing
# processname: udftools
#
# Based on /etc/rc.d/scripts/idetune
# Based on udftools.init script from Debian unstable
# written by LAKostis <lakostis at altlinux.org>
###
###                --- 12 Aug 2005 ---
### modified by Arioch ( mailto:the_Arioch@nm.ru  xmpp:arioch@jabber.ru )
###   fixed: var $DESC was not initialised
###   fixed: /sbin/service added to usage help (TO DO: take it from $0 ?)
###   fixed: redudant if's and loops encapsulated into subroutines
###   fixed: screen output for start and stop is more pretty now (i think so)
###   TO DO: check_kernel() is not to be ALT-specific. Hows to do it in generic way?
###   TO DO: use /var/lock/subsys/udftools to say of it was we who insmod'ed 
###	     pktcdvd.ko, then rmmod it on service stop
###   TO DO: enumerate CD-ROMs instead of forcing user to tune $DEFAULTFILE
###   fixed? if any of numerous [un]mapping would fail - the whole script would fail
#
# Original Debian copyrights goes here
#
# Written and Copyright 2003 Richard Atterer <atterer<at>debian.org>, GPLv2.
# * Thanks to Aleksandar Topuzovic <aleksandar.topuzovic<at>fer.hr> for an
#   initial version of the script.
# * Thanks to Cyrille Chépélov <cyrille<at>chepelov.org> for additional
#   help with the specifics of 2.6 packet writing.
# * Thanks to Christopher Martin <christopher.martin<at>utoronto.ca>
#   for fixes to make things work on systems that have "no udev + new
#   interface" or "udev + old interface"

WITHOUT_RC_COMPAT=1

RETVAL=0
DESC="packet burning for CD-RW"

# Source function library.
. /etc/init.d/functions

# in ALTLinux only wks* and std26-* kernel have packet writing support
check_kernel()
{
		local flavor
		local kver
		local valid=0

		flavor=`/bin/uname -r|/bin/cut -d- -f2`
		kver=`kernelversion_minor`

		[ "$kver" -gt 5 ] && `egrep -qs '(std|wks)26' "$flavor"`
		[ "$kver" -eq 4 ] && `egrep -qs 'wks' "$flavor"`
		valid=$?
		echo "$valid"
}	

PATH=/sbin:/bin:/usr/sbin:/usr/bin
DEFAULTFILE=/etc/sysconfig/udftools
DEVICES=""
NEWINTNAMES="0 1 2 3"
UDEVNAMES="/dev/pktcdvd/0 /dev/pktcdvd/1 /dev/pktcdvd/2 /dev/pktcdvd/3"
UDEV=""
NEWINT=""
PKTSETUP=/usr/bin/pktsetup

if test -e /dev/.devfsd; then
    OLDINTNAMES="/dev/pktcdvd/0 /dev/pktcdvd/1 /dev/pktcdvd/2 /dev/pktcdvd/3"
else
    OLDINTNAMES="/dev/pktcdvd0 /dev/pktcdvd1 /dev/pktcdvd2 /dev/pktcdvd3"
fi

### if test -f "$DEFAULTFILE"; then
###     # Read user settings
###     . "$DEFAULTFILE"
### fi
SourceIfNotEmpty "$DEFAULTFILE"
### is it supposed to override #PKTSETUP ?
### if no - next check better to be at top of the script - faster exit ;-)

[ -x "$PKTSETUP" ] || exit 0

[ "`check_kernel`" -eq 1 ] || exit 0

# Only execute modprobe if DEVICES set - avoid possible problems with
# the module for people who don't use packet writing.
if test -n "$DEVICES"; then
    modprobe pktcdvd || true
    if test -z "$NEWINT"; then # User did not set NEWINT, try auto-detection
        if [ `/sbin/kernelversion_minor` -eq 6 ] && [ `/bin/uname -r|/bin/cut -d- -f1|/bin/cut -d. -f3` -ge 8 ]; then
            NEWINT=true
        else
            NEWINT=false
        fi
    fi
    if test -z "$UDEV"; then # User did not set UDEV, try auto-detection
        if grep -E -q "^[^[:space:]]+ /dev tmpfs" /proc/mounts; then
            UDEV=true
        else
            UDEV=false
        fi
    fi
fi

ECHO_PREFIX="    "
if $NEWINT; then
    ECHO_PREFIX="$ECHO_PREFIX /dev/pktcdvd/"
fi

local_MapDrive() {  # $1 - new packet device,  $2 - corresponding block device
     action "$ECHO_PREFIX$1 ==> $2"   "$PKTSETUP \"$1\" \"$2\" "
     return $?
}

local_UnmapDrive() {  # $1 - packet device to detach from block device $2
     action "$ECHO_PREFIX$1 -X- $2"   "$PKTSETUP -d \"$1\" "
     return $?
}

local_DevicesLoop() {  # $1 - action-function
     local FN=$1
     local err_cnt=0
        if $NEWINT; then
            set $NEWINTNAMES
        else
            if $UDEV; then
                set $UDEVNAMES
            else
                set $OLDINTNAMES
            fi
        fi

	for DEVICE in $DEVICES; do
	    $FN "$1" "$DEVICE"   || err_cnt=1 # not supported by /bin/sh: $((err_cnt++))
	    shift
	done

        return $err_cnt
};

dostart() {
    if test -z "$DEVICES"; then
       echo -n "Not starting $DESC: No devices listed in $DEFAULTFILE" 
       echo_passed
    else
       echo "Starting $DESC:"
       local_DevicesLoop local_MapDrive
    fi
    RETVAL=$?
    return $RETVAL
}

dostop() {
    if test -z "$DEVICES"; then
        echo -n "Not stopping $DESC: No devices listed in $DEFAULTFILE" 
        echo_passed
    else
        echo "Stopping $DESC:"
        local_DevicesLoop local_UnmapDrive
    fi
    RETVAL=$?
    return $RETVAL
}

case "$1" in
    start) dostart;;
    stop)  dostop;;
    status) $PKTSETUP -s || true;;
    restart|force-reload) dostop; dostart;;
    *)
        msg_usage "/sbin/service ${0##*/} {start|stop|restart|force-reload|status}"
	RETVAL=1
esac

exit $RETVAL


  reply	other threads:[~2005-08-12 13:54 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-08-09 23:30 [sisyphus] " Arioch
2005-08-10 21:00 ` [sisyphus] " Arioch
2005-08-11  8:29   ` Konstantin A. Lepikhov
2005-08-12 13:54     ` Arioch [this message]
2005-08-12 19:43       ` Konstantin A. Lepikhov
2005-08-13 11:02         ` Arioch
2005-08-13 18:51           ` Konstantin A. Lepikhov
2005-08-14 14:23             ` [sisyphus] Re: hotplug, UDEV и пакетная запись cd-r Arioch
2005-08-14 17:54               ` Konstantin A. Lepikhov
2005-08-14 23:24                 ` Arioch
2005-08-15  8:11                   ` Konstantin A. Lepikhov
2005-08-16 11:44                     ` Michael Shigorin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='ddia0i$k54$2@sea.gmane.org' \
    --to=the_arioch@nm.ru \
    --cc=sisyphus@altlinux.ru \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

ALT Linux Sisyphus discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://lore.altlinux.org/sisyphus/0 sisyphus/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 sisyphus sisyphus/ http://lore.altlinux.org/sisyphus \
		sisyphus@altlinux.ru sisyphus@altlinux.org sisyphus@lists.altlinux.org sisyphus@lists.altlinux.ru sisyphus@lists.altlinux.com sisyphus@linuxteam.iplabs.ru sisyphus@list.linux-os.ru
	public-inbox-index sisyphus

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://lore.altlinux.org/org.altlinux.lists.sisyphus


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git