xref: /OK3568_Linux_fs/buildroot/package/mtp/0005-Don-t-delete-MTP-root-directory.patch (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1From fa1b466aec4004c014feedf8565c0f6a3bedf37e Mon Sep 17 00:00:00 2001
2From: Zain Wang <wzz@rock-chips.com>
3Date: Wed, 6 Nov 2019 16:21:47 +0800
4Subject: [PATCH] Don't delete MTP root directory
5
6---
7 server/UbuntuMtpDatabase.h | 3 +++
8 1 file changed, 3 insertions(+)
9
10diff --git a/server/UbuntuMtpDatabase.h b/server/UbuntuMtpDatabase.h
11index 29bd315..d675809 100644
12--- a/server/UbuntuMtpDatabase.h
13+++ b/server/UbuntuMtpDatabase.h
14@@ -1035,6 +1035,9 @@ public:
15         if (handle == 0 || handle == MTP_PARENT_ROOT)
16             return MTP_RESPONSE_INVALID_OBJECT_HANDLE;
17
18+        DbEntry entry = db.at(handle);
19+        if (entry.parent == 0)
20+            return MTP_RESPONSE_INVALID_OBJECT_HANDLE;
21         try {
22             if (db.at(handle).object_format == MTP_FORMAT_ASSOCIATION)
23                 inotify_rm_watch(inotify_fd, db.at(handle).watch_fd);
24--
252.7.4
26
27