#! /bin/sh
#
# |-----------------------------------------------------------|
# | Copyright (c) 1991, 1990 MIPS Computer Systems, Inc.      |
# | All Rights Reserved                                       |
# |-----------------------------------------------------------|
# |          Restricted Rights Legend                         |
# | Use, duplication, or disclosure by the Government is      |
# | subject to restrictions as set forth in                   |
# | subparagraph (c)(1)(ii) of the Rights in Technical        |
# | Data and Computer Software Clause of DFARS 252.227-7013.  |
# |         MIPS Computer Systems, Inc.                       |
# |         950 DeGuigne Avenue                               |
# |         Sunnyvale, California 94088-3650, USA             |
# |-----------------------------------------------------------|
#
# $Header: samedev,v 1.6.2.1 92/06/24 13:47:48 marker Exp $
#	Determine if any of the check_dev's are identical to the known_dev
#	by comparing their block or character special file major/minor numbers.

#!	chmod +x ${file}

set -ue

IFS="${IFS},"

if [ $# -lt 2 ]
then
	echo "Usage: ${0} known_dev check_dev ..." >&2
	exit 1
fi

eval `ls -l ${1} | \
	(read perm links uid gid major minor month day when name ; \
	echo perm=${perm} want=${major}/${minor})`

case "${perm}" in
b*)
	type=b
	;;
c*)
	type=c
	;;
*)
	echo "${0}: ${1}: Not a block or character device" >&2
	exit 1
	;;
esac

shift

ls -ld "$@" | while read perm links uid gid major minor month day when name
do
	case ${perm} in
	${type}* )
		if [ "${major}/${minor}" = "${want}" ]
		then
			echo "${name}"
		fi
	esac
done
