hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/fs/ubifs/misc.h
....@@ -1,20 +1,8 @@
1
+/* SPDX-License-Identifier: GPL-2.0-only */
12 /*
23 * This file is part of UBIFS.
34 *
45 * Copyright (C) 2006-2008 Nokia Corporation
5
- *
6
- * This program is free software; you can redistribute it and/or modify it
7
- * under the terms of the GNU General Public License version 2 as published by
8
- * the Free Software Foundation.
9
- *
10
- * This program is distributed in the hope that it will be useful, but WITHOUT
11
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13
- * more details.
14
- *
15
- * You should have received a copy of the GNU General Public License along with
16
- * this program; if not, write to the Free Software Foundation, Inc., 51
17
- * Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
186 *
197 * Authors: Artem Bityutskiy (Битюцкий Артём)
208 * Adrian Hunter
....@@ -133,7 +121,7 @@
133121 * ubifs_wbuf_sync - synchronize write-buffer.
134122 * @wbuf: write-buffer to synchronize
135123 *
136
- * This is the same as as 'ubifs_wbuf_sync_nolock()' but it does not assume
124
+ * This is the same as 'ubifs_wbuf_sync_nolock()' but it does not assume
137125 * that the write-buffer is already locked.
138126 */
139127 static inline int ubifs_wbuf_sync(struct ubifs_wbuf *wbuf)
....@@ -197,7 +185,8 @@
197185 */
198186 static inline int ubifs_idx_node_sz(const struct ubifs_info *c, int child_cnt)
199187 {
200
- return UBIFS_IDX_NODE_SZ + (UBIFS_BRANCH_SZ + c->key_len) * child_cnt;
188
+ return UBIFS_IDX_NODE_SZ + (UBIFS_BRANCH_SZ + c->key_len + c->hash_len)
189
+ * child_cnt;
201190 }
202191
203192 /**
....@@ -212,7 +201,7 @@
212201 int bnum)
213202 {
214203 return (struct ubifs_branch *)((void *)idx->branches +
215
- (UBIFS_BRANCH_SZ + c->key_len) * bnum);
204
+ (UBIFS_BRANCH_SZ + c->key_len + c->hash_len) * bnum);
216205 }
217206
218207 /**
....@@ -287,6 +276,14 @@
287276 return lnum;
288277 }
289278
279
+static inline int ubifs_xattr_max_cnt(struct ubifs_info *c)
280
+{
281
+ int max_xattrs = (c->leb_size / 2) / UBIFS_INO_NODE_SZ;
282
+
283
+ ubifs_assert(c, max_xattrs < c->max_orphans);
284
+ return max_xattrs;
285
+}
286
+
290287 const char *ubifs_assert_action_name(struct ubifs_info *c);
291288
292289 #endif /* __UBIFS_MISC_H__ */