From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oi0-f49.google.com ([209.85.218.49]) by ur; Sun Aug 23 20:01:21 EDT 2015 Received: by oiew67 with SMTP id w67so70740600oie.2 for <9front@9front.org>; Sun, 23 Aug 2015 17:01:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=IRiX9X8d3QurYT+eZHfWpIc0AOnjRLtd085quR3mJ38=; b=TP+SEn6xpArbvMFhoLrzuy9bhQD1mhCgAwPXSKoo4h1JlN6k8hzGRpT5/y+eF+7w1t yeKTTQsq/EMkcjcf+jxQR1T9aM1T/yVGu4go6Mp0BSGJShAT7gI5xtV0rf8iDMEjekLa AJjuqL1Frue5rqnVtLv2xGuSQsBofi9+rE0WSbt66G6ExGW7osMptHoTt+Naq8mI5Ffz d9Fz3g4AqGm2i0K8mWeoOguN/zxv6/kkOn0KSoLQ0+NJmm1w0llD6og0QCuDJHGhPvYv dg1A7g9lUokIxlKn9mnB0sLY9izsG35jGZVACK38c1T0S77Tk0jfhzCXCFXffkyYHlMs wr4A== MIME-Version: 1.0 X-Received: by 10.202.72.21 with SMTP id v21mr16495820oia.82.1440374478397; Sun, 23 Aug 2015 17:01:18 -0700 (PDT) Received: by 10.202.228.198 with HTTP; Sun, 23 Aug 2015 17:01:18 -0700 (PDT) Received: by 10.202.228.198 with HTTP; Sun, 23 Aug 2015 17:01:18 -0700 (PDT) In-Reply-To: <8a7a4824b69f9c20955f.1440373756@delta> References: <8a7a4824b69f9c20955f.1440373756@delta> Date: Sun, 23 Aug 2015 21:01:18 -0300 Message-ID: List-ID: <9front.9front.org> X-Glyph: ➈ X-Bullshit: advanced event rails-oriented database Subject: Re: [9front] [PATCH 6 of 8] mv: use iounit for reads From: =?UTF-8?Q?Iruat=C3=A3_Souza?= To: 9front@9front.org Content-Type: multipart/alternative; boundary=001a113dae5420e7a9051e035139 --001a113dae5420e7a9051e035139 Content-Type: text/plain; charset=UTF-8 Em 23/08/2015 20:52, "mischief" escreveu: > > # HG changeset patch > # User mischief > # Date 1440366687 25200 > # Sun Aug 23 14:51:27 2015 -0700 > # Node ID 8a7a4824b69f9c20955f3b96a01c142801f5af1f > # Parent b6676a7790ca84598ccc4e66856339710ab9b544 > mv: use iounit for reads > > diff -r b6676a7790ca -r 8a7a4824b69f sys/src/cmd/mv.c > --- a/sys/src/cmd/mv.c Sun Aug 23 14:51:27 2015 -0700 > +++ b/sys/src/cmd/mv.c Sun Aug 23 14:51:27 2015 -0700 > @@ -167,9 +167,14 @@ > int > copy1(int fdf, int fdt, char *from, char *to) > { > - char buf[8192]; > + int buflen; > + char *buf; > long n, n1; > > + buflen = iounit(fdf); > + if(buflen <= 0) > + buflen = IOUNIT; > + > while ((n = read(fdf, buf, sizeof buf)) > 0) { > n1 = write(fdt, buf, n); > if(n1 != n){ You don't seem to reserve memory for buf here. --001a113dae5420e7a9051e035139 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable


Em 23/08/2015 20:52, "mischief" <mischief@offblast.org> escreveu:
>
> # HG changeset patch
> # User mischief <mischief@= offblast.org>
> # Date 1440366687 25200
> #=C2=A0 =C2=A0 =C2=A0 Sun Aug 23 14:51:27 2015 -0700
> # Node ID 8a7a4824b69f9c20955f3b96a01c142801f5af1f
> # Parent=C2=A0 b6676a7790ca84598ccc4e66856339710ab9b544
> mv: use iounit for reads
>
> diff -r b6676a7790ca -r 8a7a4824b69f sys/src/cmd/mv.c
> --- a/sys/src/cmd/mv.c=C2=A0 Sun Aug 23 14:51:27 2015 -0700
> +++ b/sys/src/cmd/mv.c=C2=A0 Sun Aug 23 14:51:27 2015 -0700
> @@ -167,9 +167,14 @@
> =C2=A0int
> =C2=A0copy1(int fdf, int fdt, char *from, char *to)
> =C2=A0{
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0char buf[8192];
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0int buflen;
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0char *buf;
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 long n, n1;
>
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0buflen =3D iounit(fdf);
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0if(buflen <=3D 0)
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0buflen =3D IOU= NIT;
> +
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 while ((n =3D read(fdf, buf, sizeof buf)) = > 0) {
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 n1 =3D write(f= dt, buf, n);
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if(n1 !=3D n){=

You don't seem to reserve memory for buf here.

--001a113dae5420e7a9051e035139--