~ubuntu-branches/ubuntu/utopic/acct/utopic

« back to all changes in this revision

Viewing changes to debian/patches/04-lastcomm-forwards.patch

  • Committer: Bazaar Package Importer
  • Author(s): Colin Watson
  • Date: 2009-11-20 19:00:51 UTC
  • mfrom: (3.1.4 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091120190051-ya3i3t9ygi4jpjgg
Tags: 6.4~pre1-9ubuntu1
* Resynchronise with Debian. Remaining changes:
  - Remove stop links from rc0 and rc6.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Author: Dean Gaudet <dean@arctic.org>
 
2
Description: Adds lastcomm -f - stdin and --forwards support (Closes: #262583).
 
3
 
 
4
diff -Naurp acct.orig/lastcomm.1 acct/lastcomm.1
 
5
--- acct.orig/lastcomm.1        2009-06-09 05:00:45.000000000 +0000
 
6
+++ acct/lastcomm.1     2009-07-06 22:32:01.000000000 +0000
 
7
@@ -23,6 +23,10 @@ lastcomm \-  print out information about
 
8
 ]
 
9
 .br
 
10
 [
 
11
+.B \-\-forwards
 
12
+]
 
13
+.br
 
14
+[
 
15
 .BI \-f " filename"
 
16
 |
 
17
 .BI \-\-file " filename"
 
18
@@ -131,11 +135,25 @@ List records for command
 
19
 List records for tty
 
20
 .I name.
 
21
 .TP
 
22
+.BI \-\-forwards
 
23
+Read file forwards instead of backwards. This avoids trying to seek on the file
 
24
+and can be used to read from a pipe. This must be specified prior to any
 
25
+.BI \-f
 
26
+arguments.
 
27
+.TP
 
28
 .BI \-f " filename, " \-\-file " filename"
 
29
 Read from the file 
 
30
 .I filename 
 
31
 instead of
 
32
-.I acct
 
33
+.I acct.
 
34
+A filename of "-" will result in reading from stdin. This must either be the
 
35
+first
 
36
+.BI \-f
 
37
+option, or
 
38
+.BI \-\-forwards
 
39
+must precede all
 
40
+.BI \-f
 
41
+options.
 
42
 .TP
 
43
 .BI \-\-ahz " hz"
 
44
 Use this flag to tell the program what
 
45
diff -Naurp acct.orig/lastcomm.c acct/lastcomm.c
 
46
--- acct.orig/lastcomm.c        2009-06-09 05:00:45.000000000 +0000
 
47
+++ acct/lastcomm.c     2009-07-06 22:32:01.000000000 +0000
 
48
@@ -96,12 +96,9 @@ main (int argc, char *argv[])
 
49
   int c;
 
50
   int other_pacct_file_specified = 0; /* nonzero if the user used the
 
51
                                         `-f' or `--file' flag */
 
52
+  int backwards = 1; /* default to reading backwards */
 
53
 
 
54
   program_name = argv[0];
 
55
-  
 
56
-  /* Tell the pacct reader that we want to do things backwards! */
 
57
-
 
58
-  pacct_init (1);
 
59
 
 
60
   while (1)
 
61
     {
 
62
@@ -118,6 +115,7 @@ main (int argc, char *argv[])
 
63
        { "tty", required_argument, NULL, 8 },
 
64
        { "command", required_argument, NULL, 9 },
 
65
        { "ahz", required_argument, NULL, 10 },
 
66
+       { "forwards", no_argument, NULL, 11 },
 
67
 #ifdef HAVE_PAGING
 
68
        { "show-paging", no_argument, NULL, 11 },
 
69
 #endif
 
70
@@ -146,6 +144,18 @@ main (int argc, char *argv[])
 
71
          break;
 
72
        case 'f':
 
73
        case 4:
 
74
+         if (strcmp(optarg, "-") == 0)
 
75
+           {
 
76
+             if (backwards && other_pacct_file_specified)
 
77
+               {
 
78
+                 printf ("%s: -f - must be specified first, or --forwards must precede the first -f\n", program_name);
 
79
+                 exit (1);
 
80
+               }
 
81
+             backwards = 0;
 
82
+             optarg = "/proc/self/fd/0";
 
83
+           }
 
84
+         if (other_pacct_file_specified == 0)
 
85
+           pacct_init(backwards);
 
86
          add_pacct_file (optarg);
 
87
          other_pacct_file_specified = 1;
 
88
          break;
 
89
@@ -186,6 +196,14 @@ main (int argc, char *argv[])
 
90
          show_paging = 1;
 
91
           break;
 
92
 #endif
 
93
+       case 12:
 
94
+         if (other_pacct_file_specified)
 
95
+           {
 
96
+             printf ("%s: --forwards must come before -f\n", program_name);
 
97
+             exit (1);
 
98
+           }
 
99
+         backwards = 0;
 
100
+         break;
 
101
        case 'h':
 
102
        case 3:
 
103
          /* This should fall through to default! */
 
104
@@ -196,6 +214,9 @@ main (int argc, char *argv[])
 
105
        }
 
106
     }
 
107
 
 
108
+  if (other_pacct_file_specified == 0)
 
109
+    pacct_init(backwards);
 
110
+
 
111
   /* if we get here, we expect everything else to be a username,
 
112
      terminal name, or command name */
 
113
 
 
114
@@ -275,7 +296,7 @@ give_usage (void)
 
115
              "p"
 
116
 #endif
 
117
               "V] [-f file] [command] ... [user] ... [terminal] ...\n"
 
118
-"       [--file <file>] [--strict-match] [--print-controls]\n"
 
119
+"       [--forwards] [--file <file>] [--strict-match] [--print-controls]\n"
 
120
 "       [--user <name>] [--tty <name>] [--command <name>] [--debug]\n"
 
121
 "       "
 
122
 #ifdef HAVE_PAGING