~ubuntu-branches/ubuntu/intrepid/procps/intrepid-security

« back to all changes in this revision

Viewing changes to proc/devname.c

  • Committer: Bazaar Package Importer
  • Author(s): Colin Watson
  • Date: 2004-12-08 10:45:17 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20041208104517-dddigjyt093j9ql6
Tags: 1:3.2.4-1ubuntu1
Resynchronise with Debian.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
#include "version.h"
20
20
#include "devname.h"
21
21
 
22
 
#include <asm/page.h>
23
 
#ifndef PAGE_SIZE
24
 
#define PAGE_SIZE (sizeof(long)*1024)
25
 
#endif
 
22
// This is the buffer size for a tty name. Any path is legal,
 
23
// which makes PAGE_SIZE appropriate (see kernel source), but
 
24
// that is only 99% portable and utmp only holds 32 anyway.
 
25
#define NAME_SIZE 128
26
26
 
27
27
/* Who uses what:
28
28
 *
139
139
"AM0",  "AM1",  "AM2",  "AM3",  "AM4",  "AM5",  "AM6",  "AM7",
140
140
"AM8",  "AM9",  "AM10", "AM11", "AM12", "AM13", "AM14", "AM15",
141
141
"DB0",  "DB1",  "DB2",  "DB3",  "DB4",  "DB5",  "DB6",  "DB7",
 
142
"SG0",
 
143
"SMX0",  "SMX1",  "SMX2",
 
144
"MM0",  "MM1",
142
145
};
143
146
 
144
147
/* Try to guess the device name (useful until /proc/PID/tty is added) */
216
219
  char path[32];
217
220
  int count;
218
221
  sprintf(path, "/proc/%d/%s", pid, name);  /* often permission denied */
219
 
  count = readlink(path,buf,PAGE_SIZE-1);
 
222
  count = readlink(path,buf,NAME_SIZE-1);
220
223
  if(count == -1) return 0;
221
224
  buf[count] = '\0';
222
225
  if(stat(buf, &sbuf) < 0) return 0;
227
230
 
228
231
/* number --> name */
229
232
unsigned dev_to_tty(char *restrict ret, unsigned chop, dev_t dev_t_dev, int pid, unsigned int flags) {
230
 
  static char buf[PAGE_SIZE];
 
233
  static char buf[NAME_SIZE];
231
234
  char *restrict tmp = buf;
232
235
  unsigned dev = dev_t_dev;
233
236
  unsigned i = 0;