From owner-freebsd-ports-bugs@FreeBSD.ORG Tue Jul 19 12:30:34 2005 Return-Path: X-Original-To: freebsd-ports-bugs@hub.freebsd.org Delivered-To: freebsd-ports-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 2EDE816A425 for ; Tue, 19 Jul 2005 12:30:33 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0B58243D5D for ; Tue, 19 Jul 2005 12:30:32 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.3/8.13.3) with ESMTP id j6JCUW3m009785 for ; Tue, 19 Jul 2005 12:30:32 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.3/8.13.1/Submit) id j6JCUWJG009784; Tue, 19 Jul 2005 12:30:32 GMT (envelope-from gnats) Resent-Date: Tue, 19 Jul 2005 12:30:32 GMT Resent-Message-Id: <200507191230.j6JCUWJG009784@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-ports-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Stefan Sperling Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E0A2616A41F for ; Tue, 19 Jul 2005 12:25:04 +0000 (GMT) (envelope-from stsp@stsp.in-berlin.de) Received: from einhorn.in-berlin.de (einhorn.in-berlin.de [192.109.42.8]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4814B43D4C for ; Tue, 19 Jul 2005 12:25:03 +0000 (GMT) (envelope-from stsp@stsp.in-berlin.de) Received: from dice.seeling33.de (e178132097.adsl.alicedsl.de [85.178.132.97]) (authenticated bits=0) by einhorn.in-berlin.de (8.12.10/8.12.10/Debian-4) with ESMTP id j6JCOxS8000842 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Tue, 19 Jul 2005 14:25:01 +0200 Received: by dice.seeling33.de (Postfix, from userid 1001) id 5C60833C39; Tue, 19 Jul 2005 14:24:59 +0200 (CEST) Message-Id: <20050719122459.5C60833C39@dice.seeling33.de> Date: Tue, 19 Jul 2005 14:24:59 +0200 (CEST) From: Stefan Sperling To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: Subject: ports/83719: [patch] teach eject to open devices specified with /dev/ prefix X-BeenThere: freebsd-ports-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Stefan Sperling List-Id: Ports bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Jul 2005 12:30:34 -0000 >Number: 83719 >Category: ports >Synopsis: [patch] teach eject to open devices specified with /dev/ prefix >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Tue Jul 19 12:30:31 GMT 2005 >Closed-Date: >Last-Modified: >Originator: Stefan Sperling >Release: FreeBSD 6.0-CURRENT i386 >Organization: >Environment: System: FreeBSD dice.seeling33.de 6.0-CURRENT FreeBSD 6.0-CURRENT #38: Sun Jul 17 19:10:40 CEST 2005 stsp@dice.seeling33.de:/usr/src/sys/i386/compile/DICE i386 >Description: The eject program currently only accepts devices specified with their plain name, e.g. acd0, instead of /dev/acd0. This is a minor nuisance for people coming from linux, since the linux eject accepts devices with their full path. It might also break applications that expect the eject program to accept a full path to the device file. >How-To-Repeat: Try 'eject /dev/'. It won't work. 'eject ' in turn will work. >Fix: Please put these two patches into /usr/ports/sysutiles/eject/files, and forward upstream if appropriate. The first patch obsoletes the file patch-eject.c that is currently applied to the port. patch-aa: --- eject.c.orig Tue Jul 19 13:43:37 2005 +++ eject.c Tue Jul 19 14:14:24 2005 @@ -122,7 +122,7 @@ } /* - * check device is exists. + * check whether device exists. */ int @@ -133,8 +133,14 @@ int sts; struct stat sb; - if (asprintf(device, "/dev/%sc", name) == -1) - return sts; + if (strncmp("/dev/", name, strlen("/dev/")) == 0) { + if (asprintf(device, "%s", name) == -1) + return sts; + } + else { + if (asprintf(device, "/dev/%s", name) == -1) + return sts; + } if (vflag || nflag) { printf("%s: using device %s\n", program, device); } @@ -174,11 +180,16 @@ /* get proper mount information into the list */ len = strlen(name); for (n = 0; n < mnts; n++) { - p = rindex(mntbuf[n].f_mntfromname, '/'); - if (p == NULL) { - continue; + if (strncmp("/dev/", name, strlen("/dev/")) == 0) + p = mntbuf[n].f_mntfromname; + else { + p = rindex(mntbuf[n].f_mntfromname, '/'); + if (p == NULL) + continue; + ++p; } - for (i = 0, ++p, q = name; *p != '\0' && *q != '\0'; ++i, ++p, ++q) { + + for (i = 0, p, q = name; *p != '\0' && *q != '\0'; ++i, ++p, ++q) { if (*p != *q) { break; } patch-ab: --- eject.1.orig Tue Jul 19 13:43:50 2005 +++ eject.1 Tue Jul 19 13:26:55 2005 @@ -39,7 +39,12 @@ is a program to eject removable media from drive. The .Ar device -is a removable drive name such as cd0, matcd0, mcd0, scd0, wcd0 or od0. +is a removable drive name such as cd0, matcd0, mcd0, scd0, wcd0 or od0. +For compatiblity reasons, the string +.Dq Li /dev/ +may optionally be prepended to +.Ar device . + .Nm eject unmounts the .Ar device >Release-Note: >Audit-Trail: >Unformatted: