From owner-freebsd-current@FreeBSD.ORG Wed Oct 20 20:40:13 2010 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 382241065679 for ; Wed, 20 Oct 2010 20:40:13 +0000 (UTC) (envelope-from yanegomi@gmail.com) Received: from mail-wy0-f182.google.com (mail-wy0-f182.google.com [74.125.82.182]) by mx1.freebsd.org (Postfix) with ESMTP id BA7F28FC08 for ; Wed, 20 Oct 2010 20:40:12 +0000 (UTC) Received: by wyb38 with SMTP id 38so4310862wyb.13 for ; Wed, 20 Oct 2010 13:40:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:sender:received :in-reply-to:references:date:x-google-sender-auth:message-id:subject :from:to:cc:content-type:content-transfer-encoding; bh=IYAVlv+xe523OWKF1RQoVy7GstibqMQmHgS3+HnvM70=; b=rLt/jfml2IHOWlQpDnGclL0RcwMnjaGK3MS6pz7IlkTJbiezM8XWhXiJf47fmT6kz6 5MsEYgAoVG2ESc8ALgsVuLR/IPItKUxPPwy269f0BhBXlhTWBkRIUga/1q7fMyQfmhXT nHTpxY6VpgQgGNFmebm6OvdPWL2prQ7sTcjz8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; b=IydkrefzXfo8mFZTqMbRg1w3m9V8FtsEOlcG2zooP4VEsQsfsOjCCbMfml5MMKMfW3 5c3jdHzSCoNauO3w86WRjpwclXO5Z4fZmaZxRxpo2v3QpVNjQ/nHOH4lKzSlQEFD056z WtxH2o5z7EHI7zujZOu5oEHLp6jk//2JNmMc8= MIME-Version: 1.0 Received: by 10.216.93.9 with SMTP id k9mr8171840wef.89.1287607211566; Wed, 20 Oct 2010 13:40:11 -0700 (PDT) Sender: yanegomi@gmail.com Received: by 10.216.135.67 with HTTP; Wed, 20 Oct 2010 13:40:11 -0700 (PDT) In-Reply-To: References: <4CBCDD3A.9070404@delphij.net> <4CBD26B4.2020205@yandex.ru> <4CBDB17C.4040607@yandex.ru> <20101020194547.GA94244@server.vk2pj.dyndns.org> Date: Wed, 20 Oct 2010 13:40:11 -0700 X-Google-Sender-Auth: pU711c7O5GjulbSHaHCgSNoOlFc Message-ID: From: Garrett Cooper To: Peter Jeremy Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: KOT MATPOCKuH , FreeBSD Current Subject: Re: [zfs] Mounting from (...) failed with error 19 X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Oct 2010 20:40:13 -0000 On Wed, Oct 20, 2010 at 1:39 PM, Garrett Cooper wrote= : > On Wed, Oct 20, 2010 at 12:45 PM, Peter Jeremy wrot= e: >> On 2010-Oct-20 10:50:38 +0400, KOT MATPOCKuH wrote= : >>>> I fixed it with attached patch. >>>Omg... Why You are using strcmp, but not strncmp(fs, "zfs", strlen("zfs"= ))? >> >> Can you explain why you think it should be strncmp() please. > > I'd say that strcmp is perfectly fine because zfs is a 3 character (4 > if you count NUL) string. The comparison logic is dang near the same: > > /* > =A0* Compare strings. > =A0*/ > int > strcmp(const char *s1, const char *s2) > { > =A0 =A0 =A0 =A0while (*s1 =3D=3D *s2++) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (*s1++ =3D=3D '\0') > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0return (0); > =A0 =A0 =A0 =A0return (*(const unsigned char *)s1 - *(const unsigned char= *)(s2 - 1)); > } > > int > strncmp(const char *s1, const char *s2, size_t n) > { > > =A0 =A0 =A0 =A0if (n =3D=3D 0) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0return (0); > =A0 =A0 =A0 =A0do { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (*s1 !=3D *s2++) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0return (*(const unsigned c= har *)s1 - > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0*(const un= signed char *)(s2 - 1)); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (*s1++ =3D=3D '\0') > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0break; > =A0 =A0 =A0 =A0} while (--n !=3D 0); > =A0 =A0 =A0 =A0return (0); > } > > Weird how n =3D=3D 0 with strcmp returns 0... s/strcmp/strncmp/ -Garrett