aboutsummaryrefslogtreecommitdiff
path: root/e2fsprogs/e2fs_lib.c
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2022-05-19 12:34:34 +0100
committerRon Yorston <rmy@pobox.com>2022-05-19 15:43:23 +0100
commit6ba1bb6d0245ecfca39224a44e2b3af3b2fef3d3 (patch)
treede44a134c030c9d1ebb342ab6ae066184cb90b58 /e2fsprogs/e2fs_lib.c
parent342f35e6c8ad13dad931af7858f64c8a7f63d08f (diff)
downloadbusybox-w32-6ba1bb6d0245ecfca39224a44e2b3af3b2fef3d3.tar.gz
busybox-w32-6ba1bb6d0245ecfca39224a44e2b3af3b2fef3d3.tar.bz2
busybox-w32-6ba1bb6d0245ecfca39224a44e2b3af3b2fef3d3.zip
chattr,lsattr: code shrink
Drop fgetsetflags() and move its functionality into chattr and lsattr. Raw file attributes are available from struct stat. In chattr don't compile code related to the unused (on Windows) OPT_SET option.
Diffstat (limited to 'e2fsprogs/e2fs_lib.c')
-rw-r--r--e2fsprogs/e2fs_lib.c30
1 files changed, 0 insertions, 30 deletions
diff --git a/e2fsprogs/e2fs_lib.c b/e2fsprogs/e2fs_lib.c
index 48c3b68b5..e40702e78 100644
--- a/e2fsprogs/e2fs_lib.c
+++ b/e2fsprogs/e2fs_lib.c
@@ -8,36 +8,6 @@
8#include "libbb.h" 8#include "libbb.h"
9#include "e2fs_lib.h" 9#include "e2fs_lib.h"
10 10
11#if ENABLE_PLATFORM_MINGW32
12/* Only certain attributes can be set using SetFileAttributes() */
13#define CHATTR_MASK (FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_HIDDEN | \
14 FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_ARCHIVE | \
15 FILE_ATTRIBUTE_TEMPORARY | FILE_ATTRIBUTE_NOT_CONTENT_INDEXED | \
16 FILE_ATTRIBUTE_OFFLINE)
17
18/* Get/set file attributes on a Windows file system */
19int fgetsetflags(const char *name, unsigned *get_flags, unsigned set_flags)
20{
21 struct stat buf;
22
23 if (stat(name, &buf) == 0 /* stat is ok */
24 && !S_ISREG(buf.st_mode) && !S_ISDIR(buf.st_mode)
25 ) {
26 errno = EOPNOTSUPP;
27 return -1;
28 }
29
30 if (get_flags) {
31 *get_flags = (unsigned long)buf.st_attr;
32 }
33 else if (!SetFileAttributes(name, set_flags & CHATTR_MASK)) {
34 errno = err_win_to_posix();
35 return -1;
36 }
37 return 0;
38}
39#endif
40
41#if !ENABLE_PLATFORM_MINGW32 11#if !ENABLE_PLATFORM_MINGW32
42/* Print file attributes on an ext2 file system */ 12/* Print file attributes on an ext2 file system */
43const uint32_t e2attr_flags_value[] ALIGN4 = { 13const uint32_t e2attr_flags_value[] ALIGN4 = {