wok-current diff busybox/stuff/busybox-1.22-fatattr.u @ rev 16895
qt4-phonon: del bdep
author | Xander Ziiryanoff <psychomaniak@xakep.ru> |
---|---|
date | Mon Jul 14 15:10:46 2014 +0300 (2014-07-14) |
parents | |
children | 66ded06f27d9 |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/busybox/stuff/busybox-1.22-fatattr.u Mon Jul 14 15:10:46 2014 +0300 1.3 @@ -0,0 +1,152 @@ 1.4 +--- busybox-1.22.0/include/applets.src.h 1.5 ++++ busybox-1.22.0/include/applets.src.h 1.6 +@@ -138,6 +138,7 @@ 1.7 + IF_EXPR(APPLET(expr, BB_DIR_USR_BIN, BB_SUID_DROP)) 1.8 + IF_FAKEIDENTD(APPLET(fakeidentd, BB_DIR_USR_SBIN, BB_SUID_DROP)) 1.9 + IF_FALSE(APPLET_NOFORK(false, false, BB_DIR_BIN, BB_SUID_DROP, false)) 1.10 ++IF_FATATTR(APPLET(fatattr, BB_DIR_BIN, BB_SUID_DROP)) 1.11 + IF_FBSET(APPLET(fbset, BB_DIR_USR_SBIN, BB_SUID_DROP)) 1.12 + IF_FBSPLASH(APPLET(fbsplash, BB_DIR_SBIN, BB_SUID_DROP)) 1.13 + IF_FDFLUSH(APPLET_ODDNAME(fdflush, freeramdisk, BB_DIR_BIN, BB_SUID_DROP, fdflush)) 1.14 +--- busybox-1.22.0/e2fsprogs/Config.src 1.15 ++++ busybox-1.22.0/e2fsprogs/Config.src 1.16 +@@ -37,6 +37,13 @@ 1.17 + help 1.18 + lsattr lists the file attributes on a second extended file system. 1.19 + 1.20 ++config FATATTR 1.21 ++ bool "fatattr" 1.22 ++ default y 1.23 ++ select PLATFORM_LINUX 1.24 ++ help 1.25 ++ fatattr lists or changes the file attributes on a fat file system. 1.26 ++ 1.27 + ### config MKE2FS 1.28 + ### bool "mke2fs" 1.29 + ### default y 1.30 +--- busybox-1.22.0/e2fsprogs/Kbuild.src 1.31 ++++ busybox-1.22.0/e2fsprogs/Kbuild.src 1.32 +@@ -11,5 +11,7 @@ 1.33 + lib-$(CONFIG_CHATTR) += chattr.o e2fs_lib.o 1.34 + lib-$(CONFIG_LSATTR) += lsattr.o e2fs_lib.o 1.35 + 1.36 ++lib-$(CONFIG_FATATTR) += fatattr.o 1.37 ++ 1.38 + lib-$(CONFIG_FSCK) += fsck.o 1.39 + lib-$(CONFIG_TUNE2FS) += tune2fs.o 1.40 +--- busybox-1.22.0/e2fsprogs/fatattr.c 1.41 ++++ busybox-1.22.0/e2fsprogs/fatattr.c 1.42 +@@ -0,0 +1,113 @@ 1.43 ++/* vi: set sw=4 ts=4: */ 1.44 ++/* 1.45 ++ * fatattr.c - Display or change file attributes on a fat file system 1.46 ++ * 1.47 ++ * Copyright 2005 H. Peter Anvin 1.48 ++ * Busybox'ed (2014) by Pascal Bellard <pascal.bellard@ads-lu.com> 1.49 ++ * 1.50 ++ * This file can be redistributed under the terms of the GNU General 1.51 ++ * Public License 1.52 ++ */ 1.53 ++ 1.54 ++//usage:#define fatattr_trivial_usage 1.55 ++//usage: "[-+rhsvda] [FILE]..." 1.56 ++//usage:#define fatattr_full_usage "\n\n" 1.57 ++//usage: "Change file attributes on a fat fs\n" 1.58 ++//usage: "\nModifiers:" 1.59 ++//usage: "\n - Clear attributes" 1.60 ++//usage: "\n + Set attributes" 1.61 ++//usage: "\nAttributes:" 1.62 ++//usage: "\n r Read only" 1.63 ++//usage: "\n h Hidden" 1.64 ++//usage: "\n s System" 1.65 ++//usage: "\n v Volume label" 1.66 ++//usage: "\n d Directory" 1.67 ++//usage: "\n a Archive" 1.68 ++ 1.69 ++#include "libbb.h" 1.70 ++/* linux/msdos_fs.h says: */ 1.71 ++#ifndef FAT_IOCTL_GET_ATTRIBUTES 1.72 ++# define FAT_IOCTL_GET_ATTRIBUTES _IOR('r', 0x10, __u32) 1.73 ++#endif 1.74 ++#ifndef FAT_IOCTL_SET_ATTRIBUTES 1.75 ++# define FAT_IOCTL_SET_ATTRIBUTES _IOW('r', 0x11, __u32) 1.76 ++#endif 1.77 ++ 1.78 ++#define OPT_ADD 1 1.79 ++#define OPT_REM 2 1.80 ++ 1.81 ++struct globals { 1.82 ++ unsigned long af; 1.83 ++ unsigned long rf; 1.84 ++}; 1.85 ++ 1.86 ++/* Currently supports only the FAT flags, not the NTFS ones */ 1.87 ++const char bit_to_char[] = "rhsvda67 "; 1.88 ++ 1.89 ++static inline unsigned long get_flag(char c) 1.90 ++{ 1.91 ++ const char *fp = strchr(bit_to_char, c); 1.92 ++ if (fp) 1.93 ++ return 1 << (fp - bit_to_char); 1.94 ++ bb_error_msg_and_die("invalid character '%c' ", c); 1.95 ++} 1.96 ++ 1.97 ++static inline int decode_arg(const char *arg, struct globals *gp) 1.98 ++{ 1.99 ++ unsigned long *fl; 1.100 ++ char opt = *arg++; 1.101 ++ 1.102 ++ fl = &gp->af; 1.103 ++ if (opt == '-') { 1.104 ++ fl = &gp->rf; 1.105 ++ } else if (opt != '+') { 1.106 ++ return 0; 1.107 ++ } 1.108 ++ 1.109 ++ while (*arg) 1.110 ++ *fl |= get_flag(*arg++); 1.111 ++ 1.112 ++ return 1; 1.113 ++} 1.114 ++ 1.115 ++int fatattr_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 1.116 ++int fatattr_main(int argc UNUSED_PARAM, char **argv) 1.117 ++{ 1.118 ++ struct globals g; 1.119 ++ char *arg; 1.120 ++ 1.121 ++ g.rf = g.af = 0; 1.122 ++ 1.123 ++ /* parse the args */ 1.124 ++ while ((arg = *++argv)) { 1.125 ++ if (!decode_arg(arg, &g)) 1.126 ++ break; 1.127 ++ } 1.128 ++ 1.129 ++ /* run sanity checks on all the arguments given us */ 1.130 ++ if (!*argv) 1.131 ++ bb_show_usage(); 1.132 ++ 1.133 ++ /* now proceed all the files passed to us */ 1.134 ++ do { 1.135 ++ int fd, i; 1.136 ++ uint32_t attr; 1.137 ++ 1.138 ++ fd = xopen(*argv, O_RDONLY); 1.139 ++ xioctl(fd, FAT_IOCTL_GET_ATTRIBUTES, &attr); 1.140 ++ attr |= g.af; 1.141 ++ attr &= ~g.rf; 1.142 ++ if (g.af || g.rf) 1.143 ++ xioctl(fd, FAT_IOCTL_SET_ATTRIBUTES, &attr); 1.144 ++ else { 1.145 ++ for ( i = 0 ; bit_to_char[i] ; i++ ) { 1.146 ++ bb_putchar( (attr & 1) ? bit_to_char[i] : ' ' ); 1.147 ++ attr >>= 1; 1.148 ++ } 1.149 ++ puts(*argv); 1.150 ++ } 1.151 ++ close(fd); 1.152 ++ } while (*++argv); 1.153 ++ 1.154 ++ return EXIT_SUCCESS; 1.155 ++}