cmogstored.git  about / heads / tags
alternative mogstored implementation for MogileFS
blob b3029a7ad39d0f2ca86615691f664f787d6975c9 835 bytes (raw)
$ git show gl-env:test/valid-path-1.c	# shows this blob on the CLI

 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
 
/*
 * Copyright (C) 2012-2016 all contributors <cmogstored-public@bogomips.org>
 * License: GPLv3 or later (see COPYING for details)
 */
#include "check.h"
#define VP(path) mog_valid_path((path), sizeof(path) - 1)
#define VPP(path) mog_valid_put_path((path), sizeof(path) - 1)

int main(void)
{
	assert(0 == VP("hello/.."));
	assert(1 == VP("hello/"));
	assert(1 == VP("hello.fid"));
	assert(0 == VP("../hello.fid"));
	assert(0 == VP("/../hello.fid"));
	assert(0 == VP("/hello.fid/.."));
	assert(0 == VP("/hello/../fid"));

	assert(VPP("/dev123/foo"));
	assert(VPP("/dev123/foo.fid"));
	assert(VPP("/dev123/0/1/2/3/4.fid"));
	assert(VPP("/dev16777215/0/000/000/0123456789.fid"));
	assert(!VPP("/dev123/foo/"));
	assert(!VPP("/dev123//"));
	assert(!VPP("///"));
	assert(!VPP("/wtf//"));
	assert(!VPP("/dev123/foo.fid/"));

	return 0;
}

git clone https://yhbt.net/cmogstored.git