X-Git-Url: http://git.linux-vserver.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=util-vserver%2Fsrc%2Fshowattr.c;h=c5a04dda0acb9880035c723a335d9099f911608a;hb=a917f24ef7b003dcef54a3db2644cf9cb4bc2db2;hp=daaf7a66589d58cb7c5002c50b464f10c52d902b;hpb=9bac3099d94faabc10f8916475bcfd38eb7acc49;p=util-vserver.git diff --git a/util-vserver/src/showattr.c b/util-vserver/src/showattr.c index daaf7a6..c5a04dd 100644 --- a/util-vserver/src/showattr.c +++ b/util-vserver/src/showattr.c @@ -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; + } + + write(1, buf, 8); + write(1, display_name, strlen(display_name)); + write(1, "\n", 1); + + return res; +}