From owner-freebsd-bugs@FreeBSD.ORG Tue Sep 9 11:50:12 2003 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 188A116A4BF for ; Tue, 9 Sep 2003 11:50:12 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8758743FCB for ; Tue, 9 Sep 2003 11:50:10 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.9/8.12.9) with ESMTP id h89IoAUp076989 for ; Tue, 9 Sep 2003 11:50:10 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.9/8.12.9/Submit) id h89IoAmL076988; Tue, 9 Sep 2003 11:50:10 -0700 (PDT) Resent-Date: Tue, 9 Sep 2003 11:50:10 -0700 (PDT) Resent-Message-Id: <200309091850.h89IoAmL076988@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Lukas Ertl Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C629616A4BF for ; Tue, 9 Sep 2003 11:45:34 -0700 (PDT) Received: from mailbox.univie.ac.at (mailbox.univie.ac.at [131.130.1.27]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4F27443FE1 for ; Tue, 9 Sep 2003 11:45:33 -0700 (PDT) (envelope-from le@univie.ac.at) Received: from korben.in.tern (dialin202.cc.univie.ac.at [131.130.202.202]) by mailbox.univie.ac.at (8.12.9/8.12.9) with ESMTP id h89IitPw073540 for ; Tue, 9 Sep 2003 20:45:09 +0200 Received: from korben.in.tern (korben.in.tern [127.0.0.1]) by korben.in.tern (8.12.9/8.12.9) with ESMTP id h89IiMTN002161 for ; Tue, 9 Sep 2003 20:44:27 +0200 (CEST) (envelope-from le@korben.in.tern) Received: (from le@localhost) by korben.in.tern (8.12.9/8.12.9/Submit) id h89IiJZM002160; Tue, 9 Sep 2003 20:44:19 +0200 (CEST) (envelope-from le) Message-Id: <200309091844.h89IiJZM002160@korben.in.tern> Date: Tue, 9 Sep 2003 20:44:19 +0200 (CEST) From: Lukas Ertl To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: bin/56648: [PATCH] enable rcorder(8) to use a directory for locating config files X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Lukas Ertl List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Sep 2003 18:50:12 -0000 >Number: 56648 >Category: bin >Synopsis: [PATCH] enable rcorder(8) to use a directory for locating config files >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: update >Submitter-Id: current-users >Arrival-Date: Tue Sep 09 11:50:09 PDT 2003 >Closed-Date: >Last-Modified: >Originator: Lukas Ertl >Release: FreeBSD 5.1-CURRENT i386 >Organization: Vienna University Computer Center >Environment: System: FreeBSD korben 5.1-CURRENT FreeBSD 5.1-CURRENT #16: Sun Sep 7 18:12:54 CEST 2003 le@korben:/usr/obj/usr/src/sys/KORBEN i386 >Description: The attached patch enables rcorder(8) to use "-D " to locate the configuration files instead of passing in all configuration filenames via a shell glob. >How-To-Repeat: >Fix: --- rcorder.diff begins here --- Index: sbin/rcorder/rcorder.8 =================================================================== RCS file: /usr/local/bsdcvs/src/sbin/rcorder/rcorder.8,v retrieving revision 1.3 diff -u -r1.3 rcorder.8 --- sbin/rcorder/rcorder.8 25 Nov 2002 16:23:03 -0000 1.3 +++ sbin/rcorder/rcorder.8 9 Sep 2003 18:35:46 -0000 @@ -41,7 +41,7 @@ .Nm .Op Fl k Ar keep .Op Fl s Ar skip -.Ar +.Fl D Ar directory | Ar .Sh DESCRIPTION The .Nm @@ -104,6 +104,10 @@ If any .Fl s option is given, files containing the matching keyword are not listed. +.It Fl D +Instead of listing all filenames on the command line, use the files +located in the specified +.Ar directory . .El .Pp An example block follows: Index: sbin/rcorder/rcorder.c =================================================================== RCS file: /usr/local/bsdcvs/src/sbin/rcorder/rcorder.c,v retrieving revision 1.2 diff -u -r1.2 rcorder.c --- sbin/rcorder/rcorder.c 7 Sep 2003 14:17:17 -0000 1.2 +++ sbin/rcorder/rcorder.c 7 Sep 2003 17:54:59 -0000 @@ -37,8 +37,10 @@ __FBSDID("$FreeBSD: src/sbin/rcorder/rcorder.c,v 1.2 2003/09/07 14:17:17 charnier Exp $"); #include +#include #include +#include #include #include #include @@ -150,16 +152,24 @@ void initialize(void); void generate_ordering(void); int main(int, char *[]); +int get_files(char *, char ***); int main(argc, argv) int argc; char *argv[]; { - int ch; + char *directory; + int ch, Dflag; - while ((ch = getopt(argc, argv, "dk:s:")) != -1) + Dflag = 0; + + while ((ch = getopt(argc, argv, "D:dk:s:")) != -1) switch (ch) { + case 'D': + Dflag = 1; + directory = optarg; + break; case 'd': #ifdef DEBUG debug = 1; @@ -180,8 +190,12 @@ argc -= optind; argv += optind; - file_count = argc; - file_list = argv; + if (Dflag) { + file_count = get_files(directory, &file_list); + } else { + file_count = argc; + file_list = argv; + } DPRINTF((stderr, "parse_args\n")); initialize(); @@ -192,6 +206,37 @@ DPRINTF((stderr, "generate_ordering\n")); exit(exit_code); +} + +int +get_files(char *dir, char ***list) +{ + char *fname; + DIR *dirp; + int count, i; + struct dirent *entry; + + count = 0; + + if (dir[strlen(dir)-1] == '/') + dir[strlen(dir)-1] = '\0'; + + if ((dirp = opendir(dir)) == NULL) + return 0; + + while ((entry = readdir(dirp)) != NULL) { + if (strcmp(entry->d_name, ".") == 0 || + strcmp(entry->d_name, "..") == 0) + continue; + fname = emalloc(MAXPATHLEN); + snprintf(fname, MAXPATHLEN, "%s/%s", dir, entry->d_name); + *list = erealloc(*list, (count+1)*sizeof(char *)); + (*list)[count] = fname; + count++; + } + closedir(dirp); + + return count; } /* --- rcorder.diff ends here --- >Release-Note: >Audit-Trail: >Unformatted: