SQLite Forum

Is there a reason for MAX_PATHNAME=512 for Unix VFSs?
Login

Is there a reason for MAX_PATHNAME=512 for Unix VFSs?

(1) By Ulrich Telle (utelle) on 2023-02-24 20:20:03 [source]

All Unix VFSs are limited to maximum pathname lengths of 512 bytes. And this limit is hard coded in os_unix.c as #define MAX_PATHNAME 512. Is there a reason for this limitation?

Most (if not all) Linux systems support maximum pathname lengths of 4096 bytes nowadays.

Would it be possible to increase the limit for future SQLite versions? Or at least to make it configurable somehow?

(2) By Larry Brasfield (larrybr) on 2023-02-24 21:04:00 in reply to 1 [link] [source]

limit is hard coded in os_unix.c as #define MAX_PATHNAME 512. Is there a reason for this limitation?

I was once surprised to learn that finding the OS-determined limit, even on *Nix-like systems, is not portable. I even seem to recall that it was not always available before runtime. I suspect this is why you see it hard-coded.

Most (if not all) Linux systems support maximum pathname lengths of 4096 bytes nowadays.

Yes, and they tend to be a well-behaved subset of *Nix-like systems.

Would it be possible to increase the limit for future SQLite versions? Or at least to make it configurable somehow?

Configurable perhaps.

(3) By Warren Young (wyoung) on 2023-02-24 23:39:23 in reply to 2 [link] [source]

the OS-determined limit, even on *Nix-like systems, is not portable

It's as portable as it needs to be. pathconf("…", _PC_PATH_MAX) was first added to 4.4BSD, then later appeared in POSIX.1-2001. While there are doubtless *ix systems not conforming to either of those still in service, they're too badly outdated to be of much interest any more.

it was not always available before runtime

Yes, because it depends on where that path points.

  • Different filesystems may have different limits

  • Even it it's all-Linux and all-ext4 but the path spans an NFS link, the limit may change. (Don't tell me about how SQLite doesn't like NFS. We're below that level here.)

  • If you call that function under a chroot/jail/container namespace, you may get a different answer than calling on the raw host.

(4) By Ulrich Telle (utelle) on 2023-02-25 09:34:23 in reply to 2 [link] [source]

I was once surprised to learn that finding the OS-determined limit, even on *Nix-like systems, is not portable. I even seem to recall that it was not always available before runtime. I suspect this is why you see it hard-coded.

Most likely a length of 512 was/is the least common multiple.

Would it be possible to increase the limit for future SQLite versions? Or at least to make it configurable somehow?

Configurable perhaps.

That would be really great.