char* hostname_cleanup(char *s, bool lowercase);
bool machine_name_is_valid(const char *s) _pure_;
-bool image_name_is_valid(const char *s) _pure_;
char* strshorten(char *s, size_t l);
_r_; \
})
-struct _locale_struct_ {
- locale_t saved_locale;
- locale_t new_locale;
- bool quit;
-};
-
-static inline void _reset_locale_(struct _locale_struct_ *s) {
- PROTECT_ERRNO;
- if (s->saved_locale != (locale_t) 0)
- uselocale(s->saved_locale);
- if (s->new_locale != (locale_t) 0)
- freelocale(s->new_locale);
-}
-
-#define RUN_WITH_LOCALE(mask, loc) \
- for (_cleanup_(_reset_locale_) struct _locale_struct_ _saved_locale_ = { (locale_t) 0, (locale_t) 0, false }; \
- ({ \
- if (!_saved_locale_.quit) { \
- PROTECT_ERRNO; \
- _saved_locale_.new_locale = newlocale((mask), (loc), (locale_t) 0); \
- if (_saved_locale_.new_locale != (locale_t) 0) \
- _saved_locale_.saved_locale = uselocale(_saved_locale_.new_locale); \
- } \
- !_saved_locale_.quit; }) ; \
- _saved_locale_.quit = true)
-
bool id128_is_valid(const char *s) _pure_;
int split_pair(const char *s, const char *sep, char **l, char **r);
struct file_handle handle;
char padding[sizeof(struct file_handle) + MAX_HANDLE_SZ];
};
+#define FILE_HANDLE_INIT { .handle.handle_bytes = MAX_HANDLE_SZ }
int update_reboot_param_file(const char *param);
int same_fd(int a, int b);
-int chattr_fd(int fd, bool b, int mask);
-int chattr_path(const char *p, bool b, int mask);
+int chattr_fd(int fd, bool b, unsigned mask);
+int chattr_path(const char *p, bool b, unsigned mask);
+
+int read_attr_fd(int fd, unsigned *ret);
+int read_attr_path(const char *p, unsigned *ret);
+
+typedef struct LockFile {
+ char *path;
+ int fd;
+ int operation;
+} LockFile;
+
+int make_lock_file(const char *p, int operation, LockFile *ret);
+int make_lock_file_for(const char *p, int operation, LockFile *ret);
+void release_lock_file(LockFile *f);
+
+#define _cleanup_release_lock_file_ _cleanup_(release_lock_file)
+
+#define LOCK_FILE_INIT { .fd = -1, .path = NULL }
#define RLIMIT_MAKE_CONST(lim) ((struct rlimit) { lim, lim })