Package: disorderfs
Version: 0.5.1-1
Severity: normal

Dear Maintainer,

See the attached test program. You should see something like this:

/tmp/debrepro.LJec0mD2n2/first/disorderfs$ gcc test.c && ./a.out; ls -lad 
tst-dir* && rmdir tst-dir*
haven't found new directory 
"/tmp/debrepro.LJec0mD2n2/first/disorderfs/tst-dir.L9Wbsn"
drwx------ 2 infinity0 infinity0 4096 Nov 16 14:37 tst-dir.L9Wbsn

/tmp/debrepro.LJec0mD2n2/first/disorderfs$ cp test.c ..
/tmp/debrepro.LJec0mD2n2/first/disorderfs$ cd ..
/tmp/debrepro.LJec0mD2n2/first$ gcc test.c && ./a.out && ls -lad tst-dir* && 
rmdir tst-dir*
drwx------ 2 infinity0 infinity0 4096 Nov 16 14:35 tst-dir.vpiYtA

X

-- System Information:
Debian Release: stretch/sid
  APT prefers testing
  APT policy: (990, 'testing'), (500, 'stable'), (300, 'unstable'), (200, 
'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.7.0-1-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_GB.utf8, LC_CTYPE=en_GB.utf8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages disorderfs depends on:
ii  fuse        2.9.7-1
ii  libc6       2.24-5
ii  libfuse2    2.9.7-1
ii  libgcc1     1:6.2.0-10
ii  libstdc++6  6.2.0-10

disorderfs recommends no packages.

disorderfs suggests no packages.

-- no debconf information
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <mcheck.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/stat.h>

int main() {
  struct stat st1;
  struct stat st2;
  DIR *dir1;
  struct dirent *d;
  char *cwd;
  char *buf;

  cwd = getcwd (NULL, 0);
  if (cwd == NULL)
    {
      printf ("cannot get current directory name for object directory: %m\n");
      exit (1);
    }

  dir1 = opendir (".");
  if (dir1 == NULL)
    {
      printf ("cannot open object directory: %m\n");
      exit (1);
    }

  buf = (char *) malloc (strlen (cwd) + 1 + sizeof "tst-dir.XXXXXX");
  if (buf == NULL)
    {
      printf ("cannot allocate buffer: %m");
      exit (1);
    }

  stpcpy (stpcpy (stpcpy (buf, cwd), "/"), "tst-dir.XXXXXX");
  if (mkdtemp (buf) == NULL)
    {
      printf ("cannot create test directory in object directory: %m: %s\n", buf);
      exit (1);
    }
  if (stat (buf, &st1) < 0)
    {
      printf ("cannot stat new directory \"%s\": %m\n", buf);
      exit (1);
    }
  if (chmod (buf, 0700) < 0)
    {
      printf ("cannot change mode of new directory: %m\n");
      exit (1);
    }

  /* Try to find the new directory.  */
  rewinddir (dir1);
  errno = 0;
  while (NULL != (d = readdir (dir1)))
    {
      if (d->d_ino == st1.st_ino)
	{
	  /* Might be it.  Test the device.  We could use the st_dev
	     element from st1 but what the heck, do more testing.  */
	  size_t len = strlen (cwd) + 1 + _D_EXACT_NAMLEN (d) + 1;
	  char tmpbuf[len];

	  stpcpy (stpcpy (stpcpy (tmpbuf, cwd), "/"), d->d_name);

	  if (stat (tmpbuf, &st2) < 0)
	    {
	      printf ("cannot stat entry from readdir: %m: %s\n", tmpbuf);
	      exit (1);
	      d = NULL;
	      break;
	    }

	  if (st2.st_dev == st1.st_dev
	      && strcmp (d->d_name, buf + strlen (buf) - 14) == 0)
	    break;
	}
    }

  if (errno)
    {
      perror (strerror (errno));
      exit (1);
    }

  if (d == NULL)
    {
      printf ("haven't found new directory \"%s\"\n", buf);
      exit (1);
    }


}

Reply via email to