#!/bin/sh

. /lib/partman/lib/base.sh

dev=$2
id=$3
part=$dev/$id

cd $dev

[ -f $part/method -a -f $part/acting_filesystem ] || return 0
filesystem=$(cat $part/acting_filesystem)

case $1 in
    mountpoint)
	if select_mountpoint $dev $id; then
		update_partition $dev $id
	fi
	;;
    options)
	select_mountoptions $dev $id
	;;
    label)
	label=''
	if [ -f $part/label ]; then
		label=$(cat $part/label)
	fi
	db_set partman-basicfilesystems/choose_label "$label"
	db_input critical partman-basicfilesystems/choose_label || true
	db_go || exit 1
	db_get partman-basicfilesystems/choose_label
	if [ "$RET" ]; then
		echo "$RET" >$part/label
	else
		rm -f $part/label
	fi
	db_reset partman-basicfilesystems/choose_label
	;;
esac

exit 0
