File: stat.c

package info (click to toggle)
reiser4progs 1.0.7-6
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 5,352 kB
  • ctags: 3,699
  • sloc: ansic: 33,483; sh: 8,489; makefile: 1,001
file content (40 lines) | stat: -rw-r--r-- 917 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/* Copyright (C) 2001-2005 by Hans Reiser, licensing governed by
   reiser4progs/COPYING.
   
   stat.c -- a demo program that works similar to the standard stat utility. */

#include "busy.h"

errno_t stat_cmd(busy_ctx_t *ctx) {
	reiser4_object_t *object;
	aal_stream_t stream;

	aal_assert("vpf-1710", ctx != NULL);

	if (!ctx->in.fs) {
		aal_error("Fs is not openned. Wrong PAth is specified: %s.",
			  ctx->in.path);
		return -EINVAL;
	}
	
	if (ctx->in.path[0] == 0) {
		aal_error("NULL path is given.");
		return -EINVAL;
	}
	
	if (!(object = reiser4_semantic_open(ctx->in.fs->tree, 
					     ctx->in.path, NULL, 1)))
	{
		aal_error("Can't open file %s.", ctx->in.path);
		return -EIO;
	}

	aal_stream_init(&stream, NULL, &memory_stream);
	objcall(&object->info.start, debug->print, &stream, 0);
	printf("%s\n", (char *)stream.entity);
	aal_stream_fini(&stream);
	
	reiser4_object_close(object);
	return 0;
}