~ubuntu-branches/ubuntu/saucy/procps/saucy

« back to all changes in this revision

Viewing changes to proc/devname.c

  • Committer: Package Import Robot
  • Author(s): Oliver Grawert
  • Date: 2012-06-20 13:12:40 UTC
  • mfrom: (2.1.21 sid)
  • Revision ID: package-import@ubuntu.com-20120620131240-923p0d8q88bmk3ac
Tags: 1:3.3.3-2ubuntu1
* Merge from Debian unstable.  Remaining changes:
  - debian/sysctl.d (Ubuntu-specific):
    + 10-console-messages.conf: stop low-level kernel messages on console.
    + 10-kernel-hardening.conf: add the kptr_restrict setting
    + 10-keyboard.conf.powerpc: mouse button emulation on PowerPC.
    + 10-network-security.conf: enable rp_filter and SYN-flood protection.
    + 10-ptrace.conf: describe new PTRACE setting.
    + 10-zeropage.conf: safe mmap_min_addr value for graceful fall-back.
    + README: describe how this directory is supposed to work.
  - debian/upstart (Ubuntu-specific): upstart configuration to replace old
    style sysv init script

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright 1998-2002 by Albert Cahalan; all rights resered.         
3
 
 * This file may be used subject to the terms and conditions of the
4
 
 * GNU Library General Public License Version 2, or any later version  
5
 
 * at your option, as published by the Free Software Foundation.
6
 
 * This program is distributed in the hope that it will be useful,
 
2
 * devname - device name functions
 
3
 * Copyright 1998-2002 by Albert Cahalan
 
4
 *
 
5
 * This library is free software; you can redistribute it and/or
 
6
 * modify it under the terms of the GNU Lesser General Public
 
7
 * License as published by the Free Software Foundation; either
 
8
 * version 2.1 of the License, or (at your option) any later version.
 
9
 *
 
10
 * This library is distributed in the hope that it will be useful,
7
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
8
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9
 
 * GNU Library General Public License for more details.
 
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
13
 * Lesser General Public License for more details.
 
14
 *
 
15
 * You should have received a copy of the GNU Lesser General Public
 
16
 * License along with this library; if not, write to the Free Software
 
17
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
10
18
 */                                 
11
19
 
12
20
#include <stdio.h>
18
26
#include <unistd.h>
19
27
#include "version.h"
20
28
#include "devname.h"
 
29
#include "alloc.h"
21
30
 
22
31
// This is the buffer size for a tty name. Any path is legal,
23
32
// which makes PAGE_SIZE appropriate (see kernel source), but
69
78
  p = buf;
70
79
  while(( p = strstr(p, " /dev/") )){  // " /dev/" is the second column
71
80
    tty_map_node *tmn;
72
 
    int len;
 
81
    size_t len;
73
82
    char *end;
74
83
    p += 6;
75
84
    end = strchr(p, ' ');
76
85
    if(!end) continue;
77
86
    len = end - p;
78
 
    tmn = calloc(1, sizeof(tty_map_node));
 
87
    tmn = xcalloc(sizeof(tty_map_node));
79
88
    tmn->next = tty_map;
80
89
    tty_map = tmn;
81
90
    /* if we have a devfs type name such as /dev/tts/%d then strip the %d but
281
290
  unsigned i = 0;
282
291
  int c;
283
292
  if(dev == 0u) goto no_tty;
284
 
  if(linux_version_code > LINUX_VERSION(2, 7, 0)){  // not likely to make 2.6.xx
285
 
    if(link_name(tmp, MAJOR_OF(dev), MINOR_OF(dev), pid, "tty"   )) goto abbrev;
286
 
  }
287
293
  if(driver_name(tmp, MAJOR_OF(dev), MINOR_OF(dev)               )) goto abbrev;
288
294
  if(  link_name(tmp, MAJOR_OF(dev), MINOR_OF(dev), pid, "fd/2"  )) goto abbrev;
289
295
  if( guess_name(tmp, MAJOR_OF(dev), MINOR_OF(dev)               )) goto abbrev;