ALT Linux Community general discussions
 help / color / mirror / Atom feed
From: "Dmitry V. Levin" <ldv@altlinux.org>
To: ALT Linux general discussion list <community@altlinux.ru>
Cc: ALT Linux Sisyphus mailing list <sisyphus@altlinux.ru>
Subject: [Comm] Re: [sisyphus] Re: du ошибается...
Date: Tue, 17 Dec 2002 11:15:14 +0300
Message-ID: <20021217081514.GB4059@basalt.office.altlinux.ru> (raw)
In-Reply-To: <3DFE91A2.4090005@mmk.ru>


[-- Attachment #1.1: Type: text/plain, Size: 483 bytes --]

On Tue, Dec 17, 2002 at 07:53:22AM +0500, Alexander Kirey wrote:
> >du означает disk usage, а вы хотите с помощью его посчитать суммарный
> >размер файлов? Он вам и показывает disk usage.
> >
> Да-с, и как это я... Но разница почти в 100 мегабайт...

Вот вам пример в числах:

1. Скомпилируйте lseek.c (attached),
2. Запустите
   $ ./lseek 0x400000000 ~/tmp/empty
3. Сравните вывод от
   $ ls -lh ~/tmp/empty
   и
   $ du -h ~/tmp/empty

P.S. Этот предмет - для community@.


--
ldv

[-- Attachment #1.2: lseek.c --]
[-- Type: text/plain, Size: 655 bytes --]

#include <errno.h>
#include <error.h>
#include <fcntl.h>
#include <stdlib.h>
#include <unistd.h>

int main (int ac, char *const *av)
{
	const char *fname;
	int fd;
	off_t offset;

	if (ac != 3)
		error (1, 0, "usage: offset fname");

	offset = strtoull (av[1], 0, 0);
	fname = av[2];

	fd = open (fname, O_CREAT | O_EXCL | O_WRONLY, 0600);
	if (fd < 0)
		error (1, errno, "open: %s", fname);

	if (lseek (fd, offset - 1, SEEK_SET) == (off_t)-1)
		error (1, errno, "lseek: %#llx", (unsigned long long) offset);

	if (write (fd, "", 1) < 0)
		error (1, errno, "write: %s", fname);

	if (close (fd) < 0)
		error (1, errno, "close: %s", fname);

	return 0;
}

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

       reply	other threads:[~2002-12-17  8:15 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-12-17  8:15         ` Dmitry V. Levin [this message]
2002-12-17 13:49           ` [Comm] " Alexey Tourbin
2002-12-17 18:11             ` [Comm] " ASA
2002-12-17 20:01               ` Vitaly Lipatov
2002-12-17 20:12                 ` Michael Shigorin
2002-12-18 11:27             ` Alexander Kirey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20021217081514.GB4059@basalt.office.altlinux.ru \
    --to=ldv@altlinux.org \
    --cc=community@altlinux.ru \
    --cc=sisyphus@altlinux.ru \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

ALT Linux Community general discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://lore.altlinux.org/community/0 community/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 community community/ http://lore.altlinux.org/community \
		mandrake-russian@linuxteam.iplabs.ru community@lists.altlinux.org community@lists.altlinux.ru community@lists.altlinux.com
	public-inbox-index community

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://lore.altlinux.org/org.altlinux.lists.community


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git