Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev_t treatment broken #11738

Open
p5pRT opened this issue Nov 7, 2011 · 3 comments
Open

dev_t treatment broken #11738

p5pRT opened this issue Nov 7, 2011 · 3 comments

Comments

@p5pRT
Copy link

p5pRT commented Nov 7, 2011

Migrated from rt.perl.org#103104 (status was 'open')

Searchable as RT103104$

@p5pRT
Copy link
Author

p5pRT commented Nov 7, 2011

From tchrist@perl.com

find2perl -ls is doing the wrong thing with st_rdev​:

  sub sizemm {
  my $rdev = shift;
  sprintf("%3d, %3d", ($rdev >> 8) & 0xff, $rdev & 0xff);
  }

That only works on dev_t's that are shorts, where the major number is in
the high byte and the minor number is in low byte. That is almost never
true any longer.

This works on the four systems I tested it on, but I don't really trust it.

  sub sizemm {
  my $dev = shift;

  # these are almost always wrong​:
  my $major = ($dev >> 8) & 0xff;
  my $minor = $dev & 0xff;

  # now fix the ones we know how to
  for ($^O) {

  if (/openbsd/) {
  $major = ($dev >> 8) & 0xff;
  $minor = ($dev & 0xff) | (($dev & 0xffff0000) >> 8);
  }

  if (/darwin/) {
  $major = ($dev >> 24) & 0xff;
  $minor = $dev & 0xffffff;
  }

  if (/solaris/) {
  $major = ($dev >> 18) & 0x3fff;
  $minor = $dev & 0x3ffff;
  }

  if (/linux/) {
  $major = (($dev >> 8) & 0xfff) | (($dev >> 32) & ~0xfff);
  $minor = ($dev & 0xff) | (($dev >> 12) & ~0xff);
  }

  }
  return sprintf("%3d, %3d", $major, $minor);
  }

And people *really* want to screw with our bitwise operators?
Don't even dream of it. I don't want to ever have to do more than
copy the C macros for this kind of thing.

--tom

Summary of my perl5 (revision 5 version 14 subversion 0) configuration​:
 
  Platform​:
  osname=openbsd, osvers=4.4, archname=OpenBSD.i386-openbsd
  uname='openbsd chthon 4.4 generic#0 i386 '
  config_args='-des'
  hint=recommended, useposix=true, d_sigaction=define
  useithreads=undef, usemultiplicity=undef
  useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
  use64bitint=undef, use64bitall=undef, uselongdouble=undef
  usemymalloc=y, bincompat5005=undef
  Compiler​:
  cc='cc', ccflags ='-fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include',
  optimize='-O2',
  cppflags='-fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include'
  ccversion='', gccversion='3.3.5 (propolice)', gccosandvers='openbsd4.4'
  intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
  d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
  ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
  alignbytes=4, prototype=define
  Linker and Libraries​:
  ld='cc', ldflags ='-Wl,-E -fstack-protector -L/usr/local/lib'
  libpth=/usr/local/lib /usr/lib
  libs=-lgdbm -lm -lutil -lc
  perllibs=-lm -lutil -lc
  libc=/usr/lib/libc.so.48.0, so=so, useshrplib=false, libperl=libperl.a
  gnulibc_version=''
  Dynamic Linking​:
  dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
  cccdlflags='-DPIC -fPIC ', lddlflags='-shared -fPIC -L/usr/local/lib -fstack-protector'

Characteristics of this binary (from libperl)​:
  Compile-time options​: MYMALLOC PERL_DONT_CREATE_GVSV PERL_MALLOC_WRAP
  PERL_PRESERVE_IVUV USE_LARGE_FILES USE_PERLIO
  USE_PERL_ATOF
  Built under openbsd
  Compiled at Jun 11 2011 11​:48​:28
  %ENV​:
  PERL_UNICODE="SA"
  @​INC​:
  /usr/local/lib/perl5/site_perl/5.14.0/OpenBSD.i386-openbsd
  /usr/local/lib/perl5/site_perl/5.14.0
  /usr/local/lib/perl5/5.14.0/OpenBSD.i386-openbsd
  /usr/local/lib/perl5/5.14.0
  /usr/local/lib/perl5/site_perl/5.12.3
  /usr/local/lib/perl5/site_perl/5.11.3
  /usr/local/lib/perl5/site_perl/5.10.1
  /usr/local/lib/perl5/site_perl/5.10.0
  /usr/local/lib/perl5/site_perl/5.8.7
  /usr/local/lib/perl5/site_perl/5.8.0
  /usr/local/lib/perl5/site_perl/5.6.0
  /usr/local/lib/perl5/site_perl/5.005
  /usr/local/lib/perl5/site_perl
  .

@p5pRT
Copy link
Author

p5pRT commented Feb 18, 2012

From @tonycoz

On Mon Nov 07 06​:44​:31 2011, tom christiansen wrote​:

find2perl -ls is doing the wrong thing with st_rdev​:

sub sizemm \{
my $rdev = shift;
sprintf\("%3d\, %3d"\, \($rdev >> 8\) & 0xff\, $rdev & 0xff\);
\}

That only works on dev_t's that are shorts, where the major number is
in
the high byte and the minor number is in low byte. That is almost
never
true any longer.

This works on the four systems I tested it on, but I don't really
trust it.

If find2perl weren't core, I'd suggest Unix​::Mknod.

Otherwise we could pull some similar around major()/minor() into core,
but it isn't POSIX - just common.

Tony

@p5pRT
Copy link
Author

p5pRT commented Feb 18, 2012

The RT System itself - Status changed from 'new' to 'open'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants