~ubuntu-branches/ubuntu/quantal/util-linux/quantal

« back to all changes in this revision

Viewing changes to sys-utils/dmesg.c

  • Committer: Bazaar Package Importer
  • Author(s): Steve Langasek
  • Date: 2011-06-20 22:31:50 UTC
  • mfrom: (1.6.3 upstream) (4.5.1 sid)
  • Revision ID: james.westby@ubuntu.com-20110620223150-lz8wrv0946ihcz3z
Tags: 2.19.1-2ubuntu1
* Merge from Debian unstable, remaining changes:
  - Build for multiarch.
  - Add pre-depends on multiarch-support.
  - configure.ac: don't try to be clever about extracting a path name from
    $libdir to append to /usr in a way that's not overridable; instead,
    reuse the built-in configurable libexecdir.
  - Fix up the .pc.in files to know about libexecdir, so our substitutions
    don't leave us with unusable pkg-config files.
  - Install custom blkid.conf to use /dev/.blkid.tab since we don't
    expect device names to survive a reboot
  - Mention mountall(8) in fstab(5) manpages, along with its special
    options.
  - Since upstart is required in Ubuntu, the hwclock.sh init script is not
    called on startup and the hwclockfirst.sh init script is removed.
  - Drop depends on initscripts for the above.
  - Replace hwclock udev rule with an Upstart job.
  - For the case where mount is called with a directory to mount, look
    that directory up in mountall's /lib/init/fstab if we couldn't find
    it mentioned anywhere else.  This means "mount /proc", "mount /sys",
    etc. work.
  - mount.8 points to the cifs-utils package, not the obsolete smbfs one. 
* Dropped changes:
  - mount.preinst: lsb_release has been fixed in lucid and above to be
    usable without configuration, so we don't have to diverge from Debian
    here anymore.
* Changes merged upstream:
  - sfdisk support for '+' with '-N'
  - mount/umount.c: fix a segfault on umount with empty mtab entry
  - Fix arbitrary unmount with fuse security issue

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
#include <stdio.h>
34
34
#include <getopt.h>
35
35
#include <stdlib.h>
36
 
# include <sys/klog.h>
 
36
#include <sys/klog.h>
37
37
 
38
38
#include "nls.h"
 
39
#include "strutils.h"
39
40
 
40
41
static char *progname;
41
42
 
70
71
                        break;
71
72
                case 'n':
72
73
                        cmd = 8;        /* Set level of messages */
73
 
                        level = atoi(optarg);
 
74
                        level = strtol_or_err(optarg, _("failed to parse level"));
74
75
                        break;
75
76
                case 'r':
76
77
                        raw = 1;
77
78
                        break;
78
79
                case 's':
79
 
                        bufsize = atoi(optarg);
 
80
                        bufsize = strtol_or_err(optarg, _("failed to parse buffer size"));
80
81
                        if (bufsize < 4096)
81
82
                                bufsize = 4096;
82
83
                        break;
83
84
                case '?':
84
85
                default:
85
86
                        usage();
86
 
                        exit(1);
 
87
                        exit(EXIT_FAILURE);
87
88
                }
88
89
        }
89
90
        argc -= optind;
91
92
 
92
93
        if (argc > 1) {
93
94
                usage();
94
 
                exit(1);
 
95
                exit(EXIT_FAILURE);
95
96
        }
96
97
 
97
98
        if (cmd == 8) {
98
99
                n = klogctl(cmd, NULL, level);
99
100
                if (n < 0) {
100
101
                        perror("klogctl");
101
 
                        exit(1);
 
102
                        exit(EXIT_FAILURE);
102
103
                }
103
 
                exit(0);
 
104
                exit(EXIT_SUCCESS);
104
105
        }
105
106
 
106
107
        if (!bufsize) {
111
112
 
112
113
        if (bufsize) {
113
114
                sz = bufsize + 8;
114
 
                buf = (char *) malloc(sz);
 
115
                buf = (char *) malloc(sz * sizeof(char));
115
116
                n = klogctl(cmd, buf, sz);
116
117
        } else {
117
118
                sz = 16392;
118
119
                while (1) {
119
 
                        buf = (char *) malloc(sz);
 
120
                        buf = (char *) malloc(sz * sizeof(char));
120
121
                        n = klogctl(3, buf, sz);        /* read only */
121
122
                        if (n != sz || sz > (1<<28))
122
123
                                break;
130
131
 
131
132
        if (n < 0) {
132
133
                perror("klogctl");
133
 
                exit(1);
 
134
                exit(EXIT_FAILURE);
134
135
        }
135
136
 
136
137
        lastc = '\n';
147
148
        }
148
149
        if (lastc != '\n')
149
150
                putchar('\n');
 
151
        free(buf);
150
152
        return 0;
151
153
}