[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[MiNT] [PATCH] symlink attributes on ramfs



Hello.

Some people noticed that tar 1.26 was unable to create an archive from symlinks stored on FreeMiNT's ramdisk. It failed with "Range error".

After investigation, this problem comes from tar's src/create.c, in function dump_file0():
      size_t linklen = st->stat.st_size;
      ...
      buffer = (char *) alloca (linklen + 1);
      size = readlinkat (parentfd, name, buffer, linklen + 1);

Actually, stat.st_size was always 0 for symlinks stored on /ram, while it should be the length of the target. This can be easily verified using the ls -l command and looking at the size of the symlinks.

Additionally, the permissions of the ramdisk symlinks were l--------- while they should be lrwxrwxrwx. There was no trouble with that, but this was ugly.

I fixed both issues.

Alan or Helmut, please commit in the FreeMiNT tree!

statram.patch
Fixed file size and permissions of symlinks stored on ramfs. Contributed by Vincent Riviere.

--
Vincent Rivière
diff -x CVS -aurN freemint.orig/sys/ramfs.c freemint/sys/ramfs.c
--- freemint.orig/sys/ramfs.c	2011-05-01 16:43:17.000000000 +0200
+++ freemint/sys/ramfs.c	2011-12-09 00:38:22.625000000 +0100
@@ -1672,7 +1672,7 @@
 	if (IS_IMMUTABLE (c))
 		return EACCES;
 
-	r = __creat (c, name, &new, S_IFLNK, 0);
+	r = __creat (c, name, &new, 0777 | S_IFLNK, 0);
 	if (r == E_OK)
 	{
 		ushort len = strlen (to) + 1;
@@ -1682,6 +1682,7 @@
 		if (new->data.symlnk.name)
 		{
 			strcpy (new->data.symlnk.name, to);
+			new->stat.size = len - 1;
 		}
 		else
 		{