Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1HdsXP-0001dN-Ia for mharc-grub-devel@gnu.org; Tue, 17 Apr 2007 14:36:23 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HdsXN-0001d8-0O for grub-devel@gnu.org; Tue, 17 Apr 2007 14:36:21 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HdsXL-0001cv-SG for grub-devel@gnu.org; Tue, 17 Apr 2007 14:36:20 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HdsXL-0001cs-N1 for grub-devel@gnu.org; Tue, 17 Apr 2007 14:36:19 -0400 Received: from mx09.ms.so-net.ne.jp ([202.238.82.9]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1HdsSa-0003sL-Ct for grub-devel@gnu.org; Tue, 17 Apr 2007 14:31:24 -0400 Received: from temjin (pddf8b9.gifunt01.ap.so-net.ne.jp [218.221.248.185]) by mx09.ms.so-net.ne.jp with ESMTP id l3HIVFi7029960 for ; Wed, 18 Apr 2007 03:31:19 +0900 (JST) From: "Hitoshi Ozeki" To: "'The development of GRUB 2'" Date: Wed, 18 Apr 2007 03:31:32 +0900 Message-ID: <000001c7811e$9f928490$030010ac@ozeki> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.6822 Importance: Normal Thread-Index: AceAIaL7MEiWUYpAQv+bjSOx/aZPaQAS94+A In-Reply-To: <87y7ksqza5.fsf@gnu.org> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3028 X-detected-kernel: Solaris 9.1 Subject: RE: GRUB 1.95 cannot read the ufs filesystem X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Apr 2007 18:36:21 -0000 Hello, all. Johan Rydberg wrote: > GRUB 1.95 cannot read the ufs filesystem. > This patch fixes this problem, and make it a bit better. Could you maybe point out the problem for us? =20 Personally, I think the use of pointers make the code more complex. At first, When we use the 'strcmp' for the purpose of comparision = C-strings, It requires to terminate with the NIL sentry('\0'). ----begin------------------------------- grub_ufs_find_file (struct grub_ufs_data *data, const char *path) { char fpath[grub_strlen (path)]; <-- not enough. char *name =3D fpath; char *next; unsigned int pos =3D 0; int dirino; =20 grub_strncpy (fpath, path, grub_strlen (path)); <--without NIL. ----end--------------------------------- From the manpage of 'strncpy(3)': The strcpy() function copies the string pointed to by src (including the terminating `\0' character) to the array pointed to by dest. The strings may not overlap, and the destination string dest must be large enough to receive the copy. The strncpy() function is similar, except that not more than n = bytes of src are copied. Thus, if there is no null byte among the first n bytes of src, the result will not be null-terminated. At second, However we have the filepath in 'const char* path', The original code copies the filepath. It wastes the processor time. If you think the use of pointers makes complex, I recommend to use array and index. In addition, ufs filesystem has no label. ----begin------------------------------- static struct grub_fs grub_ufs_fs =3D { .name =3D "ufs", .dir =3D grub_ufs_dir, .open =3D grub_ufs_open, .read =3D grub_ufs_read, .close =3D grub_ufs_close, .label =3D grub_ufs_label, .next =3D 0 }; ----end--------------------------------- The '.label' should set to 0. On the original code, The 'label' function returns the invalid pointer, so the 'ls -l' command gets wrong. --=20 Regard, Hitoshi Ozeki