This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

open() giving ENOENT when trying to create files with control chars


I'm trying to create a file (on NTFS) with a CR in the name and getting
ENOENT; is it possible for this to work (without a managed mount)?

Trying all possible characters:

#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <ctype.h>

int main(int argc, char **argv)
{
  int fd, c, err;
  char filename[4] = "foo";
  char buf[12];

  for (c = 1; c <= 255; ++c) {
    filename[1] = c;
    fd = open (filename, O_WRONLY|O_CREAT|O_EXCL, 0640);
    if (fd < 0) {
      err = errno;
      printf ("%02x%s: %s\n", c,
              (iscntrl (c) ? "" : (sprintf (buf, " (%c)", c), buf)),
              strerror (err));
    } else {
      close (fd);
      if (unlink (filename))
        fprintf (stderr, "%x: unlink failed: %s\n", c, strerror (errno));
    } 
  }
  return 0;
}

shows all control characters and just a few others not working (obviously
/ and : are out):

01: No such file or directory
02: No such file or directory
03: No such file or directory
04: No such file or directory
05: No such file or directory
06: No such file or directory
07: No such file or directory
08: No such file or directory
09: No such file or directory
0a: No such file or directory
0b: No such file or directory
0c: No such file or directory
0d: No such file or directory
0e: No such file or directory
0f: No such file or directory
10: No such file or directory
11: No such file or directory
12: No such file or directory
13: No such file or directory
14: No such file or directory
15: No such file or directory
16: No such file or directory
17: No such file or directory
18: No such file or directory
19: No such file or directory
1a: No such file or directory
1b: No such file or directory
1c: No such file or directory
1d: No such file or directory
1e: No such file or directory
1f: No such file or directory
22 ("): No such file or directory
2a (*): No such file or directory
2f (/): No such file or directory
3a (:): No such file or directory
3c (<): No such file or directory
3e (>): No such file or directory
3f (?): No such file or directory
5c (\): No such file or directory
7c (|): No such file or directory

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]