~ubuntu-branches/debian/experimental/nfs-utils/experimental

« back to all changes in this revision

Viewing changes to utils/gssd/err_util.c

  • Committer: Bazaar Package Importer
  • Author(s): Anibal Monsalve Salazar
  • Date: 2006-07-08 14:26:40 UTC
  • mfrom: (1.2.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20060708142640-r171kjj2a13gy2kz
Tags: 1:1.0.9-1
* Updated co-mantainer mail address.
* New upstream release.
  - Added 'mount.nfs' utility which can be used as a mount helper
    to mount nfs filesystems. It does not yet support 'user' mounts.
  - Makefile/autoconf tidyups
  - No compiles with no warnings
  - deleted debian/* at request of debian maintainer
  - deleted assorted other unused files
  - mountd can be run multi-threaded for configurations with many hundreds
    of clients (mountd -t 20).  Default is single-threaded
  - Support for selection NFS version to be exported, and protocol to
    use.  This requires kernel patches that should be in linux 2.6.19.
  - Use 65534 rather than -2 for default anon.  This makes no difference in many
    cases, but is important in some.
  - New utility 'rpcdebug' for controlled kernel 'debug' options for nfs and nfsd.
  - nfsstat reports NFSv4 operation statistics that should be available in
    linux 2.6.18.
  - assorted other fixes

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
static int fg = 0;
39
39
 
40
40
static char message_buf[500];
41
 
static char tmp_buf[500];
42
41
 
43
42
void initerr(char *progname, int set_verbosity, int set_fg)
44
43
{
48
47
                openlog(progname, LOG_PID, LOG_DAEMON);
49
48
}
50
49
 
 
50
 
51
51
void printerr(int priority, char *format, ...)
52
52
{
53
53
        va_list args;
54
54
        int ret;
55
 
 
56
 
        /* aggregate lines: only print buffer when we get to the end of a
57
 
         * line or run out of space: */
 
55
        int buf_used, buf_available;
 
56
        char *buf;
 
57
 
 
58
        /* Don't bother formatting a message we're never going to print! */
 
59
        if (priority > verbosity)
 
60
                return;
 
61
 
 
62
        buf_used = strlen(message_buf);
 
63
        /* subtract 4 to leave room for "...\n" if necessary */
 
64
        buf_available = sizeof(message_buf) - buf_used - 4;
 
65
        buf = message_buf + buf_used;
 
66
 
 
67
        /*
 
68
         * Aggregate lines: only print buffer when we get to the
 
69
         * end of a line or run out of space
 
70
         */
58
71
        va_start(args, format);
59
 
        ret = vsnprintf(tmp_buf, sizeof(tmp_buf), format, args);
 
72
        ret = vsnprintf(buf, buf_available, format, args);
60
73
        va_end(args);
61
 
        if ((ret < 0) || (ret >= sizeof(tmp_buf)))
62
 
                goto output;
63
 
        if (strlen(tmp_buf) + strlen(message_buf) + 1 > sizeof(message_buf))
64
 
                        goto output;
65
 
        strcat(message_buf, tmp_buf);
66
 
        if (tmp_buf[strlen(tmp_buf) - 1] == '\n')
67
 
                goto output;
 
74
 
 
75
        if (ret < 0)
 
76
                goto printit;
 
77
        if (ret >= buf_available) {
 
78
                /* Indicate we're truncating */
 
79
                strcat(message_buf, "...\n");
 
80
                goto printit;
 
81
        }
 
82
        if (message_buf[strlen(message_buf) - 1] == '\n')
 
83
                goto printit;
68
84
        return;
69
 
output:
70
 
        priority -= verbosity;
71
 
        if (priority < 0)
72
 
                priority = 0;
 
85
printit:
73
86
        if (fg) {
74
 
                if (priority == 0)
75
 
                        fprintf(stderr, "%s", message_buf);
 
87
                fprintf(stderr, "%s", message_buf);
76
88
        } else {
77
 
                int sys_pri;
78
 
                switch (priority) {
79
 
                        case 0:
80
 
                                sys_pri = LOG_ERR;
81
 
                                break;
82
 
                        case 1:
83
 
                                sys_pri = LOG_DEBUG;
84
 
                                break;
85
 
                        default:
86
 
                                goto out;
87
 
                }
88
 
                syslog(sys_pri, "%s", message_buf);
 
89
                syslog(LOG_ERR, "%s", message_buf);
89
90
        }
90
 
out:
 
91
        /* reset the buffer */
91
92
        memset(message_buf, 0, sizeof(message_buf));
92
93
}