summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>1999-10-14 01:19:08 +0000
committerRoland McGrath <roland@gnu.org>1999-10-14 01:19:08 +0000
commit78fe8216941a8d0f6fb6b9259d8b0f4ed70978d4 (patch)
tree8b1996d9bd274821bd04e34a426a5359c6468656
parent8d9a019cbb1b12f9763a9863196a7742de91dd43 (diff)
1999-10-13 Roland McGrath <roland@baalperazim.frob.com>
* lookup.c (diskfs_lookup): Enforce diskfs_name_max limit for CREATE and RENAME, returning ENAMETOOLONG for violations. * io-pathconf.c (diskfs_S_io_pathconf): _PC_NO_TRUNC controlled by diskfs_name_max setting.
-rw-r--r--libdiskfs/io-pathconf.c7
-rw-r--r--libdiskfs/lookup.c9
2 files changed, 11 insertions, 5 deletions
diff --git a/libdiskfs/io-pathconf.c b/libdiskfs/io-pathconf.c
index ec13fd14..8c86cabf 100644
--- a/libdiskfs/io-pathconf.c
+++ b/libdiskfs/io-pathconf.c
@@ -44,11 +44,14 @@ diskfs_S_io_pathconf (struct protid *cred,
case _PC_NAME_MAX:
/* <hurd/hurd_types.defs> string_t constrains the upper bound. */
- *value = diskfs_name_max > 1024 ? 1024 : diskfs_name_max;
+ *value = diskfs_name_max > 1023 ? 1023 : diskfs_name_max;
+ break;
+
+ case _PC_NO_TRUNC: /* enforced in diskfs_lookup */
+ *value = diskfs_name_max >= 0;
break;
case _PC_CHOWN_RESTRICTED:
- case _PC_NO_TRUNC: /* look at string_t trunc behavior in MiG */
case _PC_SYNC_IO:
case _PC_ASYNC_IO:
*value = 1;
diff --git a/libdiskfs/lookup.c b/libdiskfs/lookup.c
index 10419f51..d81a053e 100644
--- a/libdiskfs/lookup.c
+++ b/libdiskfs/lookup.c
@@ -204,9 +204,12 @@ diskfs_lookup (struct node *dp, char *name, enum lookup_type type,
{
error_t err2;
- err2 = fshelp_checkdirmod (&dp->dn_stat,
- (err || !np) ? 0 : &(*np)->dn_stat,
- cred->user);
+ if (diskfs_name_max > 0 && strlen (name) > diskfs_name_max)
+ err2 = ENAMETOOLONG;
+ else
+ err2 = fshelp_checkdirmod (&dp->dn_stat,
+ (err || !np) ? 0 : &(*np)->dn_stat,
+ cred->user);
if (err2)
{
if (np && !err)