]> git.sur5r.net Git - u-boot/blobdiff - fs/ubifs/ubifs.h
ubifs: remove useless code
[u-boot] / fs / ubifs / ubifs.h
index acc6a404dde477a0b161aa88ad3c89a74ca7db73..512fdaa1444d1155bcf260be3156c19ce65578d1 100644 (file)
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
 /*
  * This file is part of UBIFS.
  *
@@ -6,8 +7,6 @@
  * (C) Copyright 2008-2009
  * Stefan Roese, DENX Software Engineering, sr@denx.de.
  *
- * SPDX-License-Identifier:    GPL-2.0+
- *
  * Authors: Artem Bityutskiy (Битюцкий Артём)
  *          Adrian Hunter
  */
@@ -15,7 +14,6 @@
 #ifndef __UBIFS_H__
 #define __UBIFS_H__
 
-#define __UBOOT__
 #ifndef __UBOOT__
 #include <asm/div64.h>
 #include <linux/statfs.h>
 #include <linux/mtd/ubi.h>
 #include <linux/pagemap.h>
 #include <linux/backing-dev.h>
+#include <linux/security.h>
 #include "ubifs-media.h"
 #else
+#include <asm/atomic.h>
+#include <asm-generic/atomic-long.h>
 #include <ubi_uboot.h>
+#include <ubifs_uboot.h>
 
 #include <linux/ctype.h>
 #include <linux/time.h>
@@ -64,16 +66,6 @@ struct page {
 
 void iput(struct inode *inode);
 
-/*
- * The atomic operations are used for budgeting etc which is not
- * needed for the read-only U-Boot implementation:
- */
-#define atomic_long_inc(a)
-#define atomic_long_dec(a)
-#define        atomic_long_sub(a, b)
-
-typedef unsigned long atomic_long_t;
-
 /* linux/include/time.h */
 #define NSEC_PER_SEC   1000000000L
 #define get_seconds()  0
@@ -324,8 +316,8 @@ struct super_block {
        struct backing_dev_info *s_bdi;
 #endif
        struct mtd_info         *s_mtd;
-       struct hlist_node       s_instances;
 #ifndef __UBOOT__
+       struct hlist_node       s_instances;
        struct quota_info       s_dquot;        /* Diskquota specific options */
 #endif
 
@@ -477,10 +469,6 @@ struct file {
 #define MAX_LFS_FILESIZE       0x7fffffffffffffffUL
 #endif
 
-#define INT_MAX                ((int)(~0U>>1))
-#define INT_MIN                (-INT_MAX - 1)
-#define LLONG_MAX      ((long long)(~0ULL>>1))
-
 /*
  * These are the fs-independent mount-flags: up to 32 flags are supported
  */
@@ -622,31 +610,54 @@ static inline ino_t parent_ino(struct dentry *dentry)
 /* misc.h */
 #define mutex_lock_nested(...)
 #define mutex_unlock_nested(...)
-#define mutex_is_locked(...)   0
+#define mutex_is_locked(...)   1
 #endif
 
 /* Version of this UBIFS implementation */
 #define UBIFS_VERSION 1
 
 /* Normal UBIFS messages */
-#define ubifs_msg(fmt, ...) pr_notice("UBIFS: " fmt "\n", ##__VA_ARGS__)
+#ifdef CONFIG_UBIFS_SILENCE_MSG
+#define ubifs_msg(c, fmt, ...)
+#else
+#define ubifs_msg(c, fmt, ...)                                      \
+       pr_notice("UBIFS (ubi%d:%d): " fmt "\n",                    \
+                 (c)->vi.ubi_num, (c)->vi.vol_id, ##__VA_ARGS__)
+#endif
 /* UBIFS error messages */
 #ifndef __UBOOT__
-#define ubifs_err(fmt, ...)                                         \
-       pr_err("UBIFS error (pid %d): %s: " fmt "\n", current->pid, \
+#define ubifs_err(c, fmt, ...)                                      \
+       pr_err("UBIFS error (ubi%d:%d pid %d): %s: " fmt "\n",      \
+              (c)->vi.ubi_num, (c)->vi.vol_id, current->pid,       \
               __func__, ##__VA_ARGS__)
 /* UBIFS warning messages */
-#define ubifs_warn(fmt, ...)                                        \
-       pr_warn("UBIFS warning (pid %d): %s: " fmt "\n",            \
-               current->pid, __func__, ##__VA_ARGS__)
+#define ubifs_warn(c, fmt, ...)                                     \
+       pr_warn("UBIFS warning (ubi%d:%d pid %d): %s: " fmt "\n",   \
+               (c)->vi.ubi_num, (c)->vi.vol_id, current->pid,      \
+               __func__, ##__VA_ARGS__)
 #else
-#define ubifs_err(fmt, ...)                                         \
-       pr_err("UBIFS error: %s: " fmt "\n", __func__, ##__VA_ARGS__)
+#define ubifs_err(c, fmt, ...)                                      \
+       pr_err("UBIFS error (ubi%d:%d pid %d): %s: " fmt "\n",      \
+              (c)->vi.ubi_num, (c)->vi.vol_id, 0,                  \
+              __func__, ##__VA_ARGS__)
 /* UBIFS warning messages */
-#define ubifs_warn(fmt, ...)                                        \
-       pr_warn("UBIFS warning: %s: " fmt "\n", __func__, ##__VA_ARGS__)
+#define ubifs_warn(c, fmt, ...)                                     \
+       pr_warn("UBIFS warning (ubi%d:%d pid %d): %s: " fmt "\n",   \
+               (c)->vi.ubi_num, (c)->vi.vol_id, 0,                 \
+               __func__, ##__VA_ARGS__)
+
 #endif
 
+/*
+ * A variant of 'ubifs_err()' which takes the UBIFS file-sytem description
+ * object as an argument.
+ */
+#define ubifs_errc(c, fmt, ...)                                     \
+       do {                                                        \
+               if (!(c)->probing)                                  \
+                       ubifs_err(c, fmt, ##__VA_ARGS__);           \
+       } while (0)
+
 /* UBIFS file system VFS magic number */
 #define UBIFS_SUPER_MAGIC 0x24051905
 
@@ -743,7 +754,7 @@ static inline ino_t parent_ino(struct dentry *dentry)
 #define WORST_COMPR_FACTOR 2
 
 /*
- * How much memory is needed for a buffer where we comress a data node.
+ * How much memory is needed for a buffer where we compress a data node.
  */
 #define COMPRESSED_DATA_NODE_BUF_SZ \
        (UBIFS_DATA_NODE_SZ + UBIFS_BLOCK_SIZE * WORST_COMPR_FACTOR)
@@ -900,7 +911,6 @@ struct ubifs_scan_node {
  * @nodes_cnt: number of nodes scanned
  * @nodes: list of struct ubifs_scan_node
  * @endpt: end point (and therefore the start of empty space)
- * @ecc: read returned -EBADMSG
  * @buf: buffer containing entire LEB scanned
  */
 struct ubifs_scan_leb {
@@ -908,7 +918,6 @@ struct ubifs_scan_leb {
        int nodes_cnt;
        struct list_head nodes;
        int endpt;
-       int ecc;
        void *buf;
 };
 
@@ -1251,7 +1260,7 @@ typedef int (*ubifs_lpt_scan_callback)(struct ubifs_info *c,
  * @lock: serializes @buf, @lnum, @offs, @avail, @used, @next_ino and @inodes
  *        fields
  * @softlimit: soft write-buffer timeout interval
- * @delta: hard and soft timeouts delta (the timer expire inteval is @softlimit
+ * @delta: hard and soft timeouts delta (the timer expire interval is @softlimit
  *         and @softlimit + @delta)
  * @timer: write-buffer timer
  * @no_timer: non-zero if this write-buffer does not have a timer
@@ -1521,9 +1530,9 @@ struct ubifs_orphan {
 /**
  * struct ubifs_mount_opts - UBIFS-specific mount options information.
  * @unmount_mode: selected unmount mode (%0 default, %1 normal, %2 fast)
- * @bulk_read: enable/disable bulk-reads (%0 default, %1 disabe, %2 enable)
+ * @bulk_read: enable/disable bulk-reads (%0 default, %1 disable, %2 enable)
  * @chk_data_crc: enable/disable CRC data checking when reading data nodes
- *                (%0 default, %1 disabe, %2 enable)
+ *                (%0 default, %1 disable, %2 enable)
  * @override_compr: override default compressor (%0 - do not override and use
  *                  superblock compressor, %1 - override and use compressor
  *                  specified in @compr_type)
@@ -1553,9 +1562,9 @@ struct ubifs_mount_opts {
  *           optimization)
  * @nospace_rp: the same as @nospace, but additionally means that even reserved
  *              pool is full
- * @page_budget: budget for a page (constant, nenver changed after mount)
- * @inode_budget: budget for an inode (constant, nenver changed after mount)
- * @dent_budget: budget for a directory entry (constant, nenver changed after
+ * @page_budget: budget for a page (constant, never changed after mount)
+ * @inode_budget: budget for an inode (constant, never changed after mount)
+ * @dent_budget: budget for a directory entry (constant, never changed after
  *               mount)
  */
 struct ubifs_budg_info {
@@ -1641,7 +1650,6 @@ struct ubifs_debug_info;
  *
  * @mst_node: master node
  * @mst_offs: offset of valid master node
- * @mst_mutex: protects the master node area, @mst_node, and @mst_offs
  *
  * @max_bu_buf_len: maximum bulk-read buffer length
  * @bu_mutex: protects the pre-allocated bulk-read buffer and @c->bu
@@ -1808,6 +1816,7 @@ struct ubifs_debug_info;
  * @need_recovery: %1 if the file-system needs recovery
  * @replaying: %1 during journal replay
  * @mounting: %1 while mounting
+ * @probing: %1 while attempting to mount if MS_SILENT mount flag is set
  * @remounting_rw: %1 while re-mounting from R/O mode to R/W mode
  * @replay_list: temporary list used during journal replay
  * @replay_buds: list of buds to replay
@@ -1883,7 +1892,6 @@ struct ubifs_info {
 
        struct ubifs_mst_node *mst_node;
        int mst_offs;
-       struct mutex mst_mutex;
 
        int max_bu_buf_len;
        struct mutex bu_mutex;
@@ -2042,6 +2050,7 @@ struct ubifs_info {
        unsigned int replaying:1;
        unsigned int mounting:1;
        unsigned int remounting_rw:1;
+       unsigned int probing:1;
        struct list_head replay_list;
        struct list_head replay_buds;
        unsigned long long cs_sqnum;
@@ -2061,6 +2070,7 @@ extern spinlock_t ubifs_infos_lock;
 extern atomic_long_t ubifs_clean_zn_cnt;
 extern struct kmem_cache *ubifs_inode_slab;
 extern const struct super_operations ubifs_super_operations;
+extern const struct xattr_handler *ubifs_xattr_handlers[];
 extern const struct address_space_operations ubifs_file_address_operations;
 extern const struct file_operations ubifs_file_operations;
 extern const struct inode_operations ubifs_file_inode_operations;
@@ -2352,6 +2362,8 @@ ssize_t ubifs_getxattr(struct dentry *dentry, const char *name, void *buf,
                       size_t size);
 ssize_t ubifs_listxattr(struct dentry *dentry, char *buffer, size_t size);
 int ubifs_removexattr(struct dentry *dentry, const char *name);
+int ubifs_init_security(struct inode *dentry, struct inode *inode,
+                       const struct qstr *qstr);
 
 /* super.c */
 struct inode *ubifs_iget(struct super_block *sb, unsigned long inum);
@@ -2382,21 +2394,16 @@ long ubifs_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
 /* compressor.c */
 int __init ubifs_compressors_init(void);
 void ubifs_compressors_exit(void);
-void ubifs_compress(const void *in_buf, int in_len, void *out_buf, int *out_len,
-                   int *compr_type);
-int ubifs_decompress(const void *buf, int len, void *out, int *out_len,
-                    int compr_type);
+void ubifs_compress(const struct ubifs_info *c, const void *in_buf, int in_len,
+                   void *out_buf, int *out_len, int *compr_type);
+int ubifs_decompress(const struct ubifs_info *c, const void *buf, int len,
+                    void *out, int *out_len, int compr_type);
 
 #include "debug.h"
 #include "misc.h"
 #include "key.h"
 
 #ifdef __UBOOT__
-/* these are used in cmd_ubifs.c */
-int ubifs_init(void);
-int uboot_ubifs_mount(char *vol_name);
 void ubifs_umount(struct ubifs_info *c);
-int ubifs_ls(char *dir_name);
-int ubifs_load(char *filename, u32 addr, u32 size);
 #endif
 #endif /* !__UBIFS_H__ */