X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=src%2Fshowattr.c;h=5260026a71a06114f6616fab0d2be8a7f8c39914;hb=a741f6faf2baae1e823d334012f6a09e6a1bda51;hp=c9d1055cf4899196bd1df5480e2d77b8e15bf76b;hpb=06e1018272502e1d15d6d8f32b80fa96420785b8;p=util-vserver.git diff --git a/src/showattr.c b/src/showattr.c index c9d1055..5260026 100644 --- a/src/showattr.c +++ b/src/showattr.c @@ -1,4 +1,4 @@ -// $Id: showattr.c,v 1.1.4.1 2003/11/18 22:31:10 ensc Exp $ +// $Id: showattr.c 1980 2005-03-24 12:44:17Z ensc $ // Copyright (C) 2003 Enrico Scholz // based on showattr.cc by Jacques Gelinas @@ -20,117 +20,120 @@ #ifdef HAVE_CONFIG_H # include #endif -#include "compat.h" -#include -#include -#include -#include -#include -#include +#include "fstool.h" +#include "util.h" -#include "ext2fs.h" +#include +#include +#include +#include +#include +#include +#include +#include -// Patch to help compile this utility on unpatched kernel source -#ifndef EXT2_IMMUTABLE_FILE_FL - #define EXT2_IMMUTABLE_FILE_FL 0x00000010 - #define EXT2_IMMUTABLE_LINK_FL 0x00008000 +struct option const +CMDLINE_OPTIONS[] = { + { "help", no_argument, 0, CMD_HELP }, + { "version", no_argument, 0, CMD_VERSION }, +#ifdef VC_ENABLE_API_LEGACY + { "legacy", no_argument, 0, CMD_LEGACY }, #endif + { 0,0,0,0 } +}; -/* - Get the extended attributes of a file -*/ -static int getext2flags (const char *fname, long *flags) +char const CMDLINE_OPTIONS_SHORT[] = "Radx"; + +void +showHelp(int fd, char const *cmd, int res) { - int ret = -1; - int fd = open (fname,O_RDONLY); - if (fd == -1){ - fprintf (stderr,"Can't open file %s (%s)\n",fname,strerror(errno)); - }else{ - *flags = 0; - ret = ioctl (fd,EXT2_IOC_GETFLAGS,flags); - close (fd); - if (ret == -1){ - fprintf (stderr,"Can't get ext2 flags on file %s (%s)\n" - ,fname,strerror(errno)); - } - } - return ret; + WRITE_MSG(fd, "Usage: "); + WRITE_STR(fd, cmd); + WRITE_MSG(fd, + " [-Radx] [--] *\n\n" + " Options:\n" + " -R ... recurse through directories\n" + " -a ... display files starting with '.' also\n" + " -d ... list directories like other files instead of listing\n" + " their content\n" + " -x ... do not cross filesystems\n\n" + "Please report bugs to " PACKAGE_BUGREPORT "\n"); + exit(res); } -/* - Set the extended attributes of a file -*/ -static int setext2flags (const char *fname, long flags) +void +showVersion() { - int ret = -1; - int fd = open (fname,O_RDONLY); - if (fd == -1){ - fprintf (stderr,"Can't open file %s (%s)\n",fname,strerror(errno)); - }else{ - ret = ioctl (fd,EXT2_IOC_SETFLAGS,&flags); - close (fd); - if (ret == -1){ - fprintf (stderr,"Can't set ext2 flags on file %s (%s)\n" - ,fname,strerror(errno)); - } - } - return ret; + WRITE_MSG(1, + "showattr " VERSION " -- shows vserver specific file attributes\n" + "This program is part of " PACKAGE_STRING "\n\n" + "Copyright (C) 2004 Enrico Scholz\n" + VERSION_COPYRIGHT_DISCLAIMER); + exit(0); } +void +fixupParams(struct Arguments UNUSED * args, int UNUSED argc) +{ +} -int main (int argc, char *argv[]) +static bool +getFlags(char const *name, uint32_t *flags, uint32_t *mask) { - int ret = -1; - if (argc <= 1){ - fprintf (stderr - ,"showattr file ...\n" - "\n" - "Presents extended file attribute.\n" - "\n" - "setattr --immutable --immulink file ...\n" - "\n" - "Sets the extended file attributes.\n" - "\n" - "These utilities exist as an interim until lsattr and\n" - "chattr are updated.\n" - ); - }else if (strstr(argv[0],"showattr")!=NULL){ - int i; - for (i=1; i>= 1; + flags >>= 1; + mask >>= 1; + } + } + else { + memcpy(buf, "ERR ", 7); + res = false; + } + + Vwrite(1, buf, 8); + Vwrite(1, display_name, strlen(display_name)); + Vwrite(1, "\n", 1); + + return res; +}